| 1 | ## $Id: interfaces.py 18351 2026-10-28 11:39:27Z 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'Years 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(INigeriaPGApplicant): |
|---|
| 279 | """A postgraduate applicant. |
|---|
| 280 | """ |
|---|
| 281 | |
|---|
| 282 | referees = schema.List( |
|---|
| 283 | title = _(u'Referees'), |
|---|
| 284 | value_type = RefereeEntryField(), |
|---|
| 285 | description = _(u'Maximum 3 referees'), |
|---|
| 286 | required = True, |
|---|
| 287 | defaultFactory=list, |
|---|
| 288 | ) |
|---|
| 289 | |
|---|
| 290 | class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant): |
|---|
| 291 | """An interface for both types of applicants. |
|---|
| 292 | |
|---|
| 293 | Attention: The ICustomPGApplicant field seetings will be overwritten |
|---|
| 294 | by ICustomPGApplicant field settings. If a field is defined |
|---|
| 295 | in both interfaces zope.schema validates only against the |
|---|
| 296 | constraints in ICustomUGApplicant. This does not affect the forms |
|---|
| 297 | since they are build on either ICustomUGApplicant or ICustomPGApplicant. |
|---|
| 298 | """ |
|---|
| 299 | |
|---|
| 300 | def writeLogMessage(view, comment): |
|---|
| 301 | """Adds an INFO message to the log file |
|---|
| 302 | """ |
|---|
| 303 | |
|---|
| 304 | def createStudent(): |
|---|
| 305 | """Create a student object from applicant data |
|---|
| 306 | and copy applicant object. |
|---|
| 307 | """ |
|---|
| 308 | |
|---|
| 309 | class ICustomUGApplicantEdit(ICustomUGApplicant): |
|---|
| 310 | """An undergraduate applicant interface for edit forms. |
|---|
| 311 | |
|---|
| 312 | Here we can repeat the fields from base data and set the |
|---|
| 313 | `required` and `readonly` attributes to True to further restrict |
|---|
| 314 | the data access. Or we can allow only certain certificates to be |
|---|
| 315 | selected by choosing the appropriate source. |
|---|
| 316 | |
|---|
| 317 | We cannot omit fields here. This has to be done in the |
|---|
| 318 | respective form page. |
|---|
| 319 | """ |
|---|
| 320 | |
|---|
| 321 | class ICustomPGApplicantEdit(INigeriaPGApplicantEdit): |
|---|
| 322 | """A postgraduate applicant interface for editing. |
|---|
| 323 | |
|---|
| 324 | Here we can repeat the fields from base data and set the |
|---|
| 325 | `required` and `readonly` attributes to True to further restrict |
|---|
| 326 | the data access. Or we can allow only certain certificates to be |
|---|
| 327 | selected by choosing the appropriate source. |
|---|
| 328 | |
|---|
| 329 | We cannot omit fields here. This has to be done in the |
|---|
| 330 | respective form page. |
|---|
| 331 | """ |
|---|
| 332 | |
|---|
| 333 | class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment): |
|---|
| 334 | """An applicant payment via payment gateways. |
|---|
| 335 | |
|---|
| 336 | """ |
|---|
| 337 | |
|---|
| 338 | class IPUTMEApplicantEdit(IPUTMEApplicantEdit): |
|---|
| 339 | """An undergraduate applicant interface for editing. |
|---|
| 340 | |
|---|
| 341 | Here we can repeat the fields from base data and set the |
|---|
| 342 | `required` and `readonly` attributes to True to further restrict |
|---|
| 343 | the data access. Or we can allow only certain certificates to be |
|---|
| 344 | selected by choosing the appropriate source. |
|---|
| 345 | |
|---|
| 346 | We cannot omit fields here. This has to be done in the |
|---|
| 347 | respective form page. |
|---|
| 348 | """ |
|---|
| 349 | |
|---|
| 350 | class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo): |
|---|
| 351 | """Representation of an applicant. |
|---|
| 352 | |
|---|
| 353 | Skip regular reg_number validation if reg_number is used for finding |
|---|
| 354 | the applicant object. |
|---|
| 355 | """ |
|---|