Changeset 6648


Ignore:
Timestamp:
29 Aug 2011, 07:05:17 (13 years ago)
Author:
Henrik Bettermann
Message:

Reorganize vocabularies. The vocabs of the students package are the basis. In the application package only additional sources and vocabs should be defined.

Location:
main/waeup.sirp/trunk/src/waeup/sirp
Files:
2 added
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/interfaces.py

    r6594 r6648  
    3838from waeup.sirp.interfaces import IWAeUPObject
    3939from waeup.sirp.university.vocabularies import application_categories
     40from waeup.sirp.students.vocabularies import (
     41  year_range, lgas_vocab, CertificateSource, GenderSource,
     42  )
    4043from waeup.sirp.applicants.vocabularies import (
    41   year_range, application_types_vocab, application_pins_vocab,
    42   lgas_vocab, CertificateSource, AppCatCertificateSource, GenderSource,
     44  application_types_vocab, application_pins_vocab,
     45  AppCatCertificateSource,
    4346  )
    4447
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/vocabularies.py

    r6393 r6648  
    77from zc.sourcefactory.contextual import BasicContextualSourceFactory
    88from waeup.sirp.interfaces import SimpleWAeUPVocabulary
    9 from waeup.sirp.applicants.lgas import LGAS
     9from waeup.sirp.students.lgas import LGAS
     10from waeup.sirp.students.vocabularies import (
     11    entry_session_vocab, CertificateSource, GenderSource)
    1012
    1113#: Types of applications we support.
     
    2931application_pins_vocab = SimpleWAeUPVocabulary(
    3032    *[(u"%s (%s)" % (x[2],x[0]),x[2]) for x in APPLICATION_TYPES])
    31 lgas_vocab = SimpleWAeUPVocabulary(
    32     *sorted([(x[1],x[0]) for x in LGAS]))
    3333
    34 def year_range():
    35     curr_year = datetime.now().year
    36     return range(curr_year - 2, curr_year + 5)
    37 
    38 def entry_sessions():
    39     curr_year = datetime.now().year
    40     year_range = range(curr_year - 5, curr_year + 2)
    41     return [('%s/%s' % (year,year+1), '%s' % year) for year in year_range]
    42 
    43 entry_session_vocab = SimpleWAeUPVocabulary(*entry_sessions())
    44 
    45 class CertificateSource(BasicContextualSourceFactory):
    46     """A certificate source delivers all certificates provided
    47     in the portal.
    48     """
    49     def getValues(self, context):
    50         catalog = getUtility(ICatalog, name='certificates_catalog')
    51         return sorted(list(
    52                 catalog.searchResults(
    53                     code=('', 'z*'))),
    54                     key=lambda value: value.code)
    55 
    56     def getToken(self, context, value):
    57         return value.code
    58 
    59     def getTitle(self, context, value):
    60         return "%s - %s" % (value.code, value.title[:64])
    6134
    6235class AppCatCertificateSource(CertificateSource):
     
    7245                    application_category=(appcat,appcat))),
    7346                    key=lambda value: value.code)
    74 
    75 class GenderSource(BasicSourceFactory):
    76     """A gender source delivers basically a mapping
    77        ``{'m': 'Male', 'f': 'Female'}``
    78 
    79        Using a source, we make sure that the tokens (which are
    80        stored/expected for instance from CSV files) are something one
    81        can expect and not cryptic IntIDs.
    82     """
    83     def getValues(self):
    84         return ['m', 'f']
    85 
    86     def getToken(self, value):
    87         return value[0].lower()
    88 
    89     def getTitle(self, value):
    90         if value == 'm':
    91             return 'Male'
    92         if value == 'f':
    93             return 'Female'
  • main/waeup.sirp/trunk/src/waeup/sirp/students/interfaces.py

    r6642 r6648  
    44from zope import schema
    55from waeup.sirp.interfaces import IWAeUPObject
     6from waeup.sirp.students.vocabularies import (
     7  year_range, lgas_vocab, CertificateSource, GenderSource,
     8  )
    69
    710class IStudentNavigation(IWAeUPObject):
     
    102105    """
    103106
    104     certificate_code = schema.TextLine(
    105         title = u'Certificate Code',
    106         default = u'None',
     107    certificate = schema.Choice(
     108        title = u'Certificate',
     109        source = CertificateSource(),
     110        default = None,
    107111        required = True,
    108112        )
Note: See TracChangeset for help on using the changeset viewer.