Changeset 7158 for main/waeup.sirp/trunk/src
- Timestamp:
- 21 Nov 2011, 09:17:23 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/students
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py
r7150 r7158 49 49 from waeup.sirp.students.catalog import search 50 50 from waeup.sirp.students.workflow import ( 51 CLEARANCE, RE TURNING, CLEARED, REGISTERED, VALIDATED)51 CLEARANCE, REQUESTED, RETURNING, CLEARED, REGISTERED, VALIDATED) 52 52 from waeup.sirp.students.studylevel import StudentStudyLevel, CourseTicket 53 53 from waeup.sirp.students.vocabularies import StudyLevelSource … … 454 454 target = 'edit_clearance' 455 455 456 class StudentClearActionButton(ManageActionButton): 457 grok.order(2) 458 grok.context(IStudent) 459 grok.view(StudentClearanceDisplayFormPage) 460 grok.require('waeup.clearStudent') 461 text = 'Clear student' 462 target = 'clear' 463 464 @property 465 def target_url(self): 466 if self.context.state != REQUESTED: 467 return '' 468 return self.view.url(self.view.context, self.target) 469 470 class StudentRejectClearanceActionButton(ManageActionButton): 471 grok.order(2) 472 grok.context(IStudent) 473 grok.view(StudentClearanceDisplayFormPage) 474 grok.require('waeup.clearStudent') 475 text = 'Reject clearance' 476 target = 'reject_clearance' 477 478 @property 479 def target_url(self): 480 if self.context.state not in (REQUESTED, CLEARED): 481 return '' 482 return self.view.url(self.view.context, self.target) 483 456 484 class StudentClearanceManageFormPage(WAeUPEditFormPage): 457 485 """ Page to edit student clearance data … … 475 503 def save(self, **data): 476 504 msave(self, **data) 505 return 506 507 class StudentClearPage(grok.View): 508 """ Clear student by clearance officer 509 """ 510 grok.context(IStudent) 511 grok.name('clear') 512 grok.require('waeup.clearStudent') 513 514 def update(self): 515 if self.context.state == REQUESTED: 516 IWorkflowInfo(self.context).fireTransition('clear') 517 self.flash('Student has been cleared.') 518 else: 519 self.flash('Student is in the wrong state.') 520 self.redirect(self.url(self.context,'view_clearance')) 521 return 522 523 def render(self): 524 self.redirect(self.url(self.context, 'view_clearance')) 525 return 526 527 class StudentRejectClearancePage(grok.View): 528 """ Reject clearance by clearance officers 529 """ 530 grok.context(IStudent) 531 grok.name('reject_clearance') 532 grok.require('waeup.clearStudent') 533 534 def update(self): 535 if self.context.state == CLEARED: 536 IWorkflowInfo(self.context).fireTransition('reset4') 537 self.flash('Clearance has been annulled.') 538 elif self.context.state == REQUESTED: 539 IWorkflowInfo(self.context).fireTransition('reset3') 540 self.flash('Clearance request has been rejected.') 541 else: 542 self.flash('Student is in the wrong state.') 543 self.redirect(self.url(self.context,'view_clearance')) 544 return 545 546 def render(self): 547 self.redirect(self.url(self.context, 'view_clearance')) 477 548 return 478 549 -
main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py
r7147 r7158 32 32 from zope.component.hooks import setSite, clearSite 33 33 from zope.security.interfaces import Unauthorized 34 from zope.securitypolicy.interfaces import IPrincipalRoleManager 34 35 from zope.testbrowser.testing import Browser 35 36 from hurry.workflow.interfaces import IWorkflowInfo … … 642 643 in self.browser.contents) 643 644 return 645 646 def test_handle_clearance_by_co(self): 647 # Create clearance officer 648 self.app['users'].addUser('mrclear', 'mrclearsecret') 649 prmglobal = IPrincipalRoleManager(self.app) 650 prmglobal.assignRoleToPrincipal('waeup.StudentsOfficer', 'mrclear') 651 prmlocal = IPrincipalRoleManager(self.app['faculties']['fac1']['dep1']) 652 prmlocal.assignRoleToPrincipal('waeup.local.ClearanceOfficer', 'mrclear') 653 IWorkflowInfo(self.student).fireTransition('admit') 654 IWorkflowInfo(self.student).fireTransition('start_clearance') 655 # Login as clearance officer 656 self.browser.open(self.login_path) 657 self.browser.getControl(name="form.login").value = 'mrclear' 658 self.browser.getControl(name="form.password").value = 'mrclearsecret' 659 self.browser.getControl("Login").click() 660 self.assertTrue('You logged in' in self.browser.contents) 661 self.browser.open(self.clearance_student_path) 662 self.assertEqual(self.browser.headers['Status'], '200 Ok') 663 self.assertEqual(self.browser.url, self.clearance_student_path) 664 # Only in state clearance requested the co does see the 'Clear' button 665 self.assertFalse('Clear student' in self.browser.contents) 666 IWorkflowInfo(self.student).fireTransition('request_clearance') 667 self.browser.open(self.clearance_student_path) 668 self.assertTrue('Clear student' in self.browser.contents) 669 self.browser.getLink("Clear student").click() 670 self.assertTrue('Student has been cleared' in self.browser.contents) 671 self.assertTrue('State: <span>cleared</span>' in self.browser.contents) 672 self.browser.getLink("Reject clearance").click() 673 self.assertTrue('Clearance has been annulled' in self.browser.contents) 674 self.assertTrue('State: <span>clearance started</span>' 675 in self.browser.contents) 676 IWorkflowInfo(self.student).fireTransition('request_clearance') 677 self.browser.open(self.clearance_student_path) 678 self.browser.getLink("Reject clearance").click() 679 self.assertTrue('Clearance request has been rejected' 680 in self.browser.contents) 681 self.assertTrue('State: <span>clearance started</span>' 682 in self.browser.contents) 683 # The clearance officer can't clear students if not in state 684 # clearance requested 685 self.browser.open(self.student_path + '/clear') 686 self.assertTrue('Student is in the wrong state' 687 in self.browser.contents) 644 688 645 689 def test_student_change_password(self):
Note: See TracChangeset for help on using the changeset viewer.