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)
예제 #2
0
파일: model.py 프로젝트: MarsStirner/webmis
class Group(ModelClass):
    # In a ModelClass we need to declare attributes in the following list.
    _appy_attributes = ['title', 'login', 'roles', 'users']
    # All methods defined below are fake. Real versions are in the wrapper.
    m = {'group': 'main', 'width': 25, 'indexed': True}
    title = gen.String(multiplicity=(1, 1), **m)

    def showLogin(self):
        pass

    def validateLogin(self):
        pass

    login = gen.String(show=showLogin,
                       validator=validateLogin,
                       multiplicity=(1, 1),
                       **m)
    roles = gen.String(validator=gen.Selection('getGrantableRoles'),
                       multiplicity=(0, None),
                       **m)
    users = gen.Ref(User,
                    multiplicity=(0, None),
                    add=False,
                    link=True,
                    back=gen.Ref(attribute='groups', show=True),
                    showHeaders=True,
                    shownInfo=('title', 'login'))
예제 #3
0
 def installAppyTypes(self):
     '''We complete here the initialisation process of every Appy type of
        every gen-class of the application.'''
     appName = self.productName
     for klass in self.classes:
         # Store on wrapper class the ordered list of Appy types
         wrapperClass = klass.wrapperClass
         if not hasattr(wrapperClass, 'title'):
             # Special field "type" is mandatory for every class.
             title = gen.String(multiplicity=(1, 1),
                                show='edit',
                                indexed=True,
                                searchable=True)
             title.init('title', None, 'appy')
             setattr(wrapperClass, 'title', title)
         # Special field "state" must be added for every class. It must be a
         # "select" field, because it will be necessary for displaying the
         # translated state name.
         state = gen.String(validator=gen.Selection('listStates'),
                            show='result')
         state.init('state', None, 'workflow')
         setattr(wrapperClass, 'state', state)
         names = self.config.attributes[wrapperClass.__name__[:-8]]
         wrapperClass.__fields__ = [getattr(wrapperClass, n) for n in names]
         # Post-initialise every Appy type
         for baseClass in klass.wrapperClass.__bases__:
             if baseClass.__name__ == 'AbstractWrapper': continue
             for name, appyType in baseClass.__dict__.iteritems():
                 if not isinstance(appyType, gen.Field) or \
                        (isinstance(appyType, gen.Ref) and appyType.isBack):
                     continue  # Back refs are initialised within fw refs
                 appyType.init(name, baseClass, appName)
예제 #4
0
class Group(ModelClass):
    _appy_attributes = ['title', 'login', 'roles', 'users', 'toTool2']
    # All methods defined below are fake. Real versions are in the wrapper.
    m = {'group': 'main', 'width': 25, 'indexed': True}
    title = gen.String(multiplicity=(1, 1), **m)

    def showLogin(self):
        pass

    def validateLogin(self):
        pass

    login = gen.String(show=showLogin,
                       validator=validateLogin,
                       multiplicity=(1, 1),
                       **m)
    roles = gen.String(validator=gen.Selection('getGrantableRoles'),
                       multiplicity=(0, None),
                       **m)

    def getSelectableUsers(self):
        pass

    users = gen.Ref(User,
                    multiplicity=(0, None),
                    add=False,
                    link=True,
                    back=gen.Ref(attribute='groups',
                                 show=User.showRoles,
                                 multiplicity=(0, None)),
                    select=getSelectableUsers,
                    height=15,
                    showHeaders=True,
                    shownInfo=('title', 'login'))
예제 #5
0
 def addQueryResultColumns(self, classDescr):
     '''Adds, for class p_classDescr, the attribute in the tool that allows
        to select what default columns will be shown on query results.'''
     className = classDescr.name
     fieldName = 'resultColumnsFor%s' % className
     fieldType = gen.String(multiplicity=(0, None),
                            validator=gen.Selection(
                                '_appy_getAllFields*%s' % className),
                            page='userInterface',
                            group=classDescr.klass.__name__)
     self.addField(fieldName, fieldType)
