Changeset 9273 for main/waeup.kofa/trunk
- Timestamp:
- 2 Oct 2012, 16:50:57 (12 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/permissions.py
r9262 r9273 215 215 'waeup.clearStudent', 'waeup.payStudent', 216 216 'waeup.uploadStudentFile', 'waeup.showStudents', 217 'waeup.triggerTransition', 217 218 'waeup.viewStudentsContainer','waeup.viewStudentsTab', 218 219 'waeup.handleAccommodation', … … 240 241 'waeup.clearStudent', 'waeup.payStudent', 241 242 'waeup.uploadStudentFile', 'waeup.showStudents', 243 #'waeup.triggerTransition', 242 244 'waeup.viewStudentsContainer','waeup.viewStudentsTab', 243 245 'waeup.handleAccommodation', -
main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
r9257 r9273 407 407 return 408 408 409 def getTransitions(self):410 """Return a list of dicts of allowed transition ids and titles.411 412 Each list entry provides keys ``name`` and ``title`` for413 internal name and (human readable) title of a single414 transition.415 """416 allowed_transitions = [t for t in self.wf_info.getManualTransitions()417 if not t[0].startswith('pay')]418 if self.context.is_postgrad:419 allowed_transitions = [t for t in allowed_transitions420 if not t[0] in FORBIDDEN_POSTGRAD_TRANS]421 return [dict(name='', title=_('No transition'))] +[422 dict(name=x, title=y) for x, y in allowed_transitions]423 424 409 @action(_('Save'), style='primary') 425 410 def save(self, **data): … … 440 425 changed_fields = [] 441 426 if password: 442 # Now we know that the form has no errors and can set password ...427 # Now we know that the form has no errors and can set password 443 428 IUserAccount(self.context).setPassword(password) 444 429 changed_fields.append('password') 445 # ... and execute transition446 if form.has_key('transition') and form['transition']:447 transition_id = form['transition']448 self.wf_info.fireTransition(transition_id)449 430 fields_string = ' + '.join(changed_fields) 450 431 self.flash(_('Form has been saved.')) 451 432 if fields_string: 452 433 self.context.writeLogMessage(self, 'saved: % s' % fields_string) 434 return 435 436 class StudentTriggerTransitionFormPage(KofaEditFormPage): 437 """ View to manage student base data 438 """ 439 grok.context(IStudent) 440 grok.name('trigtrans') 441 grok.require('waeup.triggerTransition') 442 grok.template('trigtrans') 443 label = _('Trigger registration transition') 444 pnav = 4 445 446 def getTransitions(self): 447 """Return a list of dicts of allowed transition ids and titles. 448 449 Each list entry provides keys ``name`` and ``title`` for 450 internal name and (human readable) title of a single 451 transition. 452 """ 453 wf_info = IWorkflowInfo(self.context) 454 allowed_transitions = [t for t in wf_info.getManualTransitions() 455 if not t[0].startswith('pay')] 456 if self.context.is_postgrad: 457 allowed_transitions = [t for t in allowed_transitions 458 if not t[0] in FORBIDDEN_POSTGRAD_TRANS] 459 return [dict(name='', title=_('No transition'))] +[ 460 dict(name=x, title=y) for x, y in allowed_transitions] 461 462 @action(_('Save'), style='primary') 463 def save(self, **data): 464 form = self.request.form 465 if form.has_key('transition') and form['transition']: 466 transition_id = form['transition'] 467 wf_info = IWorkflowInfo(self.context) 468 wf_info.fireTransition(transition_id) 453 469 return 454 470 -
main/waeup.kofa/trunk/src/waeup/kofa/students/browser_templates/basemanagepage.pt
r8486 r9273 27 27 </td> 28 28 </tr> 29 <tr>30 <td class="fieldname" i18n:translate="">Registration Transition:</td>31 <td>32 <select id="transition" name="transition">33 <option tal:repeat="transition view/getTransitions"34 tal:attributes="value transition/name">35 <span tal:replace="transition/title">TRANSITIONTITLE</span>36 </option>37 </select>38 </td>39 </tr>40 29 41 30 </tbody> -
main/waeup.kofa/trunk/src/waeup/kofa/students/permissions.py
r8367 r9273 56 56 grok.name('waeup.validateStudent') 57 57 58 class TriggerTransition(grok.Permission): 59 grok.name('waeup.triggerTransition') 60 58 61 # Local role 59 62 class StudentRecordOwner(grok.Role): -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
r9257 r9273 113 113 self.student_path = self.container_path + '/' + self.student_id 114 114 self.manage_student_path = self.student_path + '/manage_base' 115 self.trigtrans_path = self.student_path + '/trigtrans' 115 116 self.clearance_path = self.student_path + '/view_clearance' 116 117 self.personal_path = self.student_path + '/view_personal' … … 435 436 self.assertEqual(self.browser.headers['Status'], '200 Ok') 436 437 self.assertEqual(self.browser.url, self.student_path) 438 self.browser.getLink("Trigger").click() 439 self.assertEqual(self.browser.headers['Status'], '200 Ok') 440 # Managers can trigger transitions 441 self.browser.getControl(name="transition").value = ['admit'] 442 self.browser.getControl("Save").click() 443 # Managers can edit base 444 self.browser.open(self.student_path) 437 445 self.browser.getLink("Manage").click() 438 self.assertEqual(self.browser.headers['Status'], '200 Ok')439 446 self.assertEqual(self.browser.url, self.manage_student_path) 440 # Managers can edit base data and fire transitions 441 self.browser.getControl(name="transition").value = ['admit'] 447 self.assertEqual(self.browser.headers['Status'], '200 Ok') 442 448 self.browser.getControl(name="form.firstname").value = 'John' 443 449 self.browser.getControl(name="form.lastname").value = 'Tester' … … 720 726 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 721 727 student = self.app['students'][self.student_id] 722 self.browser.open(self. manage_student_path)728 self.browser.open(self.trigtrans_path) 723 729 self.assertTrue(student.clearance_locked) 724 730 self.browser.getControl(name="transition").value = ['admit'] … … 761 767 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 762 768 student = self.app['students'][self.student_id] 763 self.browser.open(self. manage_student_path)769 self.browser.open(self.trigtrans_path) 764 770 self.assertTrue('<option value="reset6">' in self.browser.contents) 765 771 self.assertTrue('<option value="register_courses">' in self.browser.contents) 766 772 self.assertTrue('<option value="reset5">' in self.browser.contents) 767 773 self.certificate.study_mode = 'pg_ft' 768 self.browser.open(self. manage_student_path)774 self.browser.open(self.trigtrans_path) 769 775 self.assertFalse('<option value="reset6">' in self.browser.contents) 770 776 self.assertFalse('<option value="register_courses">' in self.browser.contents) -
main/waeup.kofa/trunk/src/waeup/kofa/students/viewlets.py
r9257 r9273 166 166 target = 'manage_base' 167 167 168 class StudentTrigTransActionButton(ManageActionButton): 169 grok.order(2) 170 grok.context(IStudent) 171 grok.view(StudentBaseDisplayFormPage) 172 grok.require('waeup.triggerTransition') 173 icon = 'actionicon_trigtrans.png' 174 text = _(u'Trigger transition') 175 target = 'trigtrans' 176 168 177 class AdmissionSlipActionButton(ManageActionButton): 169 178 grok.order(4)
Note: See TracChangeset for help on using the changeset viewer.