[5247] | 1 | ## |
---|
| 2 | ## interfaces.py |
---|
| 3 | ## Login : <uli@pu.smp.net> |
---|
| 4 | ## Started on Sun Jun 27 11:06:23 2010 Uli Fouquet |
---|
| 5 | ## $Id$ |
---|
| 6 | ## |
---|
| 7 | ## Copyright (C) 2010 Uli Fouquet |
---|
| 8 | ## This program is free software; you can redistribute it and/or modify |
---|
| 9 | ## it under the terms of the GNU General Public License as published by |
---|
| 10 | ## the Free Software Foundation; either version 2 of the License, or |
---|
| 11 | ## (at your option) any later version. |
---|
| 12 | ## |
---|
| 13 | ## This program is distributed in the hope that it will be useful, |
---|
| 14 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | ## GNU General Public License for more details. |
---|
| 17 | ## |
---|
| 18 | ## You should have received a copy of the GNU General Public License |
---|
| 19 | ## along with this program; if not, write to the Free Software |
---|
| 20 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
| 21 | ## |
---|
| 22 | """Interfaces for JAMB data tables and related components. |
---|
| 23 | """ |
---|
[5686] | 24 | import os |
---|
| 25 | import waeup.sirp.browser |
---|
| 26 | from hurry.file import HurryFile |
---|
[5319] | 27 | from zc.sourcefactory.basic import BasicSourceFactory |
---|
[5251] | 28 | from zope import schema |
---|
[5686] | 29 | from zope.app.file.interfaces import IImage |
---|
[5432] | 30 | from zope.interface import Interface, Attribute |
---|
| 31 | from zope.pluggableauth.interfaces import IPrincipalInfo |
---|
| 32 | from zope.security.interfaces import IGroupClosureAwarePrincipal as IPrincipal |
---|
[5686] | 33 | from waeup.sirp.interfaces import IWAeUPObject |
---|
| 34 | from waeup.sirp.image.schema import ImageFile |
---|
[5753] | 35 | from waeup.sirp.applicants.interfaces import IApplicantBaseData |
---|
[5247] | 36 | |
---|
[5432] | 37 | |
---|
[5723] | 38 | class IJAMBDataRoot(IWAeUPObject): |
---|
| 39 | """A container that holds JAMB data tables. |
---|
| 40 | """ |
---|
[5271] | 41 | |
---|
| 42 | class IResultEntry(IWAeUPObject): |
---|
| 43 | subject = schema.TextLine( |
---|
| 44 | title = u'Subject', |
---|
| 45 | description = u'The subject', |
---|
| 46 | required=False, |
---|
| 47 | ) |
---|
| 48 | score = schema.TextLine( |
---|
| 49 | title = u'Score', |
---|
| 50 | description = u'The score', |
---|
| 51 | required=False, |
---|
| 52 | ) |
---|
[5268] | 53 | |
---|
| 54 | |
---|
[5319] | 55 | class IApplicantPDEImportData(IApplicantBaseData): |
---|
| 56 | """Data for applicants, that passed PDE screening. |
---|
| 57 | |
---|
| 58 | This data set should be suitable for imports from JAMB tables. It |
---|
| 59 | is also basicall the basic applicant data from |
---|
| 60 | :class:`IApplicantBaseData` only with the required fields set. |
---|
| 61 | |
---|
| 62 | """ |
---|
| 63 | firstname = schema.TextLine( |
---|
| 64 | title = u'First Name', |
---|
| 65 | required = True, |
---|
| 66 | ) |
---|
| 67 | middlenames = schema.TextLine( |
---|
| 68 | title = u'Middle Names', |
---|
| 69 | required = True, |
---|
| 70 | ) |
---|
| 71 | lastname = schema.TextLine( |
---|
| 72 | title = u'Surname/Full Name', |
---|
| 73 | required = True, |
---|
| 74 | ) |
---|
| 75 | date_of_birth = schema.Date( |
---|
| 76 | title = u'Date of Birth', |
---|
| 77 | required = True, |
---|
| 78 | ) |
---|
| 79 | jamb_state = schema.TextLine( |
---|
| 80 | title = u'State (provided by JAMB)', |
---|
| 81 | required = True, |
---|
| 82 | ) |
---|
| 83 | jamb_lga = schema.TextLine( |
---|
| 84 | title = u'LGA (provided by JAMB)', |
---|
| 85 | required = True, |
---|
| 86 | ) |
---|
| 87 | course1 = schema.TextLine( |
---|
| 88 | title = u'1st Choice Course of Study', |
---|
| 89 | required = True, |
---|
| 90 | ) |
---|
| 91 | screening_date = schema.Date( |
---|
| 92 | title = u'Screening Date', |
---|
| 93 | required = True, |
---|
| 94 | ) |
---|
| 95 | screening_type = schema.TextLine( |
---|
| 96 | # XXX: schould be choice |
---|
| 97 | title = u'Screening Type', |
---|
| 98 | required = True, |
---|
| 99 | ) |
---|
| 100 | screening_venue = schema.TextLine( |
---|
| 101 | title = u'Screening Venue', |
---|
| 102 | required = True, |
---|
| 103 | ) |
---|
| 104 | entry_session = schema.TextLine( |
---|
| 105 | # XXX: should be choice |
---|
| 106 | # XXX: should have sensible default: upcoming session |
---|
| 107 | title = u'Entry Session', |
---|
| 108 | required = True, |
---|
| 109 | ) |
---|
| 110 | |
---|
[5269] | 111 | class IApplicantContainer(IWAeUPObject): |
---|
| 112 | """A container for applicants. |
---|
| 113 | """ |
---|
[5432] | 114 | |
---|
| 115 | class IApplicantPrincipalInfo(IPrincipalInfo): |
---|
| 116 | """Infos about principals that are applicants. |
---|
| 117 | """ |
---|
| 118 | reg_no = Attribute("The JAMB registration no. of the user") |
---|
| 119 | |
---|
| 120 | access_code = Attribute("The Access Code the user purchased") |
---|
| 121 | |
---|
| 122 | class IApplicantPrincipal(IPrincipal): |
---|
| 123 | """A principal that is an applicant. |
---|
| 124 | |
---|
| 125 | This interface extends zope.security.interfaces.IPrincipal and |
---|
| 126 | requires also an `id` and other attributes defined there. |
---|
| 127 | """ |
---|
| 128 | reg_no = schema.TextLine( |
---|
| 129 | title = u'Registration number', |
---|
| 130 | description = u'The JAMB registration number', |
---|
| 131 | required = True, |
---|
| 132 | readonly = True) |
---|
| 133 | |
---|
| 134 | access_code = schema.TextLine( |
---|
| 135 | title = u'Access Code', |
---|
| 136 | description = u'The access code purchased by the user.', |
---|
| 137 | required = True, |
---|
| 138 | readonly = True) |
---|
[5436] | 139 | |
---|
[5437] | 140 | class IApplicantsFormChallenger(Interface): |
---|
[5436] | 141 | """A challenger that uses a browser form to collect applicant |
---|
| 142 | credentials. |
---|
| 143 | """ |
---|
| 144 | loginpagename = schema.TextLine( |
---|
| 145 | title = u'Loginpagename', |
---|
| 146 | description = u"""Name of the login form used by challenger. |
---|
| 147 | |
---|
| 148 | The form must provide an ``access_code`` input field. |
---|
[5439] | 149 | """) |
---|
[5436] | 150 | |
---|
[5439] | 151 | accesscode_field = schema.TextLine( |
---|
[5436] | 152 | title = u'Access code field', |
---|
| 153 | description = u'''Field of the login page which is looked up for |
---|
| 154 | access_code''', |
---|
| 155 | default = u'access_code', |
---|
| 156 | ) |
---|
| 157 | |
---|
[5439] | 158 | class IJAMBApplicantsFormChallenger(IApplicantsFormChallenger): |
---|
[5436] | 159 | """A challenger that uses a browser form to collect applicant |
---|
| 160 | credentials for applicants in JAMB process. |
---|
| 161 | |
---|
| 162 | JAMB-screened applicants have to provide an extra registration |
---|
| 163 | no. provided by JAMB. |
---|
| 164 | """ |
---|
[5439] | 165 | jamb_reg_no_field = schema.TextLine( |
---|
[5436] | 166 | title = u'JAMB registration no.', |
---|
| 167 | description = u'''Field of the login page which is looked up for |
---|
| 168 | the JAMB registration number.''', |
---|
| 169 | default = u'jamb_reg_no', |
---|
| 170 | ) |
---|
[5438] | 171 | |
---|
| 172 | class IApplicantSessionCredentials(Interface): |
---|
| 173 | """Interface for storing and accessing applicant credentials in a |
---|
| 174 | session. |
---|
| 175 | """ |
---|
| 176 | |
---|
| 177 | def __init__(access_code): |
---|
[5471] | 178 | """Create applicant session credentials.""" |
---|
[5438] | 179 | |
---|
| 180 | def getAccessCode(): |
---|
| 181 | """Return the access code.""" |
---|
| 182 | |
---|
| 183 | |
---|
| 184 | class IJAMBApplicantSessionCredentials(IApplicantSessionCredentials): |
---|
| 185 | """Interface for storing and accessing JAMB applicant credentials in a |
---|
| 186 | session. |
---|
| 187 | """ |
---|
| 188 | |
---|
| 189 | def __init__(access_code, jamb_reg_no): |
---|
[5471] | 190 | """Create credentials for JAMB screened applicants.""" |
---|
[5438] | 191 | |
---|
| 192 | def getJAMBRegNo(): |
---|
| 193 | """Return the JAMB registration no.""" |
---|