예제 #6
0
class User(ModelClass):
    # In a ModelClass we need to declare attributes in the following list.
    _appy_attributes = [
        'title', 'name', 'firstName', 'login', 'password1', 'password2',
        'email', 'roles'
    ]
    # All methods defined below are fake. Real versions are in the wrapper.
    title = gen.String(show=False, indexed=True)
    gm = {'group': 'main', 'width': 25}

    def showName(self):
        pass

    name = gen.String(show=showName, **gm)
    firstName = gen.String(show=showName, **gm)

    def showEmail(self):
        pass

    email = gen.String(show=showEmail)
    gm['multiplicity'] = (1, 1)

    def showLogin(self):
        pass

    def validateLogin(self):
        pass

    login = gen.String(show=showLogin,
                       validator=validateLogin,
                       indexed=True,
                       **gm)

    def showPassword(self):
        pass

    def validatePassword(self):
        pass

    password1 = gen.String(format=gen.String.PASSWORD,
                           show=showPassword,
                           validator=validatePassword,
                           **gm)
    password2 = gen.String(format=gen.String.PASSWORD, show=showPassword, **gm)
    gm['multiplicity'] = (0, None)

    def showRoles(self):
        pass

    roles = gen.String(show=showRoles,
                       indexed=True,
                       validator=gen.Selection('getGrantableRoles'),
                       **gm)
 def addPodRelatedFields(self, fieldDescr):
     '''Adds the fields needed in the Tool for configuring a Pod field.'''
     className = fieldDescr.classDescr.name
     # On what page and group to display those fields ?
     pg = {
         'page': 'documents',
         'group': gen.Group(fieldDescr.classDescr.klass.__name__,
                            ['50%'] * 2)
     }
     # Add the field that will store the pod template.
     fieldName = 'podTemplateFor%s_%s' % (className, fieldDescr.fieldName)
     fieldType = gen.File(**pg)
     self.addField(fieldName, fieldType)
     # Add the field that will store the output format(s)
     fieldName = 'formatsFor%s_%s' % (className, fieldDescr.fieldName)
     fieldType = gen.String(validator=gen.Selection('getPodOutputFormats'),
                            multiplicity=(1, None),
                            default=('odt', ),
                            **pg)
     self.addField(fieldName, fieldType)
예제 #8
0
class User(ModelClass):
    _appy_attributes = [
        'password1', 'password2', 'title', 'name', 'firstName', 'login',
        'email', 'roles', 'source', 'groups', 'toTool'
    ]

    # Passwords are on a specific page.
    def showPassword(self):
        pass

    def validatePassword(self):
        pass

    pp = {
        'page': gen.Page('passwords', showNext=False, show=showPassword),
        'width': 34,
        'multiplicity': (1, 1),
        'format': gen.String.PASSWORD,
        'show': showPassword
    }
    password1 = gen.String(validator=validatePassword, **pp)
    password2 = gen.String(**pp)

    # All methods defined below are fake. Real versions are in the wrapper.
    pm = {
        'page': gen.Page('main', showPrevious=False),
        'group': 'main',
        'width': 34
    }
    title = gen.String(show=False, indexed=True, **pm)

    def showName(self):
        pass

    name = gen.String(show=showName, **pm)
    firstName = gen.String(show=showName, **pm)

    def showEmail(self):
        pass

    email = gen.String(show=showEmail, **pm)
    # Where is this user stored? By default, in the ZODB. But the user can be
    # stored in an external LDAP (source='ldap').
    source = gen.String(show=False, default='zodb', layouts='f', **pm)
    pm['multiplicity'] = (1, 1)

    def showLogin(self):
        pass

    def validateLogin(self):
        pass

    login = gen.String(show=showLogin,
                       validator=validateLogin,
                       indexed=True,
                       **pm)
    pm['multiplicity'] = (0, None)

    def showRoles(self):
        pass

    roles = gen.String(show=showRoles,
                       indexed=True,
                       validator=gen.Selection('getGrantableRoles'),
                       **pm)