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