- Timestamp:
- 6 Jun 2012, 09:17:37 (12 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/applicants
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser.py
r8629 r8636 36 36 ) 37 37 from waeup.kofa.applicants.applicant import search 38 from waeup.kofa.applicants.workflow import INITIALIZED, STARTED, PAID, SUBMITTED 38 from waeup.kofa.applicants.workflow import ( 39 INITIALIZED, STARTED, PAID, SUBMITTED, ADMITTED) 39 40 from waeup.kofa.browser import ( 40 41 KofaPage, KofaEditFormPage, KofaAddFormPage, KofaDisplayFormPage, … … 545 546 546 547 class CreateStudentPage(UtilityView, grok.View): 547 """Create a student object from applicatnt data 548 and copy applicant object. 548 """Create a student object from applicant data. 549 549 """ 550 550 grok.context(IApplicant) … … 556 556 self.flash(msg) 557 557 self.redirect(self.url(self.context)) 558 return 559 560 def render(self): 561 return 562 563 class CreateAllStudentsPage(UtilityView, grok.View): 564 """Create all student objects from applicant data 565 in a container. 566 567 This is a hidden page, no link or button will 568 be provided and only PortalManagers can do this. 569 """ 570 grok.context(IApplicantsContainer) 571 grok.name('createallstudents') 572 grok.require('waeup.managePortal') 573 574 def update(self): 575 cat = getUtility(ICatalog, name='applicants_catalog') 576 results = list(cat.searchResults(state=(ADMITTED, ADMITTED))) 577 created = [] 578 for result in results: 579 if not self.context.has_key(result.application_number): 580 continue 581 success, msg = result.createStudent(view=self) 582 if success: 583 created.append(result.applicant_id) 584 else: 585 ob_class = self.__implemented__.__name__.replace('waeup.kofa.','') 586 self.context.__parent__.logger_info( 587 ob_class,result.applicant_id,msg) 588 if len(created): 589 self.flash(_('${a} students successfully created.', 590 mapping = {'a': len(created)})) 591 else: 592 self.flash(_('No student could be created.')) 593 self.redirect(self.url(self.context, u'@@manage')+'?tab2') 558 594 return 559 595 -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_applicantcopier.py
r8487 r8636 20 20 """ 21 21 import os 22 import grok 22 23 from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState 24 from zope.event import notify 23 25 from zope.component import getUtility 24 26 from zope.i18n import translate … … 35 37 return 36 38 37 def test_copier(self):39 def prepare_applicant(self): 38 40 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 39 41 self.browser.open(self.manage_path) … … 47 49 file_ctrl.add_file(file_obj, filename='my_photo.jpg') 48 50 self.browser.getControl("Save").click() # submit form 51 return 52 53 def test_copier(self): 54 self.prepare_applicant() 49 55 storage = getUtility(IExtFileStore) 50 56 file_id = IFileStoreNameChooser(self.applicant).chooseName() … … 100 106 101 107 def test_batch_copying(self): 102 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 103 self.browser.open(self.manage_path) 104 self.fill_correct_values() 105 self.browser.getControl("Save").click() 106 # Upload a passport picture 107 ctrl = self.browser.getControl(name='form.passport') 108 file_obj = open( 109 os.path.join(os.path.dirname(__file__), 'test_image.jpg'),'rb') 110 file_ctrl = ctrl.mech_control 111 file_ctrl.add_file(file_obj, filename='my_photo.jpg') 112 self.browser.getControl("Save").click() # submit form 108 self.prepare_applicant() 113 109 IWorkflowState(self.applicant).setState('admitted') 114 110 self.browser.getControl(name="form.course_admitted").value = ['CERT1'] … … 120 116 ctrl.getControl(value=self.applicant.application_number).selected = True 121 117 self.browser.getControl("Create students from selected", index=0).click() 118 self.assertTrue('1 students successfully created' in self.browser.contents) 119 120 def test_hidden_batch_copying(self): 121 logfile = os.path.join( 122 self.app['datacenter'].storage, 'logs', 'applicants.log') 123 self.prepare_applicant() 124 self.browser.open(self.container_path + '/createallstudents') 125 self.assertTrue('No student could be created' in self.browser.contents) 126 IWorkflowState(self.applicant).setState('admitted') 127 notify(grok.ObjectModifiedEvent(self.applicant)) 128 self.browser.open(self.container_path + '/createallstudents') 129 self.assertTrue('No student could be created' in self.browser.contents) 130 logcontent = open(logfile).read() 131 self.assertTrue('No course admitted provided' in logcontent) 132 self.browser.open(self.manage_path) 133 self.browser.getControl(name="form.course_admitted").value = ['CERT1'] 134 self.browser.getControl("Save").click() 135 # date_of_birth is not required for applicants but for students 136 self.applicant.date_of_birth = None 137 self.browser.open(self.container_path + '/createallstudents') 138 self.assertTrue('No student could be created' in self.browser.contents) 139 logcontent = open(logfile).read() 140 self.assertTrue('RequiredMissing: date_of_birth' in logcontent) 141 self.browser.open(self.manage_path) 142 self.browser.getControl(name="form.date_of_birth").value = '09/09/1988' 143 self.browser.getControl("Save").click() 144 self.browser.open(self.container_path + '/createallstudents') 122 145 self.assertTrue('1 students successfully created' in self.browser.contents) 123 146
Note: See TracChangeset for help on using the changeset viewer.