예제 #1
0
    def flags(self, index):
        # mainlog.debug("flags(r={},c={}) mask={}".format(index.row(),index.column(),self.edit_mask))

        if self.edit_mask:
            # mainlog.debug("edit_mask")
            if index.column() >= len(self.edit_mask):
                mainlog.warning("Index out of range ({} but max is {})".format(index.column(),len(self.edit_mask)))
                return Qt.ItemIsEnabled

            m = self.edit_mask[index.column()]
            if isfunction(m): # hasattr(m,'__call__'):
                return m(index)
            else:
                return m
        else:
            return Qt.ItemIsEditable | Qt.ItemIsSelectable | Qt.ItemIsEnabled
예제 #2
0
def makeErrorBox(text,info_text = None,ex=None):
    mainlog.warning("makeErrorBox : {}".format(text))
    errorBox = QMessageBox()
    errorBox.setObjectName("error_box")
    errorBox.setWindowTitle(_("Error !"))
    errorBox.setIcon(QMessageBox.Critical)

    t = info_text
    if ex:
        nfo = ""
        if info_text:
            nfo = info_text + u'\n'
        t = u"{}{}\n{}".format(nfo,_("Additional information :"), str(ex))
    _setBoxTexts(errorBox,text,t)
    errorBox.setStandardButtons(QMessageBox.Ok)

    if ex:
        log_stacktrace()
        mainlog.exception(ex)
    return errorBox
예제 #3
0
    def _make_path_to_document(self, doc_id, filename):
        # The path must be absolute because CherryPy likes it
        # when it serves files.

        doc_root = configuration.get("DocumentsDatabase", "documents_root")
        if not doc_root:
            raise Exception(
                "Can't find the document root directory in the configuration, so I'll be unable to locate documents.."
            )

        fs_encoding = 'ISO-8859-1'  # FIXME Put that in the server config file
        if os.path.supports_unicode_filenames:
            fs_encoding = 'UTF-8'
        else:
            mainlog.warning("File system doesn't support unicode...")

        fn = u"{}_{}_{}".format(configuration.get("Globals", "codename"),
                                doc_id, filename)
        fn = fn.encode(fs_encoding,
                       'replace').decode(fs_encoding).replace('?', '_')
        fn = fn.replace(os.sep, '_')
        fn = fn.replace(' ', '_')

        return os.path.join(doc_root, fn)
예제 #4
0
import hashlib
from sqlalchemy import Column, String, LargeBinary, Boolean, Integer, Sequence
from sqlalchemy.orm import reconstructor

from koi.Configurator import mainlog

try:
    from PySide.QtGui import QPixmap, QImage
    from PySide.QtCore import Qt, QByteArray, QBuffer, QIODevice
except:
    # All of this because on some  platform (such as Raspberry) it's hard to get a
    # working versin of PySide with painful recompilation.
    mainlog.warning(
        "Could not import PySide. This is tolerated as a fix to be able to deploy the server because it doesn't need Qt"
    )

from koi.datalayer.SQLAEnum import DeclEnum
from koi.datalayer.sqla_mapping_base import metadata, Base, DATABASE_SCHEMA

try:
    _('')
except:
    _ = lambda x: x


class RoleType(DeclEnum):
    view_timetrack = 'view_timetrack', _("View time tracks")
    timetrack_modify = 'TimeTrackModify', _("Modify time tracks")
    modify_parameters = 'ModifyParameters', _("Modify parameters")

    modify_monthly_time_track_correction = 'modify_monthly_time_track_correction', _(