[16717] | 1 | ## $Id: interfaces.py 17161 2022-11-13 23:45: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 |
---|
| 22 | from waeup.kofa.applicants.interfaces import ( |
---|
| 23 | IApplicantBaseData, |
---|
| 24 | AppCatCertificateSource, CertificateSource) |
---|
| 25 | from waeup.kofa.schoolgrades import ResultEntryField |
---|
| 26 | from waeup.kofa.interfaces import ( |
---|
| 27 | SimpleKofaVocabulary, academic_sessions_vocab, validate_email) |
---|
[16734] | 28 | from waeup.kofa.schema import FormattedDate, TextLineChoice, PhoneNumber |
---|
[15614] | 29 | from waeup.kofa.students.vocabularies import nats_vocab, GenderSource |
---|
| 30 | from waeup.kofa.applicants.interfaces import contextual_reg_num_source |
---|
| 31 | from kofacustom.nigeria.applicants.interfaces import ( |
---|
[16734] | 32 | LGASource, high_qual, high_grade, exam_types, DisabilitiesSource, |
---|
| 33 | programme_types_vocab, jambsubjects, validate_jamb_reg_number, |
---|
[15614] | 34 | INigeriaUGApplicant, INigeriaPGApplicant, |
---|
| 35 | INigeriaApplicantOnlinePayment, |
---|
| 36 | INigeriaUGApplicantEdit, INigeriaPGApplicantEdit, |
---|
| 37 | INigeriaApplicantUpdateByRegNo, |
---|
| 38 | IPUTMEApplicantEdit, |
---|
| 39 | ) |
---|
[16721] | 40 | from kofacustom.unidel.interfaces import MessageFactory as _ |
---|
| 41 | from kofacustom.unidel.payments.interfaces import ICustomOnlinePayment |
---|
[15614] | 42 | |
---|
| 43 | class ICustomUGApplicant(INigeriaUGApplicant): |
---|
| 44 | """An undergraduate applicant. |
---|
| 45 | """ |
---|
| 46 | |
---|
[16734] | 47 | disabilities = schema.Choice( |
---|
| 48 | title = _(u'Disability'), |
---|
| 49 | source = DisabilitiesSource(), |
---|
| 50 | required = False, |
---|
| 51 | ) |
---|
| 52 | nationality = schema.Choice( |
---|
| 53 | source = nats_vocab, |
---|
| 54 | title = _(u'Nationality'), |
---|
| 55 | required = False, |
---|
| 56 | ) |
---|
| 57 | lga = schema.Choice( |
---|
| 58 | source = LGASource(), |
---|
| 59 | title = _(u'State/LGA (Nigerians only)'), |
---|
| 60 | required = False, |
---|
| 61 | ) |
---|
| 62 | perm_address = schema.Text( |
---|
| 63 | title = _(u'Permanent Address'), |
---|
| 64 | required = False, |
---|
| 65 | ) |
---|
| 66 | |
---|
| 67 | next_kin_name = schema.TextLine( |
---|
| 68 | title = _(u'Next of Kin Name'), |
---|
| 69 | required = False, |
---|
| 70 | readonly = False, |
---|
| 71 | ) |
---|
| 72 | |
---|
| 73 | next_kin_relation = schema.TextLine( |
---|
| 74 | title = _(u'Next of Kin Relationship'), |
---|
| 75 | required = False, |
---|
| 76 | readonly = False, |
---|
| 77 | ) |
---|
| 78 | |
---|
| 79 | next_kin_address = schema.Text( |
---|
| 80 | title = _(u'Next of Kin Address'), |
---|
| 81 | required = False, |
---|
| 82 | readonly = False, |
---|
| 83 | ) |
---|
| 84 | |
---|
| 85 | next_kin_phone = PhoneNumber( |
---|
| 86 | title = _(u'Next of Kin Phone'), |
---|
| 87 | description = u'', |
---|
| 88 | required = False, |
---|
| 89 | readonly = False, |
---|
| 90 | ) |
---|
| 91 | |
---|
| 92 | course1 = schema.Choice( |
---|
| 93 | title = _(u'1st Choice Course of Study'), |
---|
| 94 | source = AppCatCertificateSource(), |
---|
| 95 | required = True, |
---|
| 96 | ) |
---|
| 97 | course2 = schema.Choice( |
---|
| 98 | title = _(u'2nd Choice Course of Study'), |
---|
| 99 | source = AppCatCertificateSource(), |
---|
| 100 | required = False, |
---|
| 101 | ) |
---|
| 102 | |
---|
| 103 | fst_sit_fname = schema.TextLine( |
---|
| 104 | title = _(u'Full Name'), |
---|
| 105 | required = False, |
---|
| 106 | readonly = False, |
---|
| 107 | ) |
---|
| 108 | |
---|
| 109 | fst_sit_no = schema.TextLine( |
---|
| 110 | title = _(u'Exam Number'), |
---|
| 111 | required = False, |
---|
| 112 | readonly = False, |
---|
| 113 | ) |
---|
| 114 | |
---|
| 115 | fst_sit_date = FormattedDate( |
---|
| 116 | title = _(u'Exam Date'), |
---|
| 117 | required = False, |
---|
| 118 | readonly = False, |
---|
| 119 | show_year = True, |
---|
| 120 | ) |
---|
| 121 | |
---|
| 122 | fst_sit_type = schema.Choice( |
---|
| 123 | title = _(u'Exam Type'), |
---|
| 124 | required = False, |
---|
| 125 | readonly = False, |
---|
| 126 | vocabulary = exam_types, |
---|
| 127 | ) |
---|
| 128 | |
---|
| 129 | fst_sit_results = schema.List( |
---|
| 130 | title = _(u'Exam Results'), |
---|
| 131 | value_type = ResultEntryField(), |
---|
| 132 | required = False, |
---|
| 133 | readonly = False, |
---|
| 134 | defaultFactory=list, |
---|
| 135 | ) |
---|
| 136 | |
---|
| 137 | scd_sit_fname = schema.TextLine( |
---|
| 138 | title = _(u'Full Name'), |
---|
| 139 | required = False, |
---|
| 140 | readonly = False, |
---|
| 141 | ) |
---|
| 142 | |
---|
| 143 | scd_sit_no = schema.TextLine( |
---|
| 144 | title = _(u'Exam Number'), |
---|
| 145 | required = False, |
---|
| 146 | readonly = False, |
---|
| 147 | ) |
---|
| 148 | |
---|
| 149 | scd_sit_date = FormattedDate( |
---|
| 150 | title = _(u'Exam Date'), |
---|
| 151 | required = False, |
---|
| 152 | readonly = False, |
---|
| 153 | show_year = True, |
---|
| 154 | ) |
---|
| 155 | |
---|
| 156 | scd_sit_type = schema.Choice( |
---|
| 157 | title = _(u'Exam Type'), |
---|
| 158 | required = False, |
---|
| 159 | readonly = False, |
---|
| 160 | vocabulary = exam_types, |
---|
| 161 | ) |
---|
| 162 | |
---|
| 163 | scd_sit_results = schema.List( |
---|
| 164 | title = _(u'Exam Results'), |
---|
| 165 | value_type = ResultEntryField(), |
---|
| 166 | required = False, |
---|
| 167 | readonly = False, |
---|
| 168 | defaultFactory=list, |
---|
| 169 | ) |
---|
| 170 | |
---|
| 171 | programme_type = schema.Choice( |
---|
| 172 | title = _(u'Programme Type'), |
---|
| 173 | vocabulary = programme_types_vocab, |
---|
| 174 | required = False, |
---|
| 175 | ) |
---|
| 176 | |
---|
| 177 | hq_type = schema.Choice( |
---|
| 178 | title = _(u'Qualification Obtained'), |
---|
| 179 | required = False, |
---|
| 180 | readonly = False, |
---|
| 181 | vocabulary = high_qual, |
---|
| 182 | ) |
---|
| 183 | hq_matric_no = schema.TextLine( |
---|
| 184 | title = _(u'Former Matric Number'), |
---|
| 185 | required = False, |
---|
| 186 | readonly = False, |
---|
| 187 | ) |
---|
| 188 | hq_degree = schema.Choice( |
---|
| 189 | title = _(u'Class of Degree'), |
---|
| 190 | required = False, |
---|
| 191 | readonly = False, |
---|
| 192 | vocabulary = high_grade, |
---|
| 193 | ) |
---|
| 194 | hq_school = schema.TextLine( |
---|
| 195 | title = _(u'Institution Attended'), |
---|
| 196 | required = False, |
---|
| 197 | readonly = False, |
---|
| 198 | ) |
---|
| 199 | hq_session = schema.TextLine( |
---|
| 200 | title = _(u'Years Attended'), |
---|
| 201 | required = False, |
---|
| 202 | readonly = False, |
---|
| 203 | ) |
---|
| 204 | hq_disc = schema.TextLine( |
---|
| 205 | title = _(u'Discipline'), |
---|
| 206 | required = False, |
---|
| 207 | readonly = False, |
---|
| 208 | ) |
---|
| 209 | jamb_subjects = schema.Text( |
---|
| 210 | title = _(u'Subjects and Scores'), |
---|
| 211 | required = False, |
---|
| 212 | ) |
---|
| 213 | jamb_subjects_list = schema.List( |
---|
| 214 | title = _(u'JAMB Subjects'), |
---|
| 215 | required = False, |
---|
| 216 | defaultFactory=list, |
---|
| 217 | value_type = schema.Choice( |
---|
| 218 | vocabulary = jambsubjects |
---|
| 219 | #source = JAMBSubjectSource(), |
---|
| 220 | ), |
---|
| 221 | ) |
---|
| 222 | jamb_score = schema.Int( |
---|
| 223 | title = _(u'Total JAMB Score'), |
---|
| 224 | required = False, |
---|
| 225 | ) |
---|
| 226 | #jamb_age = schema.Int( |
---|
| 227 | # title = _(u'Age (provided by JAMB)'), |
---|
| 228 | # required = False, |
---|
| 229 | # ) |
---|
| 230 | jamb_reg_number = schema.TextLine( |
---|
| 231 | title = _(u'JAMB Registration Number'), |
---|
| 232 | required = False, |
---|
| 233 | constraint=validate_jamb_reg_number, |
---|
| 234 | ) |
---|
| 235 | notice = schema.Text( |
---|
| 236 | title = _(u'Notice'), |
---|
| 237 | required = False, |
---|
| 238 | ) |
---|
| 239 | screening_venue = schema.TextLine( |
---|
| 240 | title = _(u'Screening Venue'), |
---|
| 241 | required = False, |
---|
| 242 | ) |
---|
| 243 | screening_date = schema.TextLine( |
---|
| 244 | title = _(u'Screening Date'), |
---|
| 245 | required = False, |
---|
| 246 | ) |
---|
| 247 | screening_score = schema.Int( |
---|
| 248 | title = _(u'Screening Score (%)'), |
---|
| 249 | required = False, |
---|
| 250 | ) |
---|
[17161] | 251 | aggregate = schema.Float( |
---|
[16734] | 252 | title = _(u'Aggregate Score (%)'), |
---|
| 253 | description = _(u'(average of relative JAMB and PUTME scores)'), |
---|
| 254 | required = False, |
---|
| 255 | ) |
---|
| 256 | result_uploaded = schema.Bool( |
---|
| 257 | title = _(u'Result uploaded'), |
---|
| 258 | default = False, |
---|
| 259 | required = False, |
---|
| 260 | ) |
---|
| 261 | student_id = schema.TextLine( |
---|
| 262 | title = _(u'Student Id'), |
---|
| 263 | required = False, |
---|
| 264 | readonly = False, |
---|
| 265 | ) |
---|
| 266 | course_admitted = schema.Choice( |
---|
| 267 | title = _(u'Admitted Course of Study'), |
---|
| 268 | source = CertificateSource(), |
---|
| 269 | required = False, |
---|
| 270 | ) |
---|
| 271 | locked = schema.Bool( |
---|
| 272 | title = _(u'Form locked'), |
---|
| 273 | default = False, |
---|
| 274 | required = False, |
---|
| 275 | ) |
---|
| 276 | |
---|
[15614] | 277 | class ICustomPGApplicant(INigeriaPGApplicant): |
---|
| 278 | """A postgraduate applicant. |
---|
| 279 | """ |
---|
| 280 | |
---|
| 281 | class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant): |
---|
| 282 | """An interface for both types of applicants. |
---|
| 283 | |
---|
| 284 | Attention: The ICustomPGApplicant field seetings will be overwritten |
---|
| 285 | by ICustomPGApplicant field settings. If a field is defined |
---|
| 286 | in both interfaces zope.schema validates only against the |
---|
| 287 | constraints in ICustomUGApplicant. This does not affect the forms |
---|
| 288 | since they are build on either ICustomUGApplicant or ICustomPGApplicant. |
---|
| 289 | """ |
---|
| 290 | |
---|
| 291 | def writeLogMessage(view, comment): |
---|
| 292 | """Adds an INFO message to the log file |
---|
| 293 | """ |
---|
| 294 | |
---|
| 295 | def createStudent(): |
---|
| 296 | """Create a student object from applicant data |
---|
| 297 | and copy applicant object. |
---|
| 298 | """ |
---|
| 299 | |
---|
[16734] | 300 | class ICustomUGApplicantEdit(ICustomUGApplicant): |
---|
[15614] | 301 | """An undergraduate applicant interface for edit forms. |
---|
| 302 | |
---|
| 303 | Here we can repeat the fields from base data and set the |
---|
| 304 | `required` and `readonly` attributes to True to further restrict |
---|
| 305 | the data access. Or we can allow only certain certificates to be |
---|
| 306 | selected by choosing the appropriate source. |
---|
| 307 | |
---|
| 308 | We cannot omit fields here. This has to be done in the |
---|
| 309 | respective form page. |
---|
| 310 | """ |
---|
| 311 | |
---|
| 312 | class ICustomPGApplicantEdit(INigeriaPGApplicantEdit): |
---|
| 313 | """A postgraduate applicant interface for editing. |
---|
| 314 | |
---|
| 315 | Here we can repeat the fields from base data and set the |
---|
| 316 | `required` and `readonly` attributes to True to further restrict |
---|
| 317 | the data access. Or we can allow only certain certificates to be |
---|
| 318 | selected by choosing the appropriate source. |
---|
| 319 | |
---|
| 320 | We cannot omit fields here. This has to be done in the |
---|
| 321 | respective form page. |
---|
| 322 | """ |
---|
| 323 | |
---|
| 324 | class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment): |
---|
| 325 | """An applicant payment via payment gateways. |
---|
| 326 | |
---|
| 327 | """ |
---|
| 328 | |
---|
| 329 | class IPUTMEApplicantEdit(IPUTMEApplicantEdit): |
---|
| 330 | """An undergraduate applicant interface for editing. |
---|
| 331 | |
---|
| 332 | Here we can repeat the fields from base data and set the |
---|
| 333 | `required` and `readonly` attributes to True to further restrict |
---|
| 334 | the data access. Or we can allow only certain certificates to be |
---|
| 335 | selected by choosing the appropriate source. |
---|
| 336 | |
---|
| 337 | We cannot omit fields here. This has to be done in the |
---|
| 338 | respective form page. |
---|
| 339 | """ |
---|
| 340 | |
---|
| 341 | class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo): |
---|
| 342 | """Representation of an applicant. |
---|
| 343 | |
---|
| 344 | Skip regular reg_number validation if reg_number is used for finding |
---|
| 345 | the applicant object. |
---|
| 346 | """ |
---|