Changeset 13254 for main/waeup.kofa/trunk/src/waeup/kofa
- Timestamp:
- 9 Sep 2015, 13:06:31 (9 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/applicants
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser.py
r13249 r13254 39 39 from waeup.kofa.applicants.applicant import search 40 40 from waeup.kofa.applicants.workflow import ( 41 INITIALIZED, STARTED, PAID, SUBMITTED, ADMITTED )41 INITIALIZED, STARTED, PAID, SUBMITTED, ADMITTED, NOT_ADMITTED, CREATED) 42 42 from waeup.kofa.browser import ( 43 43 # KofaPage, KofaEditFormPage, KofaAddFormPage, KofaDisplayFormPage, … … 1300 1300 return 1301 1301 1302 class ApplicantCheckStatusPage(KofaPage): 1303 """Captcha'd status checking page for applicants. 1304 """ 1305 grok.context(IApplicantsRoot) 1306 grok.name('checkstatus') 1307 grok.require('waeup.Anonymous') 1308 grok.template('applicantcheckstatus') 1309 buttonname = _('Submit') 1310 1311 def label(self): 1312 if self.result: 1313 return _('Application status of ${a}', 1314 mapping = {'a':self.applicant.applicant_id}) 1315 return _('Check your application status') 1316 1317 def update(self, SUBMIT=None): 1318 form = self.request.form 1319 self.result = False 1320 # Handle captcha 1321 self.captcha = getUtility(ICaptchaManager).getCaptcha() 1322 self.captcha_result = self.captcha.verify(self.request) 1323 self.captcha_code = self.captcha.display(self.captcha_result.error_code) 1324 if SUBMIT: 1325 if not self.captcha_result.is_valid: 1326 # Captcha will display error messages automatically. 1327 # No need to flash something. 1328 return 1329 applicant_id = form.get('applicant_id', None) 1330 lastname = form.get('lastname', None) 1331 if not applicant_id or not lastname: 1332 self.flash( 1333 _('Required input missing.'), type='warning') 1334 return 1335 cat = getUtility(ICatalog, name='applicants_catalog') 1336 results = list( 1337 cat.searchResults(applicant_id=(applicant_id, applicant_id))) 1338 if results: 1339 applicant = results[0] 1340 if applicant.lastname.lower() != lastname.lower(): 1341 # Don't tell the truth here. Anonymous must not 1342 # know that a record was found and only the lastname 1343 # verification failed. 1344 self.flash( 1345 _('No application record found.'), type='warning') 1346 return 1347 else: 1348 self.flash(_('No application record found.'), type='warning') 1349 return 1350 self.applicant = applicant 1351 self.entry_session = "%s/%s" % ( 1352 applicant.__parent__.year, 1353 applicant.__parent__.year+1) 1354 course_admitted = getattr(applicant, 'course_admitted', None) 1355 self.course_admitted = False 1356 if course_admitted is not None: 1357 self.course_admitted = True 1358 self.longtitle = course_admitted.longtitle 1359 self.department = course_admitted.__parent__.__parent__.longtitle 1360 self.faculty = course_admitted.__parent__.__parent__.__parent__.longtitle 1361 self.result = True 1362 self.admitted = False 1363 self.not_admitted = False 1364 self.submitted = False 1365 self.not_submitted = False 1366 if applicant.state in (ADMITTED, CREATED): 1367 self.admitted = True 1368 if applicant.state in (NOT_ADMITTED,): 1369 self.not_admitted = True 1370 if applicant.state in (SUBMITTED,): 1371 self.submitted = True 1372 if applicant.state in (INITIALIZED, STARTED, PAID): 1373 self.not_submitted = True 1374 return 1375 1302 1376 class ExportJobContainerOverview(KofaPage): 1303 1377 """Page that lists active applicant data export jobs and provides links -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser_templates/applicantregemailsent.pt
r11254 r13254 23 23 <td i18n:translate="">User Name:</td> 24 24 <td tal:content="view/applicant_id">ID</td> 25 < tr>25 </tr> 26 26 <tr> 27 27 <td i18n:translate="">Password:</td> 28 28 <td tal:content="view/password">PASSWORD</td> 29 < tr>29 </tr> 30 30 </table> 31 31 <p> -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py
r13228 r13254 1399 1399 in self.browser.contents) 1400 1400 1401 def test_check_status(self): 1402 self.applicant.lastname = u'Lion' 1403 self.browser.open('http://localhost/app/applicants/checkstatus') 1404 self.browser.getControl(name="applicant_id").value = 'nonsense' 1405 self.browser.getControl(name="lastname").value = 'Lion' 1406 self.browser.getControl("Submit").click() 1407 self.assertTrue('No application record found' in self.browser.contents) 1408 self.browser.getControl(name="applicant_id").value = self.applicant.applicant_id 1409 self.browser.getControl(name="lastname").value = 'nonsense' 1410 self.browser.getControl("Submit").click() 1411 self.assertTrue('No application record found' in self.browser.contents) 1412 self.browser.getControl(name="applicant_id").value = self.applicant.applicant_id 1413 self.browser.getControl(name="lastname").value = 'Lion' 1414 self.browser.getControl("Submit").click() 1415 self.assertTrue('Application status of' in self.browser.contents) 1416 self.assertTrue('You have not yet submitted your application' in self.browser.contents) 1417 IWorkflowState(self.applicant).setState('admitted') 1418 self.browser.open('http://localhost/app/applicants/checkstatus') 1419 self.browser.getControl(name="applicant_id").value = self.applicant.applicant_id 1420 self.browser.getControl(name="lastname").value = 'Lion' 1421 self.browser.getControl("Submit").click() 1422 self.assertTrue('Congratulations!' in self.browser.contents) 1423 self.assertFalse('Study Course' in self.browser.contents) 1424 self.applicant.course_admitted = self.certificate 1425 self.browser.open('http://localhost/app/applicants/checkstatus') 1426 self.browser.getControl(name="applicant_id").value = self.applicant.applicant_id 1427 self.browser.getControl(name="lastname").value = 'Lion' 1428 self.browser.getControl("Submit").click() 1429 self.assertTrue('Congratulations!' in self.browser.contents) 1430 self.assertTrue('Unnamed Certificate (CERT1)' in self.browser.contents) 1431 self.assertTrue('Department of Unnamed Department (dep1)' in self.browser.contents) 1432 self.assertTrue('Faculty of Unnamed Faculty (NA)' in self.browser.contents) 1433 1401 1434 class ApplicantsExportTests(ApplicantsFullSetup, FunctionalAsyncTestCase): 1402 1435 # Tests for StudentsContainer class views and pages
Note: See TracChangeset for help on using the changeset viewer.