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

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

Fix indentation. In Python we normally use 4 spaces.

  • 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(catalog.searchResults(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])
76
77
78
79class FutureYearsSource(BasicSourceFactory):
80    def getValues(self):
81        cy = datetime.datetime.now().year
82        return [x for x in range(cy-2,cy+5)]
83
84    def getToken(self, value):
85        return str(value)
86
87    def getTitle(self, value):
88      return str(value)
Note: See TracBrowser for help on using the repository browser.