Ignore:
Timestamp:
7 Mar 2011, 12:51:34 (14 years ago)
Author:
uli
Message:

Move (non-JAMB-specific) functions from jambtables.util to applicants.root module.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/root.py

    r5684 r5804  
    2525import grok
    2626from waeup.sirp.interfaces import IWAeUPSIRPPluggable
     27from waeup.sirp.accesscodes import get_access_code
    2728from waeup.sirp.applicants.interfaces import IApplicantsRoot
    2829
     
    106107        self.setup(site, name, logger)
    107108        return
     109
     110def get_applicant_data(reg_no, ac):
     111    """Validate credentials and return applicant data.
     112   
     113    Returns tuple ``(<APPLICANT_ENTRY>, <ACCESSCODE>) on
     114    successful validation and ``None`` else.
     115
     116    We expect a JAMB registration number and an access code in format
     117    like ``PREFIX-XXX-YYYYYYYY`` where ``PREFIX`` is something like
     118    ``APP`` or ``PUDE``, ``XXX`` the access code series and
     119    ``YYYYYYYYYY`` the real accesscode number.
     120    """
     121    site = grok.getSite()
     122    if reg_no is not None:
     123        applicant_data = site['applications'].get(reg_no, None)
     124    else:
     125        # Non-JAMB-screened applicants are stored by ac as key...
     126        applicant_data = site['applications'].get(ac, None)
     127    access_code = get_access_code(ac)
     128    return (applicant_data, access_code)
     129
     130def application_exists(identifier):
     131    """Check whether an application for the given identifier already
     132       exists.
     133
     134       `identifier` can be an access code or a JAMB registration
     135       number. For JAMB screened applicants we use the JAMB
     136       registration number as key, for other applicants we use the
     137       access code.
     138    """
     139    site = grok.getSite()
     140    if identifier in site['applications'].keys():
     141        return True
     142    return False
Note: See TracChangeset for help on using the changeset viewer.