[6256] | 1 | """Vocabularies and sources for the application section. |
---|
| 2 | """ |
---|
[6393] | 3 | from zope.component import getUtility |
---|
[6256] | 4 | from zope.catalog.interfaces import ICatalog |
---|
[6393] | 5 | from waeup.sirp.interfaces import SimpleWAeUPVocabulary |
---|
[7063] | 6 | from waeup.sirp.students.vocabularies import CertificateSource |
---|
[6256] | 7 | |
---|
| 8 | #: Types of applications we support. |
---|
| 9 | APPLICATION_TYPES = ( |
---|
| 10 | ('General Studies', 'app','APP'), |
---|
| 11 | ('Pre-NCE Programme', 'prence','PRE'), |
---|
| 12 | ('Post UME Screening Test', 'pume','PUME'), |
---|
| 13 | ('Post UDE Screening', 'pude','PUDE'), |
---|
| 14 | ('Part Time Degree in Education', 'sandwich','SAND'), |
---|
| 15 | ('Part-Time Degree Programmes', 'pt','PTP'), |
---|
| 16 | ('Diploma Programmes', 'dp','DPP'), |
---|
| 17 | ('PCE Screening', 'pce','PCE'), |
---|
| 18 | ('Certificate Programmes', 'ct','CTP'), |
---|
| 19 | ('Common Entry Screening Test', 'cest','CEST'), |
---|
| 20 | ) |
---|
| 21 | |
---|
| 22 | #: A :class:`waeup.sirp.interfaces.SimpleWAeUPVocabulary` of supported |
---|
| 23 | #: application or screening types. |
---|
| 24 | application_types_vocab = SimpleWAeUPVocabulary( |
---|
| 25 | *[(x[0],x[1]) for x in APPLICATION_TYPES]) |
---|
| 26 | application_pins_vocab = SimpleWAeUPVocabulary( |
---|
| 27 | *[(u"%s (%s)" % (x[2],x[0]),x[2]) for x in APPLICATION_TYPES]) |
---|
| 28 | |
---|
| 29 | |
---|
| 30 | class AppCatCertificateSource(CertificateSource): |
---|
| 31 | """An application certificate source delivers all courses which belong to |
---|
| 32 | a certain application_category. |
---|
| 33 | """ |
---|
| 34 | def getValues(self, context): |
---|
| 35 | appcat = context.__parent__.application_category |
---|
| 36 | catalog = getUtility(ICatalog, name='certificates_catalog') |
---|
| 37 | return sorted(list( |
---|
| 38 | catalog.searchResults( |
---|
| 39 | code=('', 'z*'), |
---|
| 40 | application_category=(appcat,appcat))), |
---|
| 41 | key=lambda value: value.code) |
---|