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_of'), |
---|
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 | ('100 (Year 1)',100), |
---|
25 | ('200 (Year 2)',200), |
---|
26 | ('300 (Year 3)',300), |
---|
27 | ('400 (Year 4)',400), |
---|
28 | ('500 (Year 5)',500), |
---|
29 | ('600 (Year 6)',600), |
---|
30 | ('700 (Year 7)',700), |
---|
31 | ('800 (Year 8)',800), |
---|
32 | ) |
---|
33 | |
---|
34 | semester = SimpleWAeUPVocabulary( |
---|
35 | ('N/A', 0), |
---|
36 | ('First Semester', 1), |
---|
37 | ('Second Semester', 2), |
---|
38 | ('Combined', 3) |
---|
39 | ) |
---|
40 | |
---|
41 | application_category = SimpleWAeUPVocabulary( |
---|
42 | ('--',''), |
---|
43 | ('PUME, PDE, PCE, PRENCE','basic'), |
---|
44 | ('Part-Time, Diploma, Certificate','cest'), |
---|
45 | ('Sandwich','sandwich'), |
---|
46 | ('Postgraduate','pg'), |
---|
47 | ) |
---|
48 | |
---|
49 | study_mode = SimpleWAeUPVocabulary( |
---|
50 | ('UME Full Time','ume_ft'), |
---|
51 | ('Direct Entry Full Time','de_ft'), |
---|
52 | ('Diploma Full Time','dp_ft'), |
---|
53 | ('Diploma Part Time','dp_pt'), |
---|
54 | ('Undergraduate Full Time','ug_ft'), |
---|
55 | ('Undergraduate Part Time','ug_pt'), |
---|
56 | ('Postgraduate Full Time','pg_ft'), |
---|
57 | ('Postgraduate Part Time','pg_pt'), |
---|
58 | ) |
---|
59 | |
---|
60 | |
---|
61 | class CourseSource(BasicSourceFactory): |
---|
62 | """A course source delivers all courses inside the portal by looking |
---|
63 | up a catalog. |
---|
64 | """ |
---|
65 | def getValues(self): |
---|
66 | catalog = getUtility(ICatalog, name='courses_catalog') |
---|
67 | return sorted(list( |
---|
68 | catalog.searchResults( |
---|
69 | code=('', 'z*'))),key=lambda value: value.code) |
---|
70 | |
---|
71 | def getToken(self, value): |
---|
72 | return value.code |
---|
73 | |
---|
74 | def getTitle(self, value): |
---|
75 | return "%s - %s" % (value.code, value.title[:64]) |
---|