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