Changeset 9210 for main/waeup.uniben/trunk/src/waeup/uniben/students
- Timestamp:
- 21 Sep 2012, 06:10:00 (12 years ago)
- Location:
- main/waeup.uniben/trunk/src/waeup/uniben/students
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.uniben/trunk/src/waeup/uniben/students/browser.py
r9205 r9210 18 18 import grok 19 19 from zope.i18n import translate 20 from zope.schema.interfaces import ConstraintNotSatisfied 21 from waeup.kofa.interfaces import REQUESTED 20 22 from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget 23 from waeup.kofa.browser import KofaEditFormPage 24 from waeup.kofa.browser.viewlets import ManageActionButton 25 from waeup.kofa.browser.layout import action 21 26 from waeup.kofa.students.browser import ( 22 StudentClearPage, StudentRejectClearancePage) 27 StudentClearPage, StudentRejectClearancePage, 28 StudyCourseDisplayFormPage, msave, emit_lock_message) 23 29 from kofacustom.nigeria.students.browser import ( 24 30 NigeriaOnlinePaymentDisplayFormPage, … … 26 32 NigeriaExportPDFPaymentSlipPage) 27 33 28 from waeup.uniben.students.interfaces import ICustomStudentOnlinePayment 34 from waeup.uniben.students.interfaces import ( 35 ICustomStudentOnlinePayment, ICustomStudentStudyCourse) 36 from waeup.uniben.interfaces import MessageFactory as _ 29 37 30 38 class CustomOnlinePaymentDisplayFormPage(NigeriaOnlinePaymentDisplayFormPage): … … 70 78 # self.redirect(self.url(self.context,'view_clearance')) 71 79 # return 80 81 class StudyCourseEditActionButton(ManageActionButton): 82 grok.order(1) 83 grok.context(ICustomStudentStudyCourse) 84 grok.view(StudyCourseDisplayFormPage) 85 grok.require('waeup.clearStudent') 86 text = _('Edit level') 87 target = 'edit_level' 88 89 @property 90 def target_url(self): 91 if self.context.is_current and self.context.student.state == REQUESTED: 92 return self.view.url(self.view.context, self.target) 93 return False 94 95 class StudyCourseCOEditFormPage(KofaEditFormPage): 96 """ Page to edit the student study course data by clearance officers 97 98 This form page is available only in Uniben. 99 """ 100 grok.context(ICustomStudentStudyCourse) 101 grok.name('edit_level') 102 grok.require('waeup.clearStudent') 103 label = _('Edit current level') 104 pnav = 4 105 form_fields = grok.AutoFields( 106 ICustomStudentStudyCourse).select('current_level') 107 108 def update(self): 109 if not (self.context.is_current and 110 self.context.student.state == REQUESTED): 111 emit_lock_message(self) 112 return 113 super(StudyCourseCOEditFormPage, self).update() 114 return 115 116 @action(_('Save'), style='primary') 117 def save(self, **data): 118 try: 119 msave(self, **data) 120 except ConstraintNotSatisfied: 121 # The selected level might not exist in certificate 122 self.flash(_('Current level not available for certificate.')) 123 return 124 #notify(grok.ObjectModifiedEvent(self.context.__parent__)) 125 return -
main/waeup.uniben/trunk/src/waeup/uniben/students/tests/test_browser.py
r9206 r9210 20 20 import tempfile 21 21 from StringIO import StringIO 22 from hurry.workflow.interfaces import IWorkflowState 22 from hurry.workflow.interfaces import IWorkflowState, IWorkflowInfo 23 from zope.securitypolicy.interfaces import IPrincipalRoleManager 23 24 from zope.component.hooks import setSite, clearSite 24 25 from zope.component import getUtility, createObject 25 26 from zope.interface import verify 27 from zope.event import notify 28 from waeup.kofa.authentication import LocalRoleSetEvent 26 29 from waeup.kofa.app import University 27 30 from waeup.kofa.students.tests.test_browser import StudentsFullSetup … … 372 375 self.assertEqual(error, None) 373 376 return 377 378 def test_edit_level_by_co(self): 379 # Create clearance officer 380 self.app['users'].addUser('mrclear', 'mrclearsecret') 381 self.app['users']['mrclear'].email = 'mrclear@foo.ng' 382 self.app['users']['mrclear'].title = 'Carlo Pitter' 383 # Assign local ClearanceOfficer role 384 department = self.app['faculties']['fac1']['dep1'] 385 prmlocal = IPrincipalRoleManager(department) 386 prmlocal.assignRoleToPrincipal('waeup.local.ClearanceOfficer', 'mrclear') 387 notify(LocalRoleSetEvent( 388 department, 'waeup.local.ClearanceOfficer', 'mrclear', granted=True)) 389 IWorkflowState(self.student).setState('clearance started') 390 # Login as clearance officer 391 self.browser.open(self.login_path) 392 self.browser.getControl(name="form.login").value = 'mrclear' 393 self.browser.getControl(name="form.password").value = 'mrclearsecret' 394 self.browser.getControl("Login").click() 395 self.assertMatches('...You logged in...', self.browser.contents) 396 # Only in state clearance requested the CO does see the 397 # 'Edit level' button ... 398 self.browser.open(self.studycourse_path) 399 self.assertFalse('Edit level' in self.browser.contents) 400 # ... and can open the edit_level view 401 self.browser.open(self.studycourse_path + '/edit_level') 402 self.assertMatches('...is locked...', self.browser.contents) 403 self.assertEqual(self.browser.url, self.studycourse_path) 404 IWorkflowInfo(self.student).fireTransition('request_clearance') 405 self.browser.open(self.studycourse_path) 406 self.assertTrue('Edit level' in self.browser.contents) 407 self.browser.getLink("Edit level").click() 408 self.browser.getControl(name="form.current_level").value = ['200'] 409 self.browser.getControl("Save").click() 410 self.assertMatches('...has been saved...', self.browser.contents) 411 self.assertEqual(self.student.current_level, 200)
Note: See TracChangeset for help on using the changeset viewer.