[7195] | 1 | ## $Id: vocabularies.py 7601 2012-02-08 07:05:16Z henrik $ |
---|
| 2 | ## |
---|
| 3 | ## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann |
---|
| 4 | ## This program is free software; you can redistribute it and/or modify |
---|
| 5 | ## it under the terms of the GNU General Public License as published by |
---|
| 6 | ## the Free Software Foundation; either version 2 of the License, or |
---|
| 7 | ## (at your option) any later version. |
---|
| 8 | ## |
---|
| 9 | ## This program is distributed in the hope that it will be useful, |
---|
| 10 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 11 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 12 | ## GNU General Public License for more details. |
---|
| 13 | ## |
---|
| 14 | ## You should have received a copy of the GNU General Public License |
---|
| 15 | ## along with this program; if not, write to the Free Software |
---|
| 16 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
| 17 | ## |
---|
[6091] | 18 | """Vocabularies and sources for the academics section. |
---|
| 19 | """ |
---|
| 20 | from zc.sourcefactory.basic import BasicSourceFactory |
---|
[6557] | 21 | from zope.catalog.interfaces import ICatalog |
---|
[6091] | 22 | from zope.component import getUtility |
---|
[7321] | 23 | from waeup.sirp.interfaces import SimpleSIRPVocabulary |
---|
[6091] | 24 | |
---|
[7321] | 25 | inst_types = SimpleSIRPVocabulary( |
---|
[6091] | 26 | ('Faculty of','faculty'), |
---|
| 27 | ('Department of','department'), |
---|
[6504] | 28 | ('School of','school'), |
---|
[6091] | 29 | ('School for','school_for'), |
---|
| 30 | ('Institute of','institute'), |
---|
| 31 | ('Office for','office'), |
---|
| 32 | ('Centre for','centre'), |
---|
| 33 | ('College','college'), |
---|
| 34 | ) |
---|
| 35 | |
---|
[7321] | 36 | course_levels = SimpleSIRPVocabulary( |
---|
[7601] | 37 | ('Pre-Studies', 10), |
---|
[6091] | 38 | ('100 (Year 1)',100), |
---|
| 39 | ('200 (Year 2)',200), |
---|
| 40 | ('300 (Year 3)',300), |
---|
| 41 | ('400 (Year 4)',400), |
---|
| 42 | ('500 (Year 5)',500), |
---|
| 43 | ('600 (Year 6)',600), |
---|
| 44 | ('700 (Year 7)',700), |
---|
| 45 | ('800 (Year 8)',800), |
---|
| 46 | ) |
---|
| 47 | |
---|
[7321] | 48 | semester = SimpleSIRPVocabulary( |
---|
[7601] | 49 | ('N/A', 9), |
---|
[6091] | 50 | ('First Semester', 1), |
---|
| 51 | ('Second Semester', 2), |
---|
| 52 | ('Combined', 3) |
---|
| 53 | ) |
---|
| 54 | |
---|
[7321] | 55 | application_categories = SimpleSIRPVocabulary( |
---|
[6091] | 56 | ('PUME, PDE, PCE, PRENCE','basic'), |
---|
| 57 | ('Part-Time, Diploma, Certificate','cest'), |
---|
| 58 | ('Sandwich','sandwich'), |
---|
| 59 | ('Postgraduate','pg'), |
---|
[7601] | 60 | ('no application','no'), |
---|
[6091] | 61 | ) |
---|
| 62 | |
---|
[7321] | 63 | study_modes = SimpleSIRPVocabulary( |
---|
[6091] | 64 | ('UME Full Time','ume_ft'), |
---|
| 65 | ('Direct Entry Full Time','de_ft'), |
---|
[7528] | 66 | ('Direct Entry Part Time','de_pt'), |
---|
[6091] | 67 | ('Diploma Full Time','dp_ft'), |
---|
| 68 | ('Diploma Part Time','dp_pt'), |
---|
| 69 | ('Undergraduate Full Time','ug_ft'), |
---|
| 70 | ('Undergraduate Part Time','ug_pt'), |
---|
| 71 | ('Postgraduate Full Time','pg_ft'), |
---|
| 72 | ('Postgraduate Part Time','pg_pt'), |
---|
[7528] | 73 | ('Certificate Full Time','ct_ft'), |
---|
| 74 | ('Certificate Part Time','ct_pt'), |
---|
| 75 | ('Remedial','rm_ft'), |
---|
| 76 | ('Remedial with deficiencies','rmd_ft'), |
---|
| 77 | ('Post Higher Education Full Time','ph_ft'), |
---|
| 78 | ('Joint Matriculation Full Time','jm_ft'), |
---|
| 79 | ('Transfer Full Time','transfer_ft'), |
---|
| 80 | ('Transfer Part Time','transfer_pt'), |
---|
[6091] | 81 | ) |
---|
| 82 | |
---|
| 83 | class CourseSource(BasicSourceFactory): |
---|
| 84 | """A course source delivers all courses inside the portal by looking |
---|
| 85 | up a catalog. |
---|
| 86 | """ |
---|
| 87 | def getValues(self): |
---|
| 88 | catalog = getUtility(ICatalog, name='courses_catalog') |
---|
[6092] | 89 | return sorted(list( |
---|
| 90 | catalog.searchResults( |
---|
| 91 | code=('', 'z*'))),key=lambda value: value.code) |
---|
[6091] | 92 | |
---|
| 93 | def getToken(self, value): |
---|
| 94 | return value.code |
---|
| 95 | |
---|
| 96 | def getTitle(self, value): |
---|
| 97 | return "%s - %s" % (value.code, value.title[:64]) |
---|