Changeset 5977
- Timestamp:
- 26 Apr 2011, 10:35:52 (14 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/browser/pages.py
r5951 r5977 1184 1184 if a['level'] > b['level']: 1185 1185 return 1 1186 if a['semester'] < b['semester']: 1187 return -1 1188 if a['semester'] > b['semester']: 1189 return 1 1186 1190 if a['mandatory'] != b['mandatory']: 1187 1191 if a['mandatory'] == False and b['mandatory'] == True: … … 1196 1200 entries = [] 1197 1201 levels = dict() 1198 for key, course in self.context.items(): 1199 certcourse = self.context[key] 1202 for key, certcourse in self.context.items(): 1200 1203 course = certcourse.course 1201 1204 level = certcourse.level 1202 1205 mandatory = certcourse.core_or_elective 1203 1206 title = course.title 1204 co de = course.code1205 course_url = self.url( self.context[key])1207 courseref_url = self.url(self.context[key]) 1208 course_url = self.url(course) 1206 1209 semester = course.semester 1207 1210 1208 1211 new_entry = dict( 1209 level=level, mandatory=mandatory, url=course_url, 1210 title=title, code=code, semester=semester) 1212 level=level, mandatory=mandatory, url=courseref_url, 1213 title=title, semester=semester, course=course, code=key, 1214 course_url=course_url) 1211 1215 if str(level) not in levels.keys(): 1212 1216 levels[str(level)] = dict() … … 1278 1282 @property 1279 1283 def title(self): 1280 return 'Course Refer ence: %s' % (self.context.course.code)1284 return 'Course Referrer: %s' % (self.context.__name__) 1281 1285 1282 1286 class CertificateCourseFormPage(WAeUPEditFormPage): … … 1291 1295 @property 1292 1296 def title(self): 1293 return 'Edit course refer ence'1297 return 'Edit course referrer' 1294 1298 1295 1299 @grok.action('Save and return') … … 1321 1325 form_fields = grok.AutoFields(ICertificateCourseAdd) 1322 1326 pnav = 1 1323 title = 'Add course refer ence'1324 1325 @grok.action('Add course refer ence')1327 title = 'Add course referrer' 1328 1329 @grok.action('Add course referrer') 1326 1330 def addCertcourse(self, **data): 1327 1331 try: 1328 1332 self.context.addCourseRef(**data) 1329 1333 except KeyError: 1330 self.status = Invalid('The chosen course refer enceis already part of'1334 self.status = Invalid('The chosen course referrer is already part of' 1331 1335 'this certificate') 1332 1336 return 1333 1337 except DuplicationError: 1334 self.status = Invalid('The chosen course refer enceis already part of'1338 self.status = Invalid('The chosen course referrer is already part of' 1335 1339 'this certificate') 1336 1340 return -
main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/certificatecoursepage.pt
r5950 r5977 1 <h2 tal:content="context/ course/code">TITLE</h2>1 <h2 tal:content="context/__name__">TITLE</h2> 2 2 3 3 <table class="listing"> … … 6 6 <tbody> 7 7 <tr class="odd"> 8 <td> ReferenceCode:</td>8 <td>Code:</td> 9 9 <td tal:content="context/__name__">CODE</td> 10 10 </tr> -
main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/certificatepage.pt
r5946 r5977 1 1 <h2 tal:content="context/title">TITLE</h2> 2 2 3 <table class=" listing">3 <table class="zebra"> 4 4 <thead> 5 5 </thead> 6 6 <tbody> 7 <tr class="odd">7 <tr> 8 8 <td>Code:</td> 9 9 <td tal:content="context/__name__">CODE</td> 10 10 </tr> 11 <tr class="even">11 <tr> 12 12 <td>Title:</td> 13 13 <td tal:content="context/title">THE TITLE</td> 14 14 </tr> 15 <tr class="odd">15 <tr> 16 16 <td>Start Level:</td> 17 17 <td tal:content="context/start_level">START_LEVEL</td> 18 18 </tr> 19 <tr class="even">19 <tr> 20 20 <td>End Level:</td> 21 21 <td tal:content="context/end_level">END_LEVEL</td> 22 22 </tr> 23 <tr class="odd">23 <tr> 24 24 <td>Study Mode:</td> 25 25 <td tal:content="context/study_mode">STUDY_MODE</td> 26 26 </tr> 27 <tr class="even">27 <tr> 28 28 <td>Application Category:</td> 29 29 <td tal:content="context/application_category">APPLICATION_CATEGORY</td> … … 32 32 </table> 33 33 34 <h3> Courses</h3>34 <h3><span tal:content="context/__name__">Code</span> Course Referrers</h3> 35 35 36 <table class="zebra"> 37 <thead> 38 <tr> 39 <th>Course Referrer</th> 40 <th>Course</th> 41 <th>Title</th> 42 <th>Level</th> 43 <th>Semester</th> 44 <th>Mandatory</th> 45 <th> </th> 46 </tr> 47 </thead> 48 <tbody> 49 <span tal:omit-tag="" tal:repeat="level python: sorted(view.getCourseList().items())"> 50 <span tal:omit-tag="" tal:repeat="semester python: sorted(level[1].items())"> 51 <tr tal:repeat="courseref python:semester[1]"> 52 <td> <a href="" tal:attributes="href courseref/url" tal:content="courseref/code">courseref code</a></td> 53 <td> <a href="" tal:attributes="href courseref/course_url" tal:content="courseref/course/code">course code</a></td> 54 <td tal:content="courseref/title">title</td> 55 <td tal:content="python:level[0]">level</td> 56 <td tal:content="python:semester[0]">semester</td> 57 <td tal:content="courseref/mandatory">mandatory</td> 58 <td> 59 <form method="POST"> 60 <input type="hidden" name="code" 61 value="" tal:attributes="value courseref/course/code" /> 62 <input type="hidden" name="level" 63 value="" tal:attributes="value python:level[0]" /> 64 <input type="submit" name="delcourse" value="delete" /> 65 </form> 66 </td> 67 </tr> 68 </span> 69 </span> 70 </tbody> 71 </table> 36 72 37 <div tal:repeat="level python: sorted(view.getCourseList().items())">38 <b>39 Level <span tal:replace="python: level[0]">100</span>40 </b>41 42 <div tal:repeat="semester python: sorted(level[1].items())">43 <div tal:condition="python: semester[0] == '0'">44 Untimed courses45 </div>46 <div tal:condition="python: semester[0] == '1'">47 First semester48 </div>49 <div tal:condition="python: semester[0] == '2'">50 Second semester51 </div>52 <div tal:condition="python: semester[0] == '3'">53 Combined54 </div>55 56 <div tal:repeat="course python:semester[1]">57 58 <form method="POST">59 <input type="hidden" name="code"60 value="" tal:attributes="value course/code" />61 <input type="hidden" name="level"62 value="" tal:attributes="value python:level[0]" />63 <input type="submit" name="delcourse" value="delete" />64 65 <a href=""66 tal:attributes="href course/url"67 ><span tal:content="course/code">code</span>68 </a>69 <span tal:content="course/title">title</span>70 <span tal:condition="course/mandatory">71 [mandatory]72 </span>73 <span tal:condition="not: course/mandatory">74 [optional]75 </span>76 </form>77 </div>78 </div>79 80 </div>81 82 -
main/waeup.sirp/trunk/src/waeup/sirp/browser/viewlets.py
r5950 r5977 344 344 grok.context(ICertificateCourse) 345 345 grok.view(CertificateCoursePage) 346 text = 'Edit course refer ence'346 text = 'Edit course referrer' 347 347 348 348 # … … 384 384 grok.view(CertificatePage) 385 385 grok.order(4) 386 text = 'Add course refer ence'386 text = 'Add course referrer' 387 387 target = 'addcertificatecourse' 388 388 -
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.