"""Vocabularies and sources for the academics section. """ from zc.sourcefactory.basic import BasicSourceFactory try: from zope.catalog.interfaces import ICatalog except ImportError: # BBB from zope.app.catalog.interfaces import ICatalog from zope.component import getUtility from waeup.sirp.interfaces import SimpleWAeUPVocabulary inst_types = SimpleWAeUPVocabulary( ('Faculty of','faculty'), ('Department of','department'), ('School of','school_of'), ('School for','school_for'), ('Institute of','institute'), ('Office for','office'), ('Centre for','centre'), ('College','college'), ) course_levels = SimpleWAeUPVocabulary( ('100 (Year 1)',100), ('200 (Year 2)',200), ('300 (Year 3)',300), ('400 (Year 4)',400), ('500 (Year 5)',500), ('600 (Year 6)',600), ('700 (Year 7)',700), ('800 (Year 8)',800), ) semester = SimpleWAeUPVocabulary( ('N/A', 0), ('First Semester', 1), ('Second Semester', 2), ('Combined', 3) ) application_categories = SimpleWAeUPVocabulary( ('--',''), ('PUME, PDE, PCE, PRENCE','basic'), ('Part-Time, Diploma, Certificate','cest'), ('Sandwich','sandwich'), ('Postgraduate','pg'), ) study_mode = SimpleWAeUPVocabulary( ('UME Full Time','ume_ft'), ('Direct Entry Full Time','de_ft'), ('Diploma Full Time','dp_ft'), ('Diploma Part Time','dp_pt'), ('Undergraduate Full Time','ug_ft'), ('Undergraduate Part Time','ug_pt'), ('Postgraduate Full Time','pg_ft'), ('Postgraduate Part Time','pg_pt'), ) class CourseSource(BasicSourceFactory): """A course source delivers all courses inside the portal by looking up a catalog. """ def getValues(self): catalog = getUtility(ICatalog, name='courses_catalog') return sorted(list( catalog.searchResults( code=('', 'z*'))),key=lambda value: value.code) def getToken(self, value): return value.code def getTitle(self, value): return "%s - %s" % (value.code, value.title[:64])