Ignore:
Timestamp:
27 Jul 2010, 10:16:38 (14 years ago)
Author:
uli
Message:

Add login page for PUDE applicants.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/branches/ulif-fasttables/src/waeup/sirp/jambtables/browser.py

    r5303 r5320  
    2727    WAeUPPage, WAeUPEditFormPage, WAeUPAddFormPage,
    2828    WAeUPDisplayFormPage, NullValidator)
     29from waeup.sirp.interfaces import IWAeUPObject
    2930from waeup.sirp.jambtables import JAMBDataTable
    3031from waeup.sirp.jambtables.interfaces import IApplicant, IApplicantContainer
     
    3839from waeup.sirp.widgets.multilistwidget import (
    3940    MultiListWidget, MultiListDisplayWidget)
     41
    4042results_widget = CustomWidgetFactory(
    4143    WAeUPObjectWidget, ResultEntry)
     
    119121        self.redirect(self.url(self.context))
    120122        return
     123
     124class Login_PDE(WAeUPPage):
     125    grok.context(IWAeUPObject)
     126    grok.name('login_pde')
     127
     128    title = 'PDE Login'
     129    pnav = 1
     130
     131    def update(self, reg_no=None, ac_series=None, ac_number=None):
     132        """Validate credentials and redirect or show error.
     133
     134        XXX: log things happening here
     135        XXX: consider real login procedure with single applicant user.
     136        """
     137        self.reg_no = reg_no
     138        self.ac_series = ac_series
     139        self.ac_number = ac_number
     140        for param in [reg_no, ac_series, ac_number]:
     141            if param is None:
     142                return
     143        ac = "PUDE-%s-%s" % (ac_series, ac_number)
     144        data = self.getApplicantData(reg_no, ac)
     145        if data is None:
     146            self.flash('Invalid data entered')
     147            return
     148        applicant_data, access_code = data
     149        app_page = self.url(applicant_data, '@@edit')
     150        # XXX: Invalidate ACCESS_CODE
     151        self.redirect(app_page)
     152        return
     153
     154    def getCurrentSession(self):
     155        """Get the current session.
     156
     157        XXX: This should be computed or retrieved from elsewhere.
     158        """
     159        return u'2010/2011'
     160
     161    def getDeadline(self):
     162        """Get application submission deadline.
     163
     164        XXX: This should be computed or retrieved from elsewhere.
     165        """
     166        return u"""Application submission deadline is at Midnight on Friday,
     167                   01. October 2010. No application will be treated
     168                   after the deadline."""
     169
     170    def getApplicantData(self, reg_no, ac):
     171        """Validate credentials and return applicant data.
     172
     173        Returns tuple ``(<APPLICANT_ENTRY>, <ACCESSCODE>) on
     174        successful validation and ``None`` else.
     175
     176        We expect a JAMB registration number and an access code in
     177        format ``PUDE-XXX-XXXXXXXXXX``.
     178        """
     179        site = grok.getSite()
     180        if reg_no not in site['applications'].keys():
     181            return None
     182        applicant_data = site['applications'][reg_no]
     183        entries = site['accesscodes'].search(ac, 'pin')
     184        if len(entries) != 1:
     185            # XXX: If entries > 1 then we have a problem!
     186            return None
     187        return (applicant_data, entries[0])
Note: See TracChangeset for help on using the changeset viewer.