Changeset 14949 for main/waeup.kofa/trunk/src/waeup/kofa/applicants
- Timestamp:
- 9 Feb 2018, 09:17:58 (7 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/applicants
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser.py
r14948 r14949 29 29 from zope.catalog.interfaces import ICatalog 30 30 from zope.i18n import translate 31 from zope.security import checkPermission 31 32 from hurry.workflow.interfaces import ( 32 33 IWorkflowInfo, IWorkflowState, InvalidTransitionError) … … 430 431 @action(_('Create students from selected')) 431 432 def createStudents(self, **data): 433 if not checkPermission('waeup.createStudents', self.context): 434 self.flash( 435 _('You don\'t have permission to create student records.'), 436 type='warning') 437 self.redirect(self.url(self.context, '@@manage')+'#tab2') 438 return 432 439 form = self.request.form 433 440 if 'val_id' in form: … … 697 704 results = list(cat.searchResults(state=(ADMITTED, ADMITTED))) 698 705 created = [] 706 failed = [] 699 707 container_only = False 700 708 applicants_root = grok.getSite()['applicants'] … … 708 716 created.append(result.applicant_id) 709 717 else: 718 failed.append('%s (%s)' % (result.applicant_id, msg)) 710 719 ob_class = self.__implemented__.__name__.replace( 711 720 'waeup.kofa.','') … … 716 725 self.flash(_('${a} students successfully created.', 717 726 mapping = {'a': len(created)})) 718 else: 719 self.flash(_('No student could be created.'), type='warning') 727 if len(failed): 728 self.flash(_('Student creation failed: ${a}', 729 mapping = {'a':', '.join(failed)}), type='danger') 730 if not len(created) and not len(failed): 731 self.flash(_('No record found.'), type='warning') 720 732 self.redirect(self.url(self.context)) 721 733 return -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_applicantcopier.py
r14934 r14949 160 160 self.prepare_applicant() 161 161 self.browser.open(self.container_path + '/createallstudents') 162 self.assertTrue('No student could be created' in self.browser.contents)162 self.assertTrue('No record found' in self.browser.contents) 163 163 IWorkflowState(self.applicant).setState('admitted') 164 164 notify(grok.ObjectModifiedEvent(self.applicant)) 165 165 self.browser.open(self.container_path + '/createallstudents') 166 self.assertTrue('No student could be created' in self.browser.contents)166 self.assertTrue('No course admitted provided' in self.browser.contents) 167 167 logcontent = open(logfile).read() 168 168 self.assertTrue('No course admitted provided' in logcontent) … … 173 173 self.applicant.date_of_birth = None 174 174 self.browser.open(self.container_path + '/createallstudents') 175 self.assertTrue(' No student could be created' in self.browser.contents)175 self.assertTrue('RequiredMissing: date_of_birth' in self.browser.contents) 176 176 logcontent = open(logfile).read() 177 177 self.assertTrue('RequiredMissing: date_of_birth' in logcontent) … … 194 194 notify(grok.ObjectModifiedEvent(self.applicant)) 195 195 self.browser.open(self.root_path + '/createallstudents') 196 self.assertTrue('No student could be created' in self.browser.contents)196 self.assertTrue('No course admitted provided' in self.browser.contents) 197 197 logcontent = open(logfile).read() 198 198 self.assertTrue('No course admitted provided' in logcontent) … … 238 238 self.assertTrue('No student could be created.' in self.browser.contents) 239 239 self.browser.open(self.container_path + '/createallstudents') 240 self.assertTrue('No student could be created' in self.browser.contents) 241 logfile = os.path.join(self.app['datacenter'].storage, 'logs', 'applicants.log') 242 logcontent = open(logfile).read() 243 self.assertTrue('IOError: Application Slip could not be created.' in logcontent) 240 self.assertTrue( 241 'IOError: Application Slip could not be created.' 242 in self.browser.contents) 243 logfile = os.path.join( 244 self.app['datacenter'].storage, 'logs', 'applicants.log') 245 logcontent = open(logfile).read() 246 self.assertTrue( 247 'IOError: Application Slip could not be created.' in logcontent) 244 248 245 249 def disabled_test_delay(self): -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py
r14366 r14949 536 536 self.assertEqual(self.applicantscontainer.counts[1], 0) 537 537 return 538 539 def init_officer(self): 540 # Create application officer 541 self.app['users'].addUser('mrappl', 'mrapplsecret') 542 self.app['users']['mrappl'].email = 'mrappl@foo.ng' 543 self.app['users']['mrappl'].title = 'Carlo Pitter' 544 prmglobal = IPrincipalRoleManager(self.app) 545 prmglobal.assignRoleToPrincipal('waeup.ApplicationsManager', 'mrappl') 546 # Login as officer 547 self.browser.open(self.login_path) 548 self.browser.getControl(name="form.login").value = 'mrappl' 549 self.browser.getControl(name="form.password").value = 'mrapplsecret' 550 self.browser.getControl("Login").click() 551 552 def test_student_creation_permission(self): 553 self.init_officer() 554 self.browser.open(self.container_path + '/manage') 555 self.browser.getControl("Create students").click() 556 self.assertTrue('You don\'t have permission to create student records' 557 in self.browser.contents) 558 prmglobal = IPrincipalRoleManager(self.app) 559 prmglobal.assignRoleToPrincipal('waeup.StudentsCreator', 'mrappl') 560 self.browser.getControl("Create students").click() 561 self.assertTrue('No applicant selected' in self.browser.contents) 562 538 563 539 564 class ApplicantUITests(ApplicantsFullSetup):
Note: See TracChangeset for help on using the changeset viewer.