[16717] | 1 | ## $Id: interfaces.py 17015 2022-07-10 07:02:25Z henrik $ |
---|
[15614] | 2 | ## |
---|
| 3 | ## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann |
---|
| 4 | ## This program is free software; you can redistribute it and/or modify |
---|
| 5 | ## it under the terms of the GNU General Public License as published by |
---|
| 6 | ## the Free Software Foundation; either version 2 of the License, or |
---|
| 7 | ## (at your option) any later version. |
---|
| 8 | ## |
---|
| 9 | ## This program is distributed in the hope that it will be useful, |
---|
| 10 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 11 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 12 | ## GNU General Public License for more details. |
---|
| 13 | ## |
---|
| 14 | ## You should have received a copy of the GNU General Public License |
---|
| 15 | ## along with this program; if not, write to the Free Software |
---|
| 16 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
| 17 | ## |
---|
| 18 | """Customized interfaces of the university application package. |
---|
| 19 | """ |
---|
| 20 | |
---|
| 21 | from zope import schema |
---|
[16997] | 22 | from zope.interface import Interface, Attribute, implements, directlyProvides |
---|
[15614] | 23 | from waeup.kofa.applicants.interfaces import ( |
---|
| 24 | IApplicantBaseData, |
---|
| 25 | AppCatCertificateSource, CertificateSource) |
---|
| 26 | from waeup.kofa.schoolgrades import ResultEntryField |
---|
| 27 | from waeup.kofa.interfaces import ( |
---|
[16997] | 28 | SimpleKofaVocabulary, academic_sessions_vocab, validate_email, |
---|
| 29 | IKofaObject) |
---|
| 30 | from waeup.kofa.schema import FormattedDate, TextLineChoice, PhoneNumber |
---|
| 31 | from waeup.kofa.students.vocabularies import ( |
---|
| 32 | nats_vocab, GenderSource,RegNumberSource) |
---|
[15614] | 33 | from waeup.kofa.applicants.interfaces import contextual_reg_num_source |
---|
[16983] | 34 | from kofacustom.lpng.interfaces import MessageFactory as _ |
---|
| 35 | from kofacustom.lpng.payments.interfaces import ICustomOnlinePayment |
---|
[16997] | 36 | from kofacustom.nigeria.interfaces import LGASource |
---|
| 37 | from kofacustom.nigeria.applicants.interfaces import ( |
---|
| 38 | INigeriaApplicantOnlinePayment,) |
---|
[15614] | 39 | |
---|
[16997] | 40 | class IApplicantBaseData(IKofaObject): |
---|
| 41 | """This is a base interface of an applicant with no field |
---|
| 42 | required. For use with processors, forms, etc., please use one of |
---|
| 43 | the derived interfaces below, which set more fields to required |
---|
| 44 | state, depending on use-case. |
---|
[15614] | 45 | """ |
---|
[16997] | 46 | state = Attribute('Application state of an applicant') |
---|
| 47 | history = Attribute('Object history, a list of messages') |
---|
| 48 | display_fullname = Attribute('The fullname of an applicant') |
---|
| 49 | application_number = Attribute('The key under which the record is stored') |
---|
| 50 | container_code = Attribute('Code of the parent container plus additional information if record is used or not') |
---|
| 51 | translated_state = Attribute('Real name of the application state') |
---|
| 52 | special = Attribute('True if special application') |
---|
| 53 | payments = Attribute('List of payment objects stored in the applicant container') |
---|
[15614] | 54 | |
---|
[16997] | 55 | application_date = Attribute('UTC datetime of submission, used for export only') |
---|
| 56 | password = Attribute('Encrypted password of an applicant') |
---|
[15614] | 57 | |
---|
| 58 | |
---|
[16997] | 59 | suspended = schema.Bool( |
---|
| 60 | title = _(u'Account suspended'), |
---|
| 61 | default = False, |
---|
| 62 | required = False, |
---|
| 63 | ) |
---|
[15614] | 64 | |
---|
[16997] | 65 | applicant_id = schema.TextLine( |
---|
[17011] | 66 | title = _(u'Registrant Id'), |
---|
[16997] | 67 | required = False, |
---|
| 68 | readonly = False, |
---|
| 69 | ) |
---|
[17011] | 70 | |
---|
[16997] | 71 | reg_number = TextLineChoice( |
---|
| 72 | title = _(u'Registration Number'), |
---|
| 73 | readonly = False, |
---|
| 74 | required = False, |
---|
| 75 | source = contextual_reg_num_source, |
---|
| 76 | ) |
---|
| 77 | |
---|
[17013] | 78 | vin = schema.TextLine( |
---|
| 79 | title = _(u'Voter Identification No (VIN)'), |
---|
[17015] | 80 | required = False, |
---|
[17013] | 81 | ) |
---|
| 82 | |
---|
[16997] | 83 | firstname = schema.TextLine( |
---|
| 84 | title = _(u'First Name'), |
---|
| 85 | required = True, |
---|
| 86 | ) |
---|
| 87 | |
---|
| 88 | middlename = schema.TextLine( |
---|
| 89 | title = _(u'Middle Name'), |
---|
| 90 | required = False, |
---|
| 91 | ) |
---|
| 92 | |
---|
| 93 | lastname = schema.TextLine( |
---|
| 94 | title = _(u'Last Name (Surname)'), |
---|
| 95 | required = True, |
---|
| 96 | ) |
---|
| 97 | |
---|
| 98 | date_of_birth = FormattedDate( |
---|
| 99 | title = _(u'Date of Birth'), |
---|
| 100 | required = True, |
---|
| 101 | show_year = True, |
---|
| 102 | ) |
---|
| 103 | |
---|
| 104 | sex = schema.Choice( |
---|
| 105 | title = _(u'Gender'), |
---|
| 106 | source = GenderSource(), |
---|
| 107 | required = True, |
---|
| 108 | ) |
---|
| 109 | |
---|
| 110 | profession = schema.ASCIILine( |
---|
| 111 | title = _(u'Profession'), |
---|
| 112 | required = False, |
---|
| 113 | ) |
---|
| 114 | |
---|
| 115 | occupation = schema.ASCIILine( |
---|
| 116 | title = _(u'Occupation'), |
---|
| 117 | required = False, |
---|
| 118 | ) |
---|
| 119 | |
---|
| 120 | nationality = schema.Choice( |
---|
| 121 | source = nats_vocab, |
---|
| 122 | title = _(u'Nationality'), |
---|
| 123 | required = False, |
---|
| 124 | ) |
---|
| 125 | |
---|
| 126 | state_of_residence = schema.Choice( |
---|
| 127 | source = nats_vocab, |
---|
| 128 | title = _(u'State of Residence'), |
---|
| 129 | required = False, |
---|
| 130 | ) |
---|
| 131 | |
---|
| 132 | perm_address = schema.Text( |
---|
| 133 | title = _(u'Residential Address'), |
---|
| 134 | required = False, |
---|
| 135 | ) |
---|
| 136 | |
---|
| 137 | lga = schema.Choice( |
---|
| 138 | source = LGASource(), |
---|
| 139 | title = _(u'Local Government (Nigerians only)'), |
---|
| 140 | required = False, |
---|
| 141 | ) |
---|
| 142 | |
---|
| 143 | ward = schema.ASCIILine( |
---|
| 144 | title = _(u'Ward'), |
---|
| 145 | required = False, |
---|
| 146 | ) |
---|
| 147 | |
---|
| 148 | phone = PhoneNumber( |
---|
| 149 | title = _(u'Phone'), |
---|
| 150 | description = u'', |
---|
| 151 | required = False, |
---|
| 152 | ) |
---|
| 153 | |
---|
| 154 | email = schema.ASCIILine( |
---|
| 155 | title = _(u'Email Address'), |
---|
| 156 | required = True, |
---|
| 157 | constraint=validate_email, |
---|
| 158 | ) |
---|
| 159 | |
---|
| 160 | notice = schema.Text( |
---|
| 161 | title = _(u'Notice'), |
---|
| 162 | required = False, |
---|
| 163 | ) |
---|
| 164 | |
---|
| 165 | student_id = schema.TextLine( |
---|
| 166 | title = _(u'Student Id'), |
---|
| 167 | required = False, |
---|
| 168 | readonly = False, |
---|
| 169 | ) |
---|
| 170 | |
---|
| 171 | locked = schema.Bool( |
---|
| 172 | title = _(u'Form locked'), |
---|
| 173 | default = False, |
---|
| 174 | required = False, |
---|
| 175 | ) |
---|
| 176 | |
---|
| 177 | |
---|
| 178 | class ICustomApplicant(IApplicantBaseData): |
---|
[15614] | 179 | """An interface for both types of applicants. |
---|
| 180 | |
---|
| 181 | Attention: The ICustomPGApplicant field seetings will be overwritten |
---|
| 182 | by ICustomPGApplicant field settings. If a field is defined |
---|
| 183 | in both interfaces zope.schema validates only against the |
---|
| 184 | constraints in ICustomUGApplicant. This does not affect the forms |
---|
| 185 | since they are build on either ICustomUGApplicant or ICustomPGApplicant. |
---|
| 186 | """ |
---|
| 187 | |
---|
| 188 | def writeLogMessage(view, comment): |
---|
| 189 | """Adds an INFO message to the log file |
---|
| 190 | """ |
---|
| 191 | |
---|
| 192 | def createStudent(): |
---|
| 193 | """Create a student object from applicant data |
---|
| 194 | and copy applicant object. |
---|
| 195 | """ |
---|
| 196 | |
---|
[17013] | 197 | class ICustomApplicantEdit(ICustomApplicant): |
---|
| 198 | """This is an applicant interface for editing. |
---|
| 199 | |
---|
| 200 | Here we can repeat the fields from base data and set the |
---|
| 201 | `required` and `readonly` attributes to True to further restrict |
---|
| 202 | the data access. Or we can allow only certain certificates to be |
---|
| 203 | selected by choosing the appropriate source. |
---|
| 204 | |
---|
| 205 | We cannot omit fields here. This has to be done in the |
---|
| 206 | respective form page. |
---|
| 207 | """ |
---|
| 208 | |
---|
| 209 | reg_number = TextLineChoice( |
---|
| 210 | title = _(u'Registration Number'), |
---|
| 211 | readonly = True, |
---|
| 212 | required = False, |
---|
| 213 | source = contextual_reg_num_source, |
---|
| 214 | ) |
---|
| 215 | |
---|
| 216 | ICustomApplicantEdit['reg_number'].order = ICustomApplicant['reg_number'].order |
---|
| 217 | |
---|
[15614] | 218 | class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment): |
---|
| 219 | """An applicant payment via payment gateways. |
---|
| 220 | |
---|
| 221 | """ |
---|
| 222 | |
---|
[16997] | 223 | class ICustomApplicantUpdateByRegNo(ICustomApplicant): |
---|
[15614] | 224 | """Representation of an applicant. |
---|
| 225 | |
---|
| 226 | Skip regular reg_number validation if reg_number is used for finding |
---|
| 227 | the applicant object. |
---|
| 228 | """ |
---|
[16997] | 229 | |
---|
| 230 | reg_number = schema.TextLine( |
---|
| 231 | title = u'Registration Number', |
---|
| 232 | required = False, |
---|
| 233 | ) |
---|