Changeset 6775 for main/waeup.sirp/trunk/src/waeup
- Timestamp:
- 15 Sep 2011, 08:59:59 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/students
- Files:
-
- 3 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py
r6774 r6775 25 25 WAeUPPage, WAeUPEditFormPage, WAeUPAddFormPage, WAeUPDisplayFormPage) 26 26 from waeup.sirp.browser.breadcrumbs import Breadcrumb 27 from waeup.sirp.browser.resources import datepicker, datatable 27 from waeup.sirp.browser.resources import datepicker, datatable, tabs 28 28 from waeup.sirp.browser.viewlets import ( 29 29 ManageActionButton, PrimaryNavTab, AddActionButton) … … 39 39 from waeup.sirp.students.workflow import CLEARANCE 40 40 from waeup.sirp.students.studylevel import StudentStudyLevel 41 from waeup.sirp.students.vocabularies import StudyLevelSource 41 42 42 43 # Save function used for save methods in manager pages … … 445 446 grok.require('waeup.viewStudent') 446 447 form_fields = grok.AutoFields(IStudentStudyCourse) 447 #grok.template('studycoursepage')448 grok.template('studycoursepage') 448 449 title = 'Study Course' 449 450 pnav = 4 … … 459 460 grok.require('waeup.manageStudents') 460 461 text = 'Manage' 461 target = ' edit'462 target = 'manage' 462 463 463 464 class StudyCourseManageFormPage(WAeUPEditFormPage): … … 465 466 """ 466 467 grok.context(IStudentStudyCourse) 467 grok.name('edit') 468 grok.require('waeup.manageStudents') 468 grok.name('manage') 469 grok.require('waeup.manageStudents') 470 grok.template('studycoursemanagepage') 469 471 form_fields = grok.AutoFields(IStudentStudyCourse) 470 472 title = 'Study Course' 471 473 label = 'Manage study course' 472 474 pnav = 4 475 taboneactions = ['Save','Cancel'] 476 tabtwoactions = ['Remove selected levels','Cancel'] 477 tabthreeactions = ['Add study level'] 478 479 def update(self): 480 super(StudyCourseManageFormPage, self).update() 481 tabs.need() 482 datatable.need() 483 return 473 484 474 485 @grok.action('Save') … … 477 488 return 478 489 479 @grok.action('Add level') 490 @property 491 def level_dict(self): 492 studylevelsource = StudyLevelSource().factory 493 for code in studylevelsource.getValues(self.context): 494 title = studylevelsource.getTitle(self.context, code) 495 yield(dict(code=code, title=title)) 496 497 @grok.action('Add study level') 480 498 def addStudyLevel(self, **data): 499 level_code = self.request.form.get('addlevel', None) 481 500 studylevel = StudentStudyLevel() 482 studylevel.level = str(self.context.current_level) 483 self.context.addStudentStudyLevel(studylevel) 484 return 485 486 class StudyCourseAddActionButton(AddActionButton): 487 grok.order(1) 488 grok.context(IStudentStudyCourse) 489 grok.view(StudyCourseManageFormPage) 490 grok.require('waeup.manageStudents') 491 text = 'Add study level' 492 target = '' 501 studylevel.level = int(level_code) 502 try: 503 self.context.addStudentStudyLevel(studylevel) 504 except KeyError: 505 self.flash('This level exists.') 506 self.redirect(self.url(self.context, u'@@manage')+'#tab-2') 507 return 508 509 @grok.action('Remove selected levels') 510 def delStudyLevels(self, **data): 511 form = self.request.form 512 if form.has_key('val_id'): 513 child_id = form['val_id'] 514 else: 515 self.flash('No study level selected.') 516 self.redirect(self.url(self.context, '@@manage')+'#tab-2') 517 return 518 if not isinstance(child_id, list): 519 child_id = [child_id] 520 deleted = [] 521 for id in child_id: 522 try: 523 del self.context[id] 524 deleted.append(id) 525 except: 526 self.flash('Could not delete %s: %s: %s' % ( 527 id, sys.exc_info()[0], sys.exc_info()[1])) 528 if len(deleted): 529 self.flash('Successfully removed: %s' % ', '.join(deleted)) 530 self.redirect(self.url(self.context, u'@@manage')+'#tab-2') 531 return 493 532 494 533 class StudyLevelDisplayFormPage(WAeUPDisplayFormPage): … … 498 537 grok.name('index') 499 538 grok.require('waeup.viewStudent') 500 form_fields = grok.AutoFields(IStudentStudy Course)539 form_fields = grok.AutoFields(IStudentStudyLevel) 501 540 #grok.template('studylevelpage') 502 541 title = 'Study Level' … … 505 544 @property 506 545 def label(self): 507 return '%s: Study Level ' % self.context.__parent__.name546 return '%s: Study Level %s' % (self.context.__parent__.name,self.context.level_title) 508 547 509 548 class PaymentsDisplayFormPage(WAeUPDisplayFormPage): -
main/waeup.sirp/trunk/src/waeup/sirp/students/interfaces.py
r6774 r6775 207 207 """ 208 208 level = Attribute('The level code') 209 level_title = Attribute('Title of level') 209 210 210 211 class IStudentAccommodation(IWAeUPObject): -
main/waeup.sirp/trunk/src/waeup/sirp/students/studycourse.py
r6774 r6775 44 44 raise TypeError( 45 45 'StudentStudyCourses contain only IStudentStudyLevel instances') 46 self[st udylevel.level] = studylevel46 self[str(studylevel.level)] = studylevel 47 47 return 48 48 -
main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py
r6771 r6775 174 174 175 175 # Registration numbers must be unique 176 self.browser.getLink("Manage").click()177 self.browser.getControl(name="form.reg_number").value = '123'178 self.browser.getControl("Save").click()179 self.assertMatches('...value already exists in catalog...',180 self.browser.contents)176 #self.browser.getLink("Manage").click() 177 #self.browser.getControl(name="form.reg_number").value = '123' 178 #self.browser.getControl("Save").click() 179 #self.assertMatches('...value already exists in catalog...', 180 # self.browser.contents) 181 181 182 182 self.browser.open(self.container_path)
Note: See TracChangeset for help on using the changeset viewer.