source: main/waeup.sirp/trunk/src/waeup/sirp/university/vocabularies.py @ 6093

Last change on this file since 6093 was 6093, checked in by uli, 14 years ago

Add a docstring.

  • Property svn:keywords set to Id
File size: 2.4 KB
Line 
1"""Vocabularies and sources for the academics section.
2"""
3
4from waeup.sirp.interfaces import SimpleWAeUPVocabulary
5from zc.sourcefactory.basic import BasicSourceFactory
6try:
7    from zope.catalog.interfaces import ICatalog
8except ImportError:
9    # BBB
10    from zope.app.catalog.interfaces import ICatalog
11from zope.component import getUtility
12import datetime
13
14inst_types = SimpleWAeUPVocabulary(
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
25course_levels = SimpleWAeUPVocabulary(
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    )
35
36semester = SimpleWAeUPVocabulary(
37    ('N/A', 0),
38    ('First Semester', 1),
39    ('Second Semester', 2),
40    ('Combined', 3)
41    )
42
43application_category = SimpleWAeUPVocabulary(
44    ('--',''),
45    ('PUME, PDE, PCE, PRENCE','basic'),
46    ('Part-Time, Diploma, Certificate','cest'),
47    ('Sandwich','sandwich'),
48    ('Postgraduate','pg'),
49    )
50
51study_mode = SimpleWAeUPVocabulary(
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    )
61
62
63class 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(
70                catalog.searchResults(
71                    code=('', 'z*'))),key=lambda value: value.code)
72
73    def getToken(self, value):
74        return value.code
75
76    def getTitle(self, value):
77        return "%s - %s" % (value.code, value.title[:64])
78
79
80
81class FutureYearsSource(BasicSourceFactory):
82    """XXX: need docs
83    """
84    def getValues(self):
85        cy = datetime.datetime.now().year
86        return [x for x in range(cy-2,cy+5)]
87
88    def getToken(self, value):
89        return str(value)
90
91    def getTitle(self, value):
92      return str(value)
Note: See TracBrowser for help on using the repository browser.