source: main/waeup.sirp/trunk/src/waeup/sirp/applicants/vocabularies.py @ 7090

Last change on this file since 7090 was 7063, checked in by uli, 13 years ago

Merge changes from branch ulif-extimgstore back into trunk.
Beside external image storage also waeupdocs should work again.

  • Property svn:keywords set to Id
File size: 1.6 KB
Line 
1"""Vocabularies and sources for the application section.
2"""
3from zope.component import getUtility
4from zope.catalog.interfaces import ICatalog
5from waeup.sirp.interfaces import SimpleWAeUPVocabulary
6from waeup.sirp.students.vocabularies import CertificateSource
7
8#: Types of applications we support.
9APPLICATION_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.
24application_types_vocab = SimpleWAeUPVocabulary(
25    *[(x[0],x[1]) for x in APPLICATION_TYPES])
26application_pins_vocab = SimpleWAeUPVocabulary(
27    *[(u"%s (%s)" % (x[2],x[0]),x[2]) for x in APPLICATION_TYPES])
28
29
30class 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)
Note: See TracBrowser for help on using the repository browser.