- Timestamp:
- 23 Aug 2015, 10:07:31 (9 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
r13177 r13215 1150 1150 return 1151 1151 if self.context.mode == 'create': 1152 # Add applicant 1153 applicant = createObject(u'waeup.Applicant') 1152 # Check if there are unused records which can be taken 1153 cat = getUtility(ICatalog, name='applicants_catalog') 1154 results = list( 1155 cat.searchResults(record_used=(False, False))) 1156 if results: 1157 applicant = results[0] 1158 else: 1159 # Add applicant 1160 applicant = createObject(u'waeup.Applicant') 1161 self.context.addApplicant(applicant) 1154 1162 self.applyData(applicant, **data) 1155 self.context.addApplicant(applicant)1156 1163 applicant.reg_number = applicant.applicant_id 1157 1164 notify(grok.ObjectModifiedEvent(applicant)) -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py
r13123 r13215 144 144 # reg_number is the only field which has to be preset here 145 145 # because managers are allowed to edit this required field 146 self.applicant.firstname = u'Joan' 146 147 self.applicant.reg_number = u'1234' 147 148 self.applicant.course1 = certificate … … 1199 1200 1200 1201 def test_register_applicant_create(self): 1202 self.assertEqual(len(self.app['applicants'][container_name_1]), 1) 1201 1203 # An applicant can register himself. 1202 1204 self.browser.open(self.container_path) … … 1212 1214 self.assertEqual(self.browser.url, 1213 1215 self.container_path + '/registration_complete?email=xx%40yy.zz') 1216 # A new applicant has been created 1217 self.assertEqual(len(self.app['applicants'][container_name_1]), 2) 1214 1218 # The new applicant can be found in the catalog via the email address 1215 1219 cat = getUtility(ICatalog, name='applicants_catalog') … … 1225 1229 reg_number=(applicant.reg_number, applicant.reg_number))) 1226 1230 self.assertEqual(applicant,results[0]) 1231 return 1232 1233 def test_register_applicant_take_unused_record(self): 1234 # Create an unused record 1235 uu_applicant = createObject('waeup.Applicant') 1236 self.app['applicants'][container_name_1].addApplicant(uu_applicant) 1237 self.assertFalse(uu_applicant.record_used) 1238 self.assertEqual(len(self.app['applicants'][container_name_1]), 2) 1239 self.browser.open(self.container_path) 1240 self.browser.getLink("Register for application").click() 1241 # Fill the edit form with suitable values 1242 self.browser.getControl(name="form.firstname").value = 'Anna' 1243 self.browser.getControl(name="form.lastname").value = 'Kurios' 1244 self.browser.getControl(name="form.email").value = 'xx@yy.zz' 1245 self.browser.getControl(name="form.phone.country").value = ['+234'] 1246 self.browser.getControl(name="form.phone.area").value = '555' 1247 self.browser.getControl(name="form.phone.ext").value = '6666666' 1248 self.browser.getControl("Send login credentials").click() 1249 # No applicant has been created ... 1250 self.assertEqual(len(self.app['applicants'][container_name_1]), 2) 1251 # ... and the existing, formerly unused record has been used instead 1252 self.assertEqual(uu_applicant.lastname, 'Kurios') 1253 self.assertTrue(uu_applicant.record_used) 1227 1254 return 1228 1255
Note: See TracChangeset for help on using the changeset viewer.