Changeset 7681 for main/waeup.sirp/trunk/src/waeup/sirp/university
- Timestamp:
- 22 Feb 2012, 21:14:09 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/university
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/university/__init__.py
r7333 r7681 2 2 from waeup.sirp.university.course import Course 3 3 from waeup.sirp.university.coursescontainer import CoursesContainer 4 from waeup.sirp.university.certificate import Certificate 5 from waeup.sirp.university.certificatescontainer import CertificatesContainer 4 6 from waeup.sirp.university.faculty import Faculty 7 from waeup.sirp.university.department import Department 5 8 from waeup.sirp.university.facultiescontainer import FacultiesContainer 6 9 __all__ = ( 7 'Course', 'CoursesContainer', 'Faculty', 'FacultiesContainer') 10 'Course', 'CoursesContainer', 11 'Certificate', 'CertificatesContainer', 12 'Faculty', 'FacultiesContainer', 'Department') -
main/waeup.sirp/trunk/src/waeup/sirp/university/department.py
r7334 r7681 19 19 """ 20 20 import grok 21 from zope.component import createObject22 21 from zope.component.interfaces import IFactory 23 22 from zope.interface import implementedBy 23 from zope.component import getUtility 24 from waeup.sirp.university.coursescontainer import CoursesContainer 25 from waeup.sirp.university.certificatescontainer import CertificatesContainer 26 from waeup.sirp.interfaces import ISIRPUtils 24 27 from waeup.sirp.university.interfaces import IDepartment, IDepartmentAdd 25 from waeup.sirp.university.vocabularies import inst_types26 28 27 29 class Department(grok.Container): … … 53 55 self.title_prefix = title_prefix 54 56 self.code = code 55 self.courses = createObject(u'waeup.CoursesContainer')57 self.courses = CoursesContainer() 56 58 self.courses.__parent__ = self 57 59 self.courses.__name__ = 'courses' 58 self.certificates = createObject(u'waeup.CertificatesContainer')60 self.certificates = CertificatesContainer() 59 61 self.certificates.__parent__ = self 60 62 self.certificates.__name__ = 'certificates' … … 71 73 72 74 def longtitle(self): 75 insttypes_dict = getUtility(ISIRPUtils).getInstTypeDict() 73 76 return "%s %s (%s)" % ( 74 inst _types.getTerm(self.title_prefix).title,77 insttypes_dict[self.title_prefix], 75 78 self.title, self.code) 76 79 -
main/waeup.sirp/trunk/src/waeup/sirp/university/faculty.py
r7334 r7681 22 22 from zope.component.interfaces import IFactory 23 23 from zope.interface import implementedBy 24 from zope.component import getUtility 25 from waeup.sirp.interfaces import ISIRPUtils 24 26 from waeup.sirp.university.interfaces import ( 25 27 IFaculty, IFacultyAdd, IDepartment) 26 from waeup.sirp.university.vocabularies import inst_types27 28 28 29 class Faculty(grok.Container): … … 60 61 61 62 def longtitle(self): 62 try: 63 result = "%s %s (%s)" % ( 64 inst_types.getTerm( 65 self.title_prefix).title, 66 self.title, self.code) 67 except: 68 result = "%s (%s)" % (self.title, self.code) 63 insttypes_dict = getUtility(ISIRPUtils).getInstTypeDict() 64 result = "%s %s (%s)" % ( 65 insttypes_dict[self.title_prefix], 66 self.title, self.code) 69 67 return result 70 68 -
main/waeup.sirp/trunk/src/waeup/sirp/university/interfaces.py
r7670 r7681 26 26 from waeup.sirp.university.vocabularies import ( 27 27 course_levels, 28 semester,29 application_categories,30 study_modes,31 inst_types,32 28 CourseSource, 29 StudyModeSource, 30 AppCatSource, 31 InstTypeSource, 32 SemesterSource, 33 33 ) 34 34 … … 53 53 title = u'Name prefix', 54 54 default = u'faculty', 55 vocabulary = inst_types,55 source = InstTypeSource(), 56 56 required = True, 57 57 ) … … 100 100 title_prefix = schema.Choice( 101 101 title = u'Name prefix', 102 vocabulary = inst_types,102 source = InstTypeSource(), 103 103 default = u'department', 104 104 required = True, … … 166 166 title = u'Semester/Term', 167 167 default = 9, 168 vocabulary = semester,168 source = SemesterSource(), 169 169 required = True, 170 170 ) … … 206 206 study_mode = schema.Choice( 207 207 title = u'Study Mode', 208 vocabulary = study_modes,208 source = StudyModeSource(), 209 209 default = u'ug_ft', 210 210 required = True, … … 227 227 application_category = schema.Choice( 228 228 title = u'Application Category', 229 vocabulary = application_categories,229 source = AppCatSource(), 230 230 default = u'basic', 231 231 required = True, -
main/waeup.sirp/trunk/src/waeup/sirp/university/tests/test_faculty.py
r7195 r7681 22 22 import unittest 23 23 from zope.interface.verify import verifyObject, verifyClass 24 from waeup.sirp.university import Faculty 25 from waeup.sirp.university.interfaces import IFaculty 24 from waeup.sirp.university import Faculty, Department 25 from waeup.sirp.university.interfaces import IFaculty, IDepartment 26 26 27 class Faculty Tests(unittest.TestCase):27 class FacultyAndDepartmentTests(unittest.TestCase): 28 28 29 29 def test_ifaces(self): … … 32 32 verifyClass(IFaculty, Faculty) 33 33 verifyObject(IFaculty, fac) 34 dep = Department() 35 verifyClass(IDepartment, Department) 36 verifyObject(IDepartment, dep) 34 37 return 35 36 def test_longtitle(self):37 # Make sure we get a longtitle38 fac = Faculty()39 self.assertEqual(fac.longtitle(),40 u'Faculty of Unnamed Faculty (NA)')41 42 def test_longtitle_no_terms(self):43 # Make sure we get a longtitle also if no term for the title44 # prefix is available45 fac = Faculty()46 fac.title_prefix = 'Studio for' # Not a valid prefix47 self.assertEqual(fac.longtitle(),48 u'Unnamed Faculty (NA)') -
main/waeup.sirp/trunk/src/waeup/sirp/university/vocabularies.py
r7601 r7681 19 19 """ 20 20 from zc.sourcefactory.basic import BasicSourceFactory 21 from zc.sourcefactory.contextual import BasicContextualSourceFactory 21 22 from zope.catalog.interfaces import ICatalog 22 23 from zope.component import getUtility 23 from waeup.sirp.interfaces import SimpleSIRPVocabulary 24 from waeup.sirp.interfaces import SimpleSIRPVocabulary, ISIRPUtils 25 from waeup.sirp.interfaces import MessageFactory as _ 24 26 25 inst_types = SimpleSIRPVocabulary( 26 ('Faculty of','faculty'), 27 ('Department of','department'), 28 ('School of','school'), 29 ('School for','school_for'), 30 ('Institute of','institute'), 31 ('Office for','office'), 32 ('Centre for','centre'), 33 ('College','college'), 27 course_levels = SimpleSIRPVocabulary( 28 (_('Pre-Studies'),10), 29 (_('100 (Year 1)'),100), 30 (_('200 (Year 2)'),200), 31 (_('300 (Year 3)'),300), 32 (_('400 (Year 4)'),400), 33 (_('500 (Year 5)'),500), 34 (_('600 (Year 6)'),600), 35 (_('700 (Year 7)'),700), 36 (_('800 (Year 8)'),800), 34 37 ) 35 38 36 course_levels = SimpleSIRPVocabulary( 37 ('Pre-Studies', 10), 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 ) 39 class SemesterSource(BasicContextualSourceFactory): 40 """An institution type source delivers semester or term descriptors. 41 """ 42 def getValues(self, context): 43 self.semesters_dict = getUtility(ISIRPUtils).getSemesterDict() 44 return self.semesters_dict.keys() 47 45 48 semester = SimpleSIRPVocabulary( 49 ('N/A', 9), 50 ('First Semester', 1), 51 ('Second Semester', 2), 52 ('Combined', 3) 53 ) 46 def getToken(self, context, value): 47 return str(value) 54 48 55 application_categories = SimpleSIRPVocabulary( 56 ('PUME, PDE, PCE, PRENCE','basic'), 57 ('Part-Time, Diploma, Certificate','cest'), 58 ('Sandwich','sandwich'), 59 ('Postgraduate','pg'), 60 ('no application','no'), 61 ) 49 def getTitle(self, context, value): 50 return self.semesters_dict[value] 62 51 63 study_modes = SimpleSIRPVocabulary( 64 ('UME Full Time','ume_ft'), 65 ('Direct Entry Full Time','de_ft'), 66 ('Direct Entry Part Time','de_pt'), 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'), 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'), 81 ) 52 class InstTypeSource(BasicContextualSourceFactory): 53 """An institution type source delivers types of institutions 54 in the portal. 55 """ 56 def getValues(self, context): 57 self.insttypes_dict = getUtility(ISIRPUtils).getInstTypeDict() 58 return sorted(self.insttypes_dict.keys()) 59 60 def getToken(self, context, value): 61 return value 62 63 def getTitle(self, context, value): 64 return self.insttypes_dict[value] 65 66 class AppCatSource(BasicContextualSourceFactory): 67 """A application category source delivers all application categories 68 provided in the portal. 69 """ 70 def getValues(self, context): 71 self.appcats_dict = getUtility(ISIRPUtils).getAppCatDict() 72 return sorted(self.appcats_dict.keys()) 73 74 def getToken(self, context, value): 75 return value 76 77 def getTitle(self, context, value): 78 return self.appcats_dict[value] 79 80 class StudyModeSource(BasicContextualSourceFactory): 81 """A study modes source delivers all study modes provided 82 in the portal. 83 """ 84 def getValues(self, context): 85 self.studymodes_dict = getUtility(ISIRPUtils).getStudyModesDict() 86 return sorted(self.studymodes_dict.keys()) 87 88 def getToken(self, context, value): 89 return value 90 91 def getTitle(self, context, value): 92 return self.studymodes_dict[value] 82 93 83 94 class CourseSource(BasicSourceFactory):
Note: See TracChangeset for help on using the changeset viewer.