1 | """Vocabularies and sources for the academics section. |
---|
2 | """ |
---|
3 | from zc.sourcefactory.basic import BasicSourceFactory |
---|
4 | try: |
---|
5 | from zope.catalog.interfaces import ICatalog |
---|
6 | except ImportError: |
---|
7 | # BBB |
---|
8 | from zope.app.catalog.interfaces import ICatalog |
---|
9 | from zope.component import getUtility |
---|
10 | from waeup.sirp.interfaces import SimpleWAeUPVocabulary |
---|
11 | |
---|
12 | inst_types = SimpleWAeUPVocabulary( |
---|
13 | ('Faculty of','faculty'), |
---|
14 | ('Department of','department'), |
---|
15 | ('School of','school'), |
---|
16 | ('School for','school_for'), |
---|
17 | ('Institute of','institute'), |
---|
18 | ('Office for','office'), |
---|
19 | ('Centre for','centre'), |
---|
20 | ('College','college'), |
---|
21 | ) |
---|
22 | |
---|
23 | course_levels = SimpleWAeUPVocabulary( |
---|
24 | ('Pre-Studies',0), |
---|
25 | ('100 (Year 1)',100), |
---|
26 | ('200 (Year 2)',200), |
---|
27 | ('300 (Year 3)',300), |
---|
28 | ('400 (Year 4)',400), |
---|
29 | ('500 (Year 5)',500), |
---|
30 | ('600 (Year 6)',600), |
---|
31 | ('700 (Year 7)',700), |
---|
32 | ('800 (Year 8)',800), |
---|
33 | ) |
---|
34 | |
---|
35 | semester = SimpleWAeUPVocabulary( |
---|
36 | ('N/A', 0), |
---|
37 | ('First Semester', 1), |
---|
38 | ('Second Semester', 2), |
---|
39 | ('Combined', 3) |
---|
40 | ) |
---|
41 | |
---|
42 | application_categories = SimpleWAeUPVocabulary( |
---|
43 | ('--',''), |
---|
44 | ('PUME, PDE, PCE, PRENCE','basic'), |
---|
45 | ('Part-Time, Diploma, Certificate','cest'), |
---|
46 | ('Sandwich','sandwich'), |
---|
47 | ('Postgraduate','pg'), |
---|
48 | ) |
---|
49 | |
---|
50 | study_mode = SimpleWAeUPVocabulary( |
---|
51 | ('UME Full Time','ume_ft'), |
---|
52 | ('Direct Entry Full Time','de_ft'), |
---|
53 | ('Diploma Full Time','dp_ft'), |
---|
54 | ('Diploma Part Time','dp_pt'), |
---|
55 | ('Undergraduate Full Time','ug_ft'), |
---|
56 | ('Undergraduate Part Time','ug_pt'), |
---|
57 | ('Postgraduate Full Time','pg_ft'), |
---|
58 | ('Postgraduate Part Time','pg_pt'), |
---|
59 | ) |
---|
60 | |
---|
61 | |
---|
62 | class CourseSource(BasicSourceFactory): |
---|
63 | """A course source delivers all courses inside the portal by looking |
---|
64 | up a catalog. |
---|
65 | """ |
---|
66 | def getValues(self): |
---|
67 | catalog = getUtility(ICatalog, name='courses_catalog') |
---|
68 | return sorted(list( |
---|
69 | catalog.searchResults( |
---|
70 | code=('', 'z*'))),key=lambda value: value.code) |
---|
71 | |
---|
72 | def getToken(self, value): |
---|
73 | return value.code |
---|
74 | |
---|
75 | def getTitle(self, value): |
---|
76 | return "%s - %s" % (value.code, value.title[:64]) |
---|