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

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

Reorder imports.

  • Property svn:keywords set to Id
File size: 2.4 KB
RevLine 
[6091]1"""Vocabularies and sources for the academics section.
2"""
[6094]3from datetime import datetime
[6091]4from zc.sourcefactory.basic import BasicSourceFactory
5try:
6    from zope.catalog.interfaces import ICatalog
7except ImportError:
8    # BBB
9    from zope.app.catalog.interfaces import ICatalog
10from zope.component import getUtility
[6095]11from waeup.sirp.interfaces import SimpleWAeUPVocabulary
[6091]12
13inst_types = SimpleWAeUPVocabulary(
14    ('Faculty of','faculty'),
15    ('Department of','department'),
16    ('School of','school_of'),
17    ('School for','school_for'),
18    ('Institute of','institute'),
19    ('Office for','office'),
20    ('Centre for','centre'),
21    ('College','college'),
22    )
23
24course_levels = SimpleWAeUPVocabulary(
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
35semester = SimpleWAeUPVocabulary(
36    ('N/A', 0),
37    ('First Semester', 1),
38    ('Second Semester', 2),
39    ('Combined', 3)
40    )
41
42application_category = SimpleWAeUPVocabulary(
43    ('--',''),
44    ('PUME, PDE, PCE, PRENCE','basic'),
45    ('Part-Time, Diploma, Certificate','cest'),
46    ('Sandwich','sandwich'),
47    ('Postgraduate','pg'),
48    )
49
50study_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
62class 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')
[6092]68        return sorted(list(
69                catalog.searchResults(
70                    code=('', 'z*'))),key=lambda value: value.code)
[6091]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])
77
78
79
80class FutureYearsSource(BasicSourceFactory):
[6093]81    """XXX: need docs
82    """
[6091]83    def getValues(self):
[6094]84        curr_year = datetime.now().year
85        return [x for x in range(curr_year - 2, curr_year + 5)]
[6091]86
87    def getToken(self, value):
88        return str(value)
89
90    def getTitle(self, value):
91      return str(value)
Note: See TracBrowser for help on using the repository browser.