"""Vocabularies and sources for the application section. """ from datetime import datetime from zope.component import getUtility from zope.catalog.interfaces import ICatalog from zc.sourcefactory.basic import BasicSourceFactory from zc.sourcefactory.contextual import BasicContextualSourceFactory from waeup.sirp.interfaces import SimpleWAeUPVocabulary from waeup.sirp.students.lgas import LGAS from waeup.sirp.students.vocabularies import ( entry_session_vocab, CertificateSource, GenderSource) #: Types of applications we support. APPLICATION_TYPES = ( ('General Studies', 'app','APP'), ('Pre-NCE Programme', 'prence','PRE'), ('Post UME Screening Test', 'pume','PUME'), ('Post UDE Screening', 'pude','PUDE'), ('Part Time Degree in Education', 'sandwich','SAND'), ('Part-Time Degree Programmes', 'pt','PTP'), ('Diploma Programmes', 'dp','DPP'), ('PCE Screening', 'pce','PCE'), ('Certificate Programmes', 'ct','CTP'), ('Common Entry Screening Test', 'cest','CEST'), ) #: A :class:`waeup.sirp.interfaces.SimpleWAeUPVocabulary` of supported #: application or screening types. application_types_vocab = SimpleWAeUPVocabulary( *[(x[0],x[1]) for x in APPLICATION_TYPES]) application_pins_vocab = SimpleWAeUPVocabulary( *[(u"%s (%s)" % (x[2],x[0]),x[2]) for x in APPLICATION_TYPES]) class AppCatCertificateSource(CertificateSource): """An application certificate source delivers all courses which belong to a certain application_category. """ def getValues(self, context): appcat = context.__parent__.application_category catalog = getUtility(ICatalog, name='certificates_catalog') return sorted(list( catalog.searchResults( code=('', 'z*'), application_category=(appcat,appcat))), key=lambda value: value.code)