## ## interfaces.py ## Login : ## Started on Sun Jun 27 11:06:23 2010 Uli Fouquet ## $Id$ ## ## Copyright (C) 2010 Uli Fouquet ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ## """Interfaces for JAMB data tables and related components. """ import os import waeup.sirp.browser from hurry.file import HurryFile from zc.sourcefactory.basic import BasicSourceFactory from zope import schema from zope.app.file.interfaces import IImage from zope.interface import Interface, Attribute from zope.pluggableauth.interfaces import IPrincipalInfo from zope.security.interfaces import IGroupClosureAwarePrincipal as IPrincipal from waeup.sirp.interfaces import IWAeUPObject from waeup.sirp.image.schema import ImageFile from waeup.sirp.applicants.interfaces import IApplicantBaseData class IJAMBDataRoot(IWAeUPObject): """A container that holds JAMB data tables. """ class IResultEntry(IWAeUPObject): subject = schema.TextLine( title = u'Subject', description = u'The subject', required=False, ) score = schema.TextLine( title = u'Score', description = u'The score', required=False, ) class IApplicantPDEImportData(IApplicantBaseData): """Data for applicants, that passed PDE screening. This data set should be suitable for imports from JAMB tables. It is also basicall the basic applicant data from :class:`IApplicantBaseData` only with the required fields set. """ firstname = schema.TextLine( title = u'First Name', required = True, ) middlenames = schema.TextLine( title = u'Middle Names', required = True, ) lastname = schema.TextLine( title = u'Surname/Full Name', required = True, ) date_of_birth = schema.Date( title = u'Date of Birth', required = True, ) jamb_state = schema.TextLine( title = u'State (provided by JAMB)', required = True, ) jamb_lga = schema.TextLine( title = u'LGA (provided by JAMB)', required = True, ) course1 = schema.TextLine( title = u'1st Choice Course of Study', required = True, ) screening_date = schema.Date( title = u'Screening Date', required = True, ) screening_type = schema.TextLine( # XXX: schould be choice title = u'Screening Type', required = True, ) screening_venue = schema.TextLine( title = u'Screening Venue', required = True, ) entry_session = schema.TextLine( # XXX: should be choice # XXX: should have sensible default: upcoming session title = u'Entry Session', required = True, ) class IApplicantContainer(IWAeUPObject): """A container for applicants. """ class IApplicantPrincipalInfo(IPrincipalInfo): """Infos about principals that are applicants. """ reg_no = Attribute("The JAMB registration no. of the user") access_code = Attribute("The Access Code the user purchased") class IApplicantPrincipal(IPrincipal): """A principal that is an applicant. This interface extends zope.security.interfaces.IPrincipal and requires also an `id` and other attributes defined there. """ reg_no = schema.TextLine( title = u'Registration number', description = u'The JAMB registration number', required = True, readonly = True) access_code = schema.TextLine( title = u'Access Code', description = u'The access code purchased by the user.', required = True, readonly = True) class IApplicantsFormChallenger(Interface): """A challenger that uses a browser form to collect applicant credentials. """ loginpagename = schema.TextLine( title = u'Loginpagename', description = u"""Name of the login form used by challenger. The form must provide an ``access_code`` input field. """) accesscode_field = schema.TextLine( title = u'Access code field', description = u'''Field of the login page which is looked up for access_code''', default = u'access_code', ) class IJAMBApplicantsFormChallenger(IApplicantsFormChallenger): """A challenger that uses a browser form to collect applicant credentials for applicants in JAMB process. JAMB-screened applicants have to provide an extra registration no. provided by JAMB. """ jamb_reg_no_field = schema.TextLine( title = u'JAMB registration no.', description = u'''Field of the login page which is looked up for the JAMB registration number.''', default = u'jamb_reg_no', ) class IApplicantSessionCredentials(Interface): """Interface for storing and accessing applicant credentials in a session. """ def __init__(access_code): """Create applicant session credentials.""" def getAccessCode(): """Return the access code.""" class IJAMBApplicantSessionCredentials(IApplicantSessionCredentials): """Interface for storing and accessing JAMB applicant credentials in a session. """ def __init__(access_code, jamb_reg_no): """Create credentials for JAMB screened applicants.""" def getJAMBRegNo(): """Return the JAMB registration no."""