| 1 | ## $Id: interfaces.py 18359 2026-11-05 12:09:23Z henrik $ |
|---|
| 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) |
|---|
| 28 | from waeup.kofa.schema import FormattedDate, TextLineChoice, PhoneNumber |
|---|
| 29 | from waeup.kofa.students.vocabularies import nats_vocab, GenderSource |
|---|
| 30 | from waeup.kofa.applicants.interfaces import contextual_reg_num_source |
|---|
| 31 | from waeup.kofa.refereeentries import RefereeEntryField |
|---|
| 32 | from kofacustom.nigeria.applicants.interfaces import ( |
|---|
| 33 | LGASource, high_qual, high_grade, exam_types, DisabilitiesSource, |
|---|
| 34 | programme_types_vocab, jambsubjects, validate_jamb_reg_number, |
|---|
| 35 | INigeriaUGApplicant, INigeriaPGApplicant, |
|---|
| 36 | INigeriaApplicantOnlinePayment, |
|---|
| 37 | INigeriaUGApplicantEdit, INigeriaPGApplicantEdit, |
|---|
| 38 | INigeriaApplicantUpdateByRegNo, |
|---|
| 39 | IPUTMEApplicantEdit, |
|---|
| 40 | ) |
|---|
| 41 | from kofacustom.unidel.interfaces import MessageFactory as _ |
|---|
| 42 | from kofacustom.unidel.payments.interfaces import ICustomOnlinePayment |
|---|
| 43 | |
|---|
| 44 | class ICustomUGApplicant(INigeriaUGApplicant): |
|---|
| 45 | """An undergraduate applicant. |
|---|
| 46 | """ |
|---|
| 47 | |
|---|
| 48 | disabilities = schema.Choice( |
|---|
| 49 | title = _(u'Disability'), |
|---|
| 50 | source = DisabilitiesSource(), |
|---|
| 51 | required = False, |
|---|
| 52 | ) |
|---|
| 53 | nationality = schema.Choice( |
|---|
| 54 | source = nats_vocab, |
|---|
| 55 | title = _(u'Nationality'), |
|---|
| 56 | required = False, |
|---|
| 57 | ) |
|---|
| 58 | lga = schema.Choice( |
|---|
| 59 | source = LGASource(), |
|---|
| 60 | title = _(u'State/LGA (Nigerians only)'), |
|---|
| 61 | required = False, |
|---|
| 62 | ) |
|---|
| 63 | perm_address = schema.Text( |
|---|
| 64 | title = _(u'Permanent Address'), |
|---|
| 65 | required = False, |
|---|
| 66 | ) |
|---|
| 67 | |
|---|
| 68 | next_kin_name = schema.TextLine( |
|---|
| 69 | title = _(u'Next of Kin Name'), |
|---|
| 70 | required = False, |
|---|
| 71 | readonly = False, |
|---|
| 72 | ) |
|---|
| 73 | |
|---|
| 74 | next_kin_relation = schema.TextLine( |
|---|
| 75 | title = _(u'Next of Kin Relationship'), |
|---|
| 76 | required = False, |
|---|
| 77 | readonly = False, |
|---|
| 78 | ) |
|---|
| 79 | |
|---|
| 80 | next_kin_address = schema.Text( |
|---|
| 81 | title = _(u'Next of Kin Address'), |
|---|
| 82 | required = False, |
|---|
| 83 | readonly = False, |
|---|
| 84 | ) |
|---|
| 85 | |
|---|
| 86 | next_kin_phone = PhoneNumber( |
|---|
| 87 | title = _(u'Next of Kin Phone'), |
|---|
| 88 | description = u'', |
|---|
| 89 | required = False, |
|---|
| 90 | readonly = False, |
|---|
| 91 | ) |
|---|
| 92 | |
|---|
| 93 | course1 = schema.Choice( |
|---|
| 94 | title = _(u'1st Choice Course of Study'), |
|---|
| 95 | source = AppCatCertificateSource(), |
|---|
| 96 | required = True, |
|---|
| 97 | ) |
|---|
| 98 | course2 = schema.Choice( |
|---|
| 99 | title = _(u'2nd Choice Course of Study'), |
|---|
| 100 | source = AppCatCertificateSource(), |
|---|
| 101 | required = False, |
|---|
| 102 | ) |
|---|
| 103 | |
|---|
| 104 | fst_sit_fname = schema.TextLine( |
|---|
| 105 | title = _(u'Full Name'), |
|---|
| 106 | required = False, |
|---|
| 107 | readonly = False, |
|---|
| 108 | ) |
|---|
| 109 | |
|---|
| 110 | fst_sit_no = schema.TextLine( |
|---|
| 111 | title = _(u'Exam Number'), |
|---|
| 112 | required = False, |
|---|
| 113 | readonly = False, |
|---|
| 114 | ) |
|---|
| 115 | |
|---|
| 116 | fst_sit_date = FormattedDate( |
|---|
| 117 | title = _(u'Exam Date'), |
|---|
| 118 | required = False, |
|---|
| 119 | readonly = False, |
|---|
| 120 | show_year = True, |
|---|
| 121 | ) |
|---|
| 122 | |
|---|
| 123 | fst_sit_type = schema.Choice( |
|---|
| 124 | title = _(u'Exam Type'), |
|---|
| 125 | required = False, |
|---|
| 126 | readonly = False, |
|---|
| 127 | vocabulary = exam_types, |
|---|
| 128 | ) |
|---|
| 129 | |
|---|
| 130 | fst_sit_results = schema.List( |
|---|
| 131 | title = _(u'Exam Results'), |
|---|
| 132 | value_type = ResultEntryField(), |
|---|
| 133 | required = False, |
|---|
| 134 | readonly = False, |
|---|
| 135 | defaultFactory=list, |
|---|
| 136 | ) |
|---|
| 137 | |
|---|
| 138 | scd_sit_fname = schema.TextLine( |
|---|
| 139 | title = _(u'Full Name'), |
|---|
| 140 | required = False, |
|---|
| 141 | readonly = False, |
|---|
| 142 | ) |
|---|
| 143 | |
|---|
| 144 | scd_sit_no = schema.TextLine( |
|---|
| 145 | title = _(u'Exam Number'), |
|---|
| 146 | required = False, |
|---|
| 147 | readonly = False, |
|---|
| 148 | ) |
|---|
| 149 | |
|---|
| 150 | scd_sit_date = FormattedDate( |
|---|
| 151 | title = _(u'Exam Date'), |
|---|
| 152 | required = False, |
|---|
| 153 | readonly = False, |
|---|
| 154 | show_year = True, |
|---|
| 155 | ) |
|---|
| 156 | |
|---|
| 157 | scd_sit_type = schema.Choice( |
|---|
| 158 | title = _(u'Exam Type'), |
|---|
| 159 | required = False, |
|---|
| 160 | readonly = False, |
|---|
| 161 | vocabulary = exam_types, |
|---|
| 162 | ) |
|---|
| 163 | |
|---|
| 164 | scd_sit_results = schema.List( |
|---|
| 165 | title = _(u'Exam Results'), |
|---|
| 166 | value_type = ResultEntryField(), |
|---|
| 167 | required = False, |
|---|
| 168 | readonly = False, |
|---|
| 169 | defaultFactory=list, |
|---|
| 170 | ) |
|---|
| 171 | |
|---|
| 172 | programme_type = schema.Choice( |
|---|
| 173 | title = _(u'Programme Type'), |
|---|
| 174 | vocabulary = programme_types_vocab, |
|---|
| 175 | required = False, |
|---|
| 176 | ) |
|---|
| 177 | |
|---|
| 178 | hq_type = schema.Choice( |
|---|
| 179 | title = _(u'Qualification Obtained'), |
|---|
| 180 | required = False, |
|---|
| 181 | readonly = False, |
|---|
| 182 | vocabulary = high_qual, |
|---|
| 183 | ) |
|---|
| 184 | hq_matric_no = schema.TextLine( |
|---|
| 185 | title = _(u'Former Matric Number'), |
|---|
| 186 | required = False, |
|---|
| 187 | readonly = False, |
|---|
| 188 | ) |
|---|
| 189 | hq_degree = schema.Choice( |
|---|
| 190 | title = _(u'Class of Degree'), |
|---|
| 191 | required = False, |
|---|
| 192 | readonly = False, |
|---|
| 193 | vocabulary = high_grade, |
|---|
| 194 | ) |
|---|
| 195 | hq_school = schema.TextLine( |
|---|
| 196 | title = _(u'Institution Attended'), |
|---|
| 197 | required = False, |
|---|
| 198 | readonly = False, |
|---|
| 199 | ) |
|---|
| 200 | hq_session = schema.TextLine( |
|---|
| 201 | title = _(u'Year Attended'), |
|---|
| 202 | required = False, |
|---|
| 203 | readonly = False, |
|---|
| 204 | ) |
|---|
| 205 | hq_disc = schema.TextLine( |
|---|
| 206 | title = _(u'Discipline'), |
|---|
| 207 | required = False, |
|---|
| 208 | readonly = False, |
|---|
| 209 | ) |
|---|
| 210 | jamb_reg_number = schema.TextLine( |
|---|
| 211 | title = _(u'JAMB Registration Number'), |
|---|
| 212 | required = False, |
|---|
| 213 | constraint=validate_jamb_reg_number, |
|---|
| 214 | ) |
|---|
| 215 | jamb_subjects = schema.Text( |
|---|
| 216 | title = _(u'Subjects and Scores'), |
|---|
| 217 | required = False, |
|---|
| 218 | ) |
|---|
| 219 | #jamb_subjects_list = schema.List( |
|---|
| 220 | # title = _(u'JAMB Subjects'), |
|---|
| 221 | # required = False, |
|---|
| 222 | # defaultFactory=list, |
|---|
| 223 | # value_type = schema.Choice( |
|---|
| 224 | # vocabulary = jambsubjects |
|---|
| 225 | # #source = JAMBSubjectSource(), |
|---|
| 226 | # ), |
|---|
| 227 | # ) |
|---|
| 228 | jamb_score = schema.Int( |
|---|
| 229 | title = _(u'Total JAMB Score'), |
|---|
| 230 | required = False, |
|---|
| 231 | ) |
|---|
| 232 | #jamb_age = schema.Int( |
|---|
| 233 | # title = _(u'Age (provided by JAMB)'), |
|---|
| 234 | # required = False, |
|---|
| 235 | # ) |
|---|
| 236 | notice = schema.Text( |
|---|
| 237 | title = _(u'Notice'), |
|---|
| 238 | required = False, |
|---|
| 239 | ) |
|---|
| 240 | screening_venue = schema.TextLine( |
|---|
| 241 | title = _(u'Screening Venue'), |
|---|
| 242 | required = False, |
|---|
| 243 | ) |
|---|
| 244 | screening_date = schema.TextLine( |
|---|
| 245 | title = _(u'Screening Date'), |
|---|
| 246 | required = False, |
|---|
| 247 | ) |
|---|
| 248 | screening_score = schema.Float( |
|---|
| 249 | title = _(u'Screening Score (%)'), |
|---|
| 250 | required = False, |
|---|
| 251 | ) |
|---|
| 252 | aggregate = schema.Float( |
|---|
| 253 | title = _(u'Aggregate Score (%)'), |
|---|
| 254 | description = _(u'(average of relative JAMB and PUTME scores)'), |
|---|
| 255 | required = False, |
|---|
| 256 | ) |
|---|
| 257 | result_uploaded = schema.Bool( |
|---|
| 258 | title = _(u'Result uploaded'), |
|---|
| 259 | default = False, |
|---|
| 260 | required = False, |
|---|
| 261 | ) |
|---|
| 262 | student_id = schema.TextLine( |
|---|
| 263 | title = _(u'Student Id'), |
|---|
| 264 | required = False, |
|---|
| 265 | readonly = False, |
|---|
| 266 | ) |
|---|
| 267 | course_admitted = schema.Choice( |
|---|
| 268 | title = _(u'Admitted Course of Study'), |
|---|
| 269 | source = CertificateSource(), |
|---|
| 270 | required = False, |
|---|
| 271 | ) |
|---|
| 272 | locked = schema.Bool( |
|---|
| 273 | title = _(u'Form locked'), |
|---|
| 274 | default = False, |
|---|
| 275 | required = False, |
|---|
| 276 | ) |
|---|
| 277 | |
|---|
| 278 | class ICustomPGApplicant(IApplicantBaseData): |
|---|
| 279 | """A postgraduate applicant. |
|---|
| 280 | """ |
|---|
| 281 | |
|---|
| 282 | nationality = schema.Choice( |
|---|
| 283 | source = nats_vocab, |
|---|
| 284 | title = _(u'Nationality'), |
|---|
| 285 | required = True, |
|---|
| 286 | ) |
|---|
| 287 | lga = schema.Choice( |
|---|
| 288 | source = LGASource(), |
|---|
| 289 | title = _(u'State/LGA (Nigerians only)'), |
|---|
| 290 | required = False, |
|---|
| 291 | ) |
|---|
| 292 | #perm_address = schema.Text( |
|---|
| 293 | # title = _(u'Permanent Address'), |
|---|
| 294 | # required = False, |
|---|
| 295 | # ) |
|---|
| 296 | course1 = schema.Choice( |
|---|
| 297 | title = _(u'1st Choice Course of Study'), |
|---|
| 298 | source = AppCatCertificateSource(), |
|---|
| 299 | required = True, |
|---|
| 300 | ) |
|---|
| 301 | course2 = schema.Choice( |
|---|
| 302 | title = _(u'2nd Choice Course of Study'), |
|---|
| 303 | source = AppCatCertificateSource(), |
|---|
| 304 | required = False, |
|---|
| 305 | ) |
|---|
| 306 | hq_type = schema.Choice( |
|---|
| 307 | title = _(u'Qualification Obtained'), |
|---|
| 308 | required = False, |
|---|
| 309 | readonly = False, |
|---|
| 310 | vocabulary = high_qual, |
|---|
| 311 | ) |
|---|
| 312 | hq_fname = schema.TextLine( |
|---|
| 313 | title = _(u'Full Name'), |
|---|
| 314 | required = False, |
|---|
| 315 | readonly = False, |
|---|
| 316 | ) |
|---|
| 317 | hq_matric_no = schema.TextLine( |
|---|
| 318 | title = _(u'Former Matric Number'), |
|---|
| 319 | required = False, |
|---|
| 320 | readonly = False, |
|---|
| 321 | ) |
|---|
| 322 | hq_degree = schema.Choice( |
|---|
| 323 | title = _(u'Class of Degree'), |
|---|
| 324 | required = False, |
|---|
| 325 | readonly = False, |
|---|
| 326 | vocabulary = high_grade, |
|---|
| 327 | ) |
|---|
| 328 | hq_school = schema.TextLine( |
|---|
| 329 | title = _(u'Institution Attended'), |
|---|
| 330 | required = False, |
|---|
| 331 | readonly = False, |
|---|
| 332 | ) |
|---|
| 333 | hq_session = schema.TextLine( |
|---|
| 334 | title = _(u'Year Attended'), |
|---|
| 335 | required = False, |
|---|
| 336 | readonly = False, |
|---|
| 337 | ) |
|---|
| 338 | hq_disc = schema.TextLine( |
|---|
| 339 | title = _(u'Discipline'), |
|---|
| 340 | required = False, |
|---|
| 341 | readonly = False, |
|---|
| 342 | ) |
|---|
| 343 | |
|---|
| 344 | presently_inst = schema.TextLine( |
|---|
| 345 | title = _(u'If yes, name of institution'), |
|---|
| 346 | required = False, |
|---|
| 347 | readonly = False, |
|---|
| 348 | ) |
|---|
| 349 | nysc_year = schema.Int( |
|---|
| 350 | title = _(u'Nysc Year'), |
|---|
| 351 | required = False, |
|---|
| 352 | readonly = False, |
|---|
| 353 | ) |
|---|
| 354 | nysc_lga = schema.Choice( |
|---|
| 355 | source = LGASource(), |
|---|
| 356 | title = _(u'Nysc Location'), |
|---|
| 357 | description = _(u'Leave blank for exception letters.'), |
|---|
| 358 | required = False, |
|---|
| 359 | ) |
|---|
| 360 | notice = schema.Text( |
|---|
| 361 | title = _(u'Notice'), |
|---|
| 362 | required = False, |
|---|
| 363 | readonly = False, |
|---|
| 364 | ) |
|---|
| 365 | screening_venue = schema.TextLine( |
|---|
| 366 | title = _(u'Screening Venue'), |
|---|
| 367 | required = False, |
|---|
| 368 | ) |
|---|
| 369 | screening_date = schema.TextLine( |
|---|
| 370 | title = _(u'Screening Date'), |
|---|
| 371 | required = False, |
|---|
| 372 | ) |
|---|
| 373 | screening_score = schema.Float( |
|---|
| 374 | title = _(u'Screening Score (%)'), |
|---|
| 375 | required = False, |
|---|
| 376 | ) |
|---|
| 377 | student_id = schema.TextLine( |
|---|
| 378 | title = _(u'Student Id'), |
|---|
| 379 | required = False, |
|---|
| 380 | readonly = False, |
|---|
| 381 | ) |
|---|
| 382 | course_admitted = schema.Choice( |
|---|
| 383 | title = _(u'Admitted Course of Study'), |
|---|
| 384 | source = CertificateSource(), |
|---|
| 385 | required = False, |
|---|
| 386 | readonly = False, |
|---|
| 387 | ) |
|---|
| 388 | locked = schema.Bool( |
|---|
| 389 | title = _(u'Form locked'), |
|---|
| 390 | default = False, |
|---|
| 391 | required = False, |
|---|
| 392 | ) |
|---|
| 393 | |
|---|
| 394 | referees = schema.List( |
|---|
| 395 | title = _(u'Referees'), |
|---|
| 396 | value_type = RefereeEntryField(), |
|---|
| 397 | description = _(u'Maximum 3 referees'), |
|---|
| 398 | required = True, |
|---|
| 399 | defaultFactory=list, |
|---|
| 400 | ) |
|---|
| 401 | |
|---|
| 402 | class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant): |
|---|
| 403 | """An interface for both types of applicants. |
|---|
| 404 | |
|---|
| 405 | Attention: The ICustomPGApplicant field seetings will be overwritten |
|---|
| 406 | by ICustomPGApplicant field settings. If a field is defined |
|---|
| 407 | in both interfaces zope.schema validates only against the |
|---|
| 408 | constraints in ICustomUGApplicant. This does not affect the forms |
|---|
| 409 | since they are build on either ICustomUGApplicant or ICustomPGApplicant. |
|---|
| 410 | """ |
|---|
| 411 | |
|---|
| 412 | def writeLogMessage(view, comment): |
|---|
| 413 | """Adds an INFO message to the log file |
|---|
| 414 | """ |
|---|
| 415 | |
|---|
| 416 | def createStudent(): |
|---|
| 417 | """Create a student object from applicant data |
|---|
| 418 | and copy applicant object. |
|---|
| 419 | """ |
|---|
| 420 | |
|---|
| 421 | class ICustomUGApplicantEdit(ICustomUGApplicant): |
|---|
| 422 | """An undergraduate applicant interface for edit forms. |
|---|
| 423 | |
|---|
| 424 | Here we can repeat the fields from base data and set the |
|---|
| 425 | `required` and `readonly` attributes to True to further restrict |
|---|
| 426 | the data access. Or we can allow only certain certificates to be |
|---|
| 427 | selected by choosing the appropriate source. |
|---|
| 428 | |
|---|
| 429 | We cannot omit fields here. This has to be done in the |
|---|
| 430 | respective form page. |
|---|
| 431 | """ |
|---|
| 432 | |
|---|
| 433 | class ICustomPGApplicantEdit(ICustomPGApplicant): |
|---|
| 434 | """A postgraduate applicant interface for editing. |
|---|
| 435 | |
|---|
| 436 | Here we can repeat the fields from base data and set the |
|---|
| 437 | `required` and `readonly` attributes to True to further restrict |
|---|
| 438 | the data access. Or we can allow only certain certificates to be |
|---|
| 439 | selected by choosing the appropriate source. |
|---|
| 440 | |
|---|
| 441 | We cannot omit fields here. This has to be done in the |
|---|
| 442 | respective form page. |
|---|
| 443 | """ |
|---|
| 444 | |
|---|
| 445 | |
|---|
| 446 | class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment): |
|---|
| 447 | """An applicant payment via payment gateways. |
|---|
| 448 | |
|---|
| 449 | """ |
|---|
| 450 | |
|---|
| 451 | class IPUTMEApplicantEdit(IPUTMEApplicantEdit): |
|---|
| 452 | """An undergraduate applicant interface for editing. |
|---|
| 453 | |
|---|
| 454 | Here we can repeat the fields from base data and set the |
|---|
| 455 | `required` and `readonly` attributes to True to further restrict |
|---|
| 456 | the data access. Or we can allow only certain certificates to be |
|---|
| 457 | selected by choosing the appropriate source. |
|---|
| 458 | |
|---|
| 459 | We cannot omit fields here. This has to be done in the |
|---|
| 460 | respective form page. |
|---|
| 461 | """ |
|---|
| 462 | |
|---|
| 463 | class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo): |
|---|
| 464 | """Representation of an applicant. |
|---|
| 465 | |
|---|
| 466 | Skip regular reg_number validation if reg_number is used for finding |
|---|
| 467 | the applicant object. |
|---|
| 468 | """ |
|---|