Changeset 5977 for main/waeup.sirp/trunk/src/waeup/sirp/university
- Timestamp:
- 26 Apr 2011, 10:35:52 (14 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/university
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/university/certificate.py
r5953 r5977 58 58 59 59 def addCourseRef(self, course, level=100, core_or_elective=True): 60 """Add a course refer ence.60 """Add a course referrer. 61 61 """ 62 62 code = "%s_%s" % (course.code, level) … … 67 67 68 68 def delCourseRef(self, code, level=None): 69 """Delete a course refer encedenoted by its code.69 """Delete a course referrer denoted by its code. 70 70 """ 71 71 for key in self.keys(): … … 122 122 @grok.subscribe(ICourse, grok.IObjectRemovedEvent) 123 123 def removedCourseHandler(course, event): 124 """If a course is deleted, we make sure that also refer ences in a124 """If a course is deleted, we make sure that also referrers in a 125 125 certificatecontainer are removed. 126 126 """ 127 127 code = course.code 128 128 129 # Find all cert courses that reference thegiven course...129 # Find all certificatecourses that refer to given course... 130 130 try: 131 131 cat = getUtility(ICatalog, name='certcourses_catalog') … … 136 136 results = cat.searchResults(course_code=(code, code)) 137 137 for certcourse in results: 138 # Remove that refer ence...138 # Remove that referrer... 139 139 cert = certcourse.__parent__ 140 140 cert.delCourseRef(code) -
main/waeup.sirp/trunk/src/waeup/sirp/university/interfaces.py
r5951 r5977 1 1 """Interfaces of academics specific objects. 2 2 """ 3 from zc.sourcefactory.basic import BasicSourceFactory4 3 from zope import schema 5 try:6 from zope.catalog.interfaces import ICatalog7 except ImportError:8 # BBB9 from zope.app.catalog.interfaces import ICatalog10 from zope.component import getUtility11 4 from zope.interface import Attribute 12 from waeup.sirp.interfaces import (IWAeUPObject, IWAeUPContainer, 13 SimpleWAeUPVocabulary) 14 15 class CourseSource(BasicSourceFactory): 16 """A course source delivers all courses inside the portal by looking 17 up a catalog. 18 """ 19 def getValues(self): 20 catalog = getUtility(ICatalog, name='courses_catalog') 21 return list(catalog.searchResults(code=('', 'z*'))) 22 23 def getToken(self, value): 24 return value.code 25 26 def getTitle(self, value): 27 return "%s - %s" % (value.code, value.title[:64]) 5 from waeup.sirp.interfaces import (IWAeUPObject, IWAeUPContainer) 6 7 from waeup.sirp.university.vocabularies import (course_levels, 8 semester, CourseSource) 28 9 29 10 class IFaculty(IWAeUPContainer): … … 151 132 title = u'Semester/Term', 152 133 default = 0, 153 vocabulary = SimpleWAeUPVocabulary( 154 ('N/A', 0), ('First Semester', 1), 155 ('Second Semester', 2), ('Combined', 3)), 134 vocabulary = semester, 156 135 required = True, 157 136 ) … … 199 178 ) 200 179 201 start_level = schema. TextLine(180 start_level = schema.Choice( 202 181 title = u'Start Level', 203 default = u'100', 204 required = True, 205 ) 206 207 end_level = schema.TextLine( 182 #source = LevelSource(), 183 vocabulary = course_levels, 184 default = 100, 185 required = True, 186 ) 187 188 end_level = schema.Choice( 208 189 title = u'End Level', 209 default = u'500', 190 #source = LevelSource(), 191 vocabulary = course_levels, 192 default = 500, 210 193 required = True, 211 194 ) … … 240 223 241 224 class ICertificateCourse(IWAeUPObject): 242 """A certificatecourse is a course referenced by a certificate, which225 """A certificatecourse is referring a course and 243 226 provides some own attributes. 244 227 """ 245 228 course = schema.Choice( 246 title = u'Course refer enced',229 title = u'Course referrer', 247 230 source = CourseSource(), 248 231 readonly = True, 249 232 ) 250 233 251 level = schema. Int(234 level = schema.Choice( 252 235 title = u'Level', 253 236 required = True, 254 default = 100, 237 #source = LevelSource(), 238 vocabulary = course_levels, 255 239 readonly = False, 256 240 ) … … 263 247 264 248 def getCourseCode(): 265 """Return the code of the referenced course.249 """Return the code of the course referred to. 266 250 267 251 This is needed for cataloging. … … 270 254 271 255 class ICertificateCourseAdd(ICertificateCourse): 272 """A certificatecourse is a course referenced by a certificate, which256 """A certificatecourse is referring a course and 273 257 provides some own attributes. 274 258 """ 275 259 course = schema.Choice( 276 title = u'Course to be referenced',260 title = u'Course', 277 261 source = CourseSource(), 278 262 readonly = False,
Note: See TracChangeset for help on using the changeset viewer.