Esempio n. 1
0
 def addWorkflowFields(self, classDescr):
     '''Adds, for a given p_classDescr, the workflow-related fields.'''
     className = classDescr.name
     groupName = classDescr.klass.__name__
     # Adds a field allowing to show/hide completely any workflow-related
     # information for a given class.
     defaultValue = False
     if classDescr.isRoot() or issubclass(classDescr.klass, ModelClass):
         defaultValue = True
     fieldName = 'showWorkflowFor%s' % className
     fieldType = gen.Boolean(default=defaultValue,
                             page='userInterface',
                             group=groupName)
     self.addField(fieldName, fieldType)
     # Adds the boolean field for showing all states in current state or not.
     # If this boolean is True but the current phase counts only one state,
     # we will not show the state at all: the fact of knowing in what phase
     # we are is sufficient. If this boolean is False, we simply show the
     # current state.
     defaultValue = False
     if len(classDescr.getPhases()) > 1:
         defaultValue = True
     fieldName = 'showAllStatesInPhaseFor%s' % className
     fieldType = gen.Boolean(default=defaultValue,
                             page='userInterface',
                             group=groupName)
     self.addField(fieldName, fieldType)
 def addSearchRelatedFields(self, classDescr):
     '''Adds, for class p_classDescr, attributes related to the search
        functionality for class p_classDescr.'''
     className = classDescr.name
     # Field that defines if advanced search is enabled for class
     # p_classDescr or not.
     fieldName = 'enableAdvancedSearchFor%s' % className
     fieldType = gen.Boolean(default=True,
                             page='userInterface',
                             group=classDescr.klass.__name__)
     self.addField(fieldName, fieldType)
     # Field that defines how many columns are shown on the custom search
     # screen.
     fieldName = 'numberOfSearchColumnsFor%s' % className
     fieldType = gen.Integer(default=3,
                             page='userInterface',
                             group=classDescr.klass.__name__)
     self.addField(fieldName, fieldType)
     # Field that allows to select, among all indexed fields, what fields
     # must really be used in the search screen.
     fieldName = 'searchFieldsFor%s' % className
     defaultValue = [
         a[0] for a in classDescr.getOrderedAppyAttributes(
             condition='attrValue.indexed')
     ]
     if 'title' not in defaultValue: defaultValue.insert(0, 'title')
     fieldType = gen.String(multiplicity=(0, None),
                            validator=gen.Selection(
                                '_appy_getSearchableFields*%s' % className),
                            default=defaultValue,
                            page='userInterface',
                            group=classDescr.klass.__name__)
     self.addField(fieldName, fieldType)
Esempio n. 3
0
class Tool(ModelClass):
    # In a ModelClass we need to declare attributes in the following list.
    _appy_attributes = list(defaultToolFields)

    # Tool attributes
    def validPythonWithUno(self, value):
        pass  # Real method in the wrapper

    unoEnabledPython = gen.String(group="connectionToOpenOffice",
                                  validator=validPythonWithUno)
    openOfficePort = gen.Integer(default=2002, group="connectionToOpenOffice")
    numberOfResultsPerPage = gen.Integer(default=30, show=False)
    listBoxesMaximumWidth = gen.Integer(default=100, show=False)
    appyVersion = gen.String(show=False, layouts='f')

    def refreshSecurity(self):
        pass  # Real method in the wrapper

    refreshSecurity = gen.Action(action=refreshSecurity, confirm=True)
    # Ref(User) will maybe be transformed into Ref(CustomUserClass).
    users = gen.Ref(User,
                    multiplicity=(0, None),
                    add=True,
                    link=False,
                    back=gen.Ref(attribute='toTool', show=False),
                    page=gen.Page('users', show='view'),
                    queryable=True,
                    queryFields=('title', 'login'),
                    showHeaders=True,
                    shownInfo=('title', 'login', 'roles'))
    groups = gen.Ref(Group,
                     multiplicity=(0, None),
                     add=True,
                     link=False,
                     back=gen.Ref(attribute='toTool2', show=False),
                     page=gen.Page('groups', show='view'),
                     queryable=True,
                     queryFields=('title', 'login'),
                     showHeaders=True,
                     shownInfo=('title', 'login', 'roles'))
    translations = gen.Ref(Translation,
                           multiplicity=(0, None),
                           add=False,
                           link=False,
                           show='view',
                           back=gen.Ref(attribute='trToTool', show=False),
                           page=gen.Page('translations', show='view'))
    enableNotifications = gen.Boolean(default=True,
                                      page=gen.Page('notifications',
                                                    show=False))

    @classmethod
    def _appy_clean(klass):
        toClean = []
        for k, v in klass.__dict__.iteritems():
            if not k.startswith('__') and (not k.startswith('_appy_')):
                if k not in defaultToolFields:
                    toClean.append(k)
        for k in toClean:
            exec 'del klass.%s' % k
        klass._appy_attributes = list(defaultToolFields)
Esempio n. 4
0
class Tool(ModelClass):
    # In a ModelClass we need to declare attributes in the following list.
    _appy_attributes = list(defaultToolFields)
    folder = True

    # Tool attributes
    def isManager(self):
        pass

    def isManagerEdit(self):
        pass

    lf = {'layouts': 'f'}
    title = gen.String(show=False,
                       page=gen.Page('main', show=False),
                       default='Configuration',
                       **lf)
    mailHost = gen.String(default='localhost:25', **lf)
    mailEnabled = gen.Boolean(default=False, **lf)
    mailFrom = gen.String(default='*****@*****.**', **lf)
    appyVersion = gen.String(**lf)
    dateFormat = gen.String(default='%d/%m/%Y', **lf)
    hourFormat = gen.String(default='%H:%M', **lf)

    # Ref(User) will maybe be transformed into Ref(CustomUserClass).
    userPage = gen.Page('users', show=isManager)
    users = gen.Ref(User,
                    multiplicity=(0, None),
                    add=True,
                    link=False,
                    back=gen.Ref(attribute='toTool', show=False),
                    page=userPage,
                    queryable=True,
                    queryFields=('title', 'login'),
                    show=isManager,
                    showHeaders=True,
                    shownInfo=('title', 'login', 'roles'))

    def computeConnectedUsers(self):
        pass

    connectedUsers = gen.Computed(method=computeConnectedUsers,
                                  page=userPage,
                                  plainText=False,
                                  show=isManager)
    groups = gen.Ref(Group,
                     multiplicity=(0, None),
                     add=True,
                     link=False,
                     back=gen.Ref(attribute='toTool2', show=False),
                     page=gen.Page('groups', show=isManager),
                     show=isManager,
                     queryable=True,
                     queryFields=('title', 'login'),
                     showHeaders=True,
                     shownInfo=('title', 'login', 'roles'))
    pt = gen.Page('translations', show=isManager)
    translations = gen.Ref(Translation,
                           multiplicity=(0, None),
                           add=False,
                           link=False,
                           show='view',
                           page=pt,
                           back=gen.Ref(attribute='trToTool', show=False))
    loadTranslationsAtStartup = gen.Boolean(default=True,
                                            show=False,
                                            page=pt,
                                            layouts='f')
    pages = gen.Ref(Page,
                    multiplicity=(0, None),
                    add=True,
                    link=False,
                    show='view',
                    back=gen.Ref(attribute='toTool3', show=False),
                    page=gen.Page('pages', show=isManager))

    # Document generation page
    dgp = {'page': gen.Page('documents', show=isManagerEdit)}

    def validPythonWithUno(self, value):
        pass  # Real method in the wrapper

    unoEnabledPython = gen.String(default='/usr/bin/python',
                                  show=False,
                                  validator=validPythonWithUno,
                                  **dgp)
    openOfficePort = gen.Integer(default=2002, show=False, **dgp)
    # User interface page
    numberOfResultsPerPage = gen.Integer(default=30,
                                         page=gen.Page('userInterface',
                                                       show=False))

    @classmethod
    def _appy_clean(klass):
        toClean = []
        for k, v in klass.__dict__.iteritems():
            if not k.startswith('__') and (not k.startswith('_appy_')):
                if k not in defaultToolFields:
                    toClean.append(k)
        for k in toClean:
            exec 'del klass.%s' % k
        klass._appy_attributes = list(defaultToolFields)
        klass.folder = True