Ignore:
Timestamp:
9 Sep 2015, 13:06:31 (9 years ago)
Author:
Henrik Bettermann
Message:

Add public page to check application status without password.

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  
    3939from waeup.kofa.applicants.applicant import search
    4040from waeup.kofa.applicants.workflow import (
    41     INITIALIZED, STARTED, PAID, SUBMITTED, ADMITTED)
     41    INITIALIZED, STARTED, PAID, SUBMITTED, ADMITTED, NOT_ADMITTED, CREATED)
    4242from waeup.kofa.browser import (
    4343#    KofaPage, KofaEditFormPage, KofaAddFormPage, KofaDisplayFormPage,
     
    13001300        return
    13011301
     1302class 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
    13021376class ExportJobContainerOverview(KofaPage):
    13031377    """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  
    2323      <td i18n:translate="">User Name:</td>
    2424      <td tal:content="view/applicant_id">ID</td>
    25     <tr>
     25    </tr>
    2626    <tr>
    2727      <td i18n:translate="">Password:</td>
    2828      <td tal:content="view/password">PASSWORD</td>
    29     <tr>
     29    </tr>
    3030  </table>
    3131  <p>
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py

    r13228 r13254  
    13991399            in self.browser.contents)
    14001400
     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
    14011434class ApplicantsExportTests(ApplicantsFullSetup, FunctionalAsyncTestCase):
    14021435    # Tests for StudentsContainer class views and pages
Note: See TracChangeset for help on using the changeset viewer.