Changeset 6648 for main/waeup.sirp/trunk/src/waeup
- Timestamp:
- 29 Aug 2011, 07:05:17 (13 years ago)
- 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 38 38 from waeup.sirp.interfaces import IWAeUPObject 39 39 from waeup.sirp.university.vocabularies import application_categories 40 from waeup.sirp.students.vocabularies import ( 41 year_range, lgas_vocab, CertificateSource, GenderSource, 42 ) 40 43 from 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, 43 46 ) 44 47 -
main/waeup.sirp/trunk/src/waeup/sirp/applicants/vocabularies.py
r6393 r6648 7 7 from zc.sourcefactory.contextual import BasicContextualSourceFactory 8 8 from waeup.sirp.interfaces import SimpleWAeUPVocabulary 9 from waeup.sirp.applicants.lgas import LGAS 9 from waeup.sirp.students.lgas import LGAS 10 from waeup.sirp.students.vocabularies import ( 11 entry_session_vocab, CertificateSource, GenderSource) 10 12 11 13 #: Types of applications we support. … … 29 31 application_pins_vocab = SimpleWAeUPVocabulary( 30 32 *[(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]))33 33 34 def year_range():35 curr_year = datetime.now().year36 return range(curr_year - 2, curr_year + 5)37 38 def entry_sessions():39 curr_year = datetime.now().year40 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 provided47 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.code58 59 def getTitle(self, context, value):60 return "%s - %s" % (value.code, value.title[:64])61 34 62 35 class AppCatCertificateSource(CertificateSource): … … 72 45 application_category=(appcat,appcat))), 73 46 key=lambda value: value.code) 74 75 class GenderSource(BasicSourceFactory):76 """A gender source delivers basically a mapping77 ``{'m': 'Male', 'f': 'Female'}``78 79 Using a source, we make sure that the tokens (which are80 stored/expected for instance from CSV files) are something one81 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 4 4 from zope import schema 5 5 from waeup.sirp.interfaces import IWAeUPObject 6 from waeup.sirp.students.vocabularies import ( 7 year_range, lgas_vocab, CertificateSource, GenderSource, 8 ) 6 9 7 10 class IStudentNavigation(IWAeUPObject): … … 102 105 """ 103 106 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, 107 111 required = True, 108 112 )
Note: See TracChangeset for help on using the changeset viewer.