[7853] | 1 | ## $Id: interfaces.py 14499 2017-02-03 07:54:44Z 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 | |
---|
[8012] | 21 | from zope import schema |
---|
[13877] | 22 | from zc.sourcefactory.basic import BasicSourceFactory |
---|
[8051] | 23 | from waeup.kofa.applicants.interfaces import ( |
---|
[8053] | 24 | IApplicantBaseData, |
---|
[8051] | 25 | AppCatCertificateSource, CertificateSource) |
---|
| 26 | from waeup.kofa.schoolgrades import ResultEntryField |
---|
[8531] | 27 | from waeup.kofa.interfaces import ( |
---|
[13877] | 28 | SimpleKofaVocabulary, academic_sessions_vocab, validate_email, |
---|
| 29 | IKofaObject) |
---|
| 30 | from waeup.kofa.schema import FormattedDate, TextLineChoice, PhoneNumber |
---|
[9465] | 31 | from waeup.kofa.schoolgrades import ResultEntryField |
---|
[8531] | 32 | from waeup.kofa.students.vocabularies import nats_vocab, GenderSource |
---|
| 33 | from waeup.kofa.applicants.interfaces import contextual_reg_num_source |
---|
[8933] | 34 | from kofacustom.nigeria.applicants.interfaces import ( |
---|
| 35 | LGASource, high_qual, high_grade, exam_types, |
---|
| 36 | INigeriaUGApplicant, INigeriaPGApplicant, |
---|
| 37 | INigeriaApplicantOnlinePayment, |
---|
[9497] | 38 | INigeriaUGApplicantEdit, |
---|
[8979] | 39 | INigeriaApplicantUpdateByRegNo, |
---|
| 40 | IPUTMEApplicantEdit, |
---|
[9463] | 41 | OMIT_DISPLAY_FIELDS |
---|
[8933] | 42 | ) |
---|
[13877] | 43 | from waeup.fceokene.applicants.schools import SCHOOLS |
---|
[8460] | 44 | from waeup.fceokene.interfaces import MessageFactory as _ |
---|
[7853] | 45 | |
---|
[9463] | 46 | BEC_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS |
---|
| 47 | BEC_OMIT_PDF_FIELDS = BEC_OMIT_DISPLAY_FIELDS + ('phone',) |
---|
[10852] | 48 | BEC_OMIT_MANAGE_FIELDS = ('special_application',) |
---|
[9463] | 49 | BEC_OMIT_EDIT_FIELDS = BEC_OMIT_MANAGE_FIELDS + OMIT_DISPLAY_FIELDS + ( |
---|
| 50 | 'student_id', 'notice', |
---|
| 51 | 'screening_score', |
---|
| 52 | 'screening_venue', |
---|
| 53 | 'screening_date', |
---|
| 54 | #'jamb_subjects', |
---|
| 55 | #'jamb_score', |
---|
| 56 | 'aggregate') |
---|
| 57 | |
---|
[13877] | 58 | class SchoolSource(BasicSourceFactory): |
---|
[14499] | 59 | """A source that delivers all kinds of schools. |
---|
[13877] | 60 | """ |
---|
| 61 | def getValues(self): |
---|
[14067] | 62 | sorted_items = sorted( |
---|
| 63 | SCHOOLS.items(), |
---|
| 64 | key=lambda element: element[1][0] + element[1][1] +element[1][2]) |
---|
[13877] | 65 | return [item[0] for item in sorted_items] |
---|
| 66 | |
---|
[14499] | 67 | def getToken(self, value): |
---|
| 68 | return value |
---|
| 69 | |
---|
[13877] | 70 | def getTitle(self, value): |
---|
| 71 | return u"%s: %s -- %s" % ( |
---|
| 72 | SCHOOLS[value][0], |
---|
| 73 | SCHOOLS[value][1], |
---|
| 74 | SCHOOLS[value][2],) |
---|
| 75 | |
---|
| 76 | class ITPURegistration(IKofaObject): |
---|
| 77 | """A TPU registrant. |
---|
| 78 | """ |
---|
| 79 | |
---|
| 80 | suspended = schema.Bool( |
---|
| 81 | title = _(u'Account suspended'), |
---|
| 82 | default = False, |
---|
| 83 | required = False, |
---|
| 84 | ) |
---|
| 85 | |
---|
| 86 | locked = schema.Bool( |
---|
| 87 | title = _(u'Form locked'), |
---|
| 88 | default = False, |
---|
| 89 | required = False, |
---|
| 90 | ) |
---|
| 91 | |
---|
| 92 | applicant_id = schema.TextLine( |
---|
| 93 | title = _(u'Applicant Id'), |
---|
| 94 | required = False, |
---|
| 95 | readonly = False, |
---|
| 96 | ) |
---|
| 97 | |
---|
| 98 | reg_number = schema.TextLine( |
---|
| 99 | title = _(u'Registration Number'), |
---|
| 100 | required = False, |
---|
| 101 | readonly = False, |
---|
| 102 | ) |
---|
| 103 | |
---|
| 104 | matric_number = schema.TextLine( |
---|
| 105 | title = _(u'Matriculation Number'), |
---|
| 106 | required = False, |
---|
| 107 | readonly = False, |
---|
| 108 | ) |
---|
| 109 | |
---|
| 110 | firstname = schema.TextLine( |
---|
| 111 | title = _(u'First Name'), |
---|
| 112 | required = True, |
---|
| 113 | ) |
---|
| 114 | |
---|
| 115 | middlename = schema.TextLine( |
---|
| 116 | title = _(u'Middle Name'), |
---|
| 117 | required = False, |
---|
| 118 | ) |
---|
| 119 | |
---|
| 120 | lastname = schema.TextLine( |
---|
| 121 | title = _(u'Last Name (Surname)'), |
---|
| 122 | required = True, |
---|
| 123 | ) |
---|
| 124 | |
---|
| 125 | email = schema.ASCIILine( |
---|
| 126 | title = _(u'Email Address'), |
---|
| 127 | required = True, |
---|
| 128 | constraint=validate_email, |
---|
| 129 | ) |
---|
| 130 | |
---|
| 131 | phone = PhoneNumber( |
---|
| 132 | title = _(u'Phone'), |
---|
| 133 | description = u'', |
---|
| 134 | required = False, |
---|
| 135 | ) |
---|
| 136 | |
---|
| 137 | perm_address = schema.Text( |
---|
| 138 | title = _(u'Home Address'), |
---|
| 139 | required = False, |
---|
| 140 | readonly = False, |
---|
| 141 | ) |
---|
| 142 | |
---|
| 143 | lga = schema.Choice( |
---|
| 144 | source = LGASource(), |
---|
| 145 | title = _(u'State/LGA'), |
---|
| 146 | required = False, |
---|
| 147 | ) |
---|
| 148 | |
---|
| 149 | subj_comb = schema.TextLine( |
---|
| 150 | title = _(u'Subject Combination'), |
---|
| 151 | required = False, |
---|
| 152 | readonly = False, |
---|
| 153 | ) |
---|
| 154 | |
---|
| 155 | school1 = schema.Choice( |
---|
| 156 | title = _(u'1st Choice TPZ and School'), |
---|
| 157 | source = SchoolSource(), |
---|
[14499] | 158 | required = True, |
---|
[13877] | 159 | ) |
---|
| 160 | |
---|
| 161 | school2 = schema.Choice( |
---|
| 162 | title = _(u'2nd Choice TPZ and School'), |
---|
| 163 | source = SchoolSource(), |
---|
[13883] | 164 | required = False, |
---|
[13877] | 165 | ) |
---|
| 166 | |
---|
| 167 | school3 = schema.Choice( |
---|
| 168 | title = _(u'3rd Choice TPZ and School'), |
---|
| 169 | source = SchoolSource(), |
---|
[13883] | 170 | required = False, |
---|
[13877] | 171 | ) |
---|
| 172 | |
---|
[8933] | 173 | class ICustomUGApplicant(INigeriaUGApplicant): |
---|
[8012] | 174 | """An undergraduate applicant. |
---|
| 175 | |
---|
[8520] | 176 | This interface defines the least common multiple of all fields |
---|
| 177 | in ug application forms. In customized forms, fields can be excluded by |
---|
[9463] | 178 | adding them to the OMIT* tuples. |
---|
[8012] | 179 | """ |
---|
| 180 | |
---|
[9465] | 181 | nationality = schema.Choice( |
---|
| 182 | source = nats_vocab, |
---|
| 183 | title = _(u'Nationality'), |
---|
| 184 | required = True, |
---|
| 185 | ) |
---|
| 186 | lga = schema.Choice( |
---|
| 187 | source = LGASource(), |
---|
| 188 | title = _(u'State/LGA (Nigerians only)'), |
---|
| 189 | required = False, |
---|
| 190 | ) |
---|
| 191 | #perm_address = schema.Text( |
---|
| 192 | # title = _(u'Permanent Address'), |
---|
| 193 | # required = False, |
---|
| 194 | # ) |
---|
| 195 | course1 = schema.Choice( |
---|
| 196 | title = _(u'1st Choice Course of Study'), |
---|
| 197 | source = AppCatCertificateSource(), |
---|
[13884] | 198 | required = False, |
---|
[9465] | 199 | ) |
---|
| 200 | course2 = schema.Choice( |
---|
| 201 | title = _(u'2nd Choice Course of Study'), |
---|
| 202 | source = AppCatCertificateSource(), |
---|
| 203 | required = False, |
---|
| 204 | ) |
---|
[9463] | 205 | olevel_type = schema.Choice( |
---|
[9500] | 206 | title = _(u'1st Qualification Obtained'), |
---|
[9463] | 207 | required = False, |
---|
| 208 | readonly = False, |
---|
[9465] | 209 | vocabulary = exam_types, |
---|
| 210 | ) |
---|
| 211 | olevel_school = schema.TextLine( |
---|
[9500] | 212 | title = _(u'1st Institution Attended'), |
---|
[9465] | 213 | required = False, |
---|
| 214 | readonly = False, |
---|
| 215 | ) |
---|
| 216 | olevel_exam_number = schema.TextLine( |
---|
[9500] | 217 | title = _(u'1st Exam Number'), |
---|
[9465] | 218 | required = False, |
---|
| 219 | readonly = False, |
---|
| 220 | ) |
---|
| 221 | olevel_exam_date = FormattedDate( |
---|
[9500] | 222 | title = _(u'1st Exam Date'), |
---|
[9465] | 223 | required = False, |
---|
| 224 | readonly = False, |
---|
| 225 | show_year = True, |
---|
| 226 | ) |
---|
| 227 | olevel_results = schema.List( |
---|
[9500] | 228 | title = _(u'1st Exam Results'), |
---|
[9465] | 229 | value_type = ResultEntryField(), |
---|
| 230 | required = False, |
---|
| 231 | readonly = False, |
---|
[14018] | 232 | defaultFactory=list, |
---|
[9465] | 233 | ) |
---|
[9500] | 234 | olevel_type2 = schema.Choice( |
---|
| 235 | title = _(u'2nd Qualification Obtained'), |
---|
| 236 | required = False, |
---|
| 237 | readonly = False, |
---|
| 238 | vocabulary = exam_types, |
---|
| 239 | ) |
---|
| 240 | olevel_school2 = schema.TextLine( |
---|
| 241 | title = _(u'2nd Institution Attended'), |
---|
| 242 | required = False, |
---|
| 243 | readonly = False, |
---|
| 244 | ) |
---|
| 245 | olevel_exam_number2 = schema.TextLine( |
---|
| 246 | title = _(u'2nd Exam Number'), |
---|
| 247 | required = False, |
---|
| 248 | readonly = False, |
---|
| 249 | ) |
---|
| 250 | olevel_exam_date2 = FormattedDate( |
---|
| 251 | title = _(u'2nd Exam Date'), |
---|
| 252 | required = False, |
---|
| 253 | readonly = False, |
---|
| 254 | show_year = True, |
---|
| 255 | ) |
---|
| 256 | olevel_results2 = schema.List( |
---|
| 257 | title = _(u'2nd Exam Results'), |
---|
| 258 | value_type = ResultEntryField(), |
---|
| 259 | required = False, |
---|
| 260 | readonly = False, |
---|
[14018] | 261 | defaultFactory=list, |
---|
[9500] | 262 | ) |
---|
[9465] | 263 | hq_type = schema.Choice( |
---|
| 264 | title = _(u'Qualification Obtained'), |
---|
| 265 | required = False, |
---|
| 266 | readonly = False, |
---|
[9463] | 267 | vocabulary = high_qual, |
---|
| 268 | ) |
---|
[9465] | 269 | hq_matric_no = schema.TextLine( |
---|
[9463] | 270 | title = _(u'Former Matric Number'), |
---|
| 271 | required = False, |
---|
| 272 | readonly = False, |
---|
| 273 | ) |
---|
[9465] | 274 | hq_degree = schema.Choice( |
---|
[9463] | 275 | title = _(u'Class of Degree'), |
---|
| 276 | required = False, |
---|
| 277 | readonly = False, |
---|
| 278 | vocabulary = high_grade, |
---|
| 279 | ) |
---|
[9465] | 280 | hq_school = schema.TextLine( |
---|
[9463] | 281 | title = _(u'Institution Attended'), |
---|
| 282 | required = False, |
---|
| 283 | readonly = False, |
---|
| 284 | ) |
---|
[9465] | 285 | hq_session = schema.TextLine( |
---|
[9463] | 286 | title = _(u'Years Attended'), |
---|
| 287 | required = False, |
---|
| 288 | readonly = False, |
---|
| 289 | ) |
---|
[9465] | 290 | hq_disc = schema.TextLine( |
---|
[9463] | 291 | title = _(u'Discipline'), |
---|
| 292 | required = False, |
---|
| 293 | readonly = False, |
---|
| 294 | ) |
---|
[9465] | 295 | jamb_subjects = schema.Text( |
---|
| 296 | title = _(u'Subjects and Scores'), |
---|
[10533] | 297 | description = _(u'(one subject with score per line)'), |
---|
[9465] | 298 | required = False, |
---|
| 299 | ) |
---|
| 300 | jamb_score = schema.Int( |
---|
| 301 | title = _(u'Total JAMB Score'), |
---|
| 302 | required = False, |
---|
| 303 | ) |
---|
[10500] | 304 | jamb_reg_number = schema.TextLine( |
---|
| 305 | title = _(u'JAMB Registration Number'), |
---|
| 306 | required = False, |
---|
| 307 | ) |
---|
[9465] | 308 | notice = schema.Text( |
---|
| 309 | title = _(u'Notice'), |
---|
| 310 | required = False, |
---|
| 311 | ) |
---|
| 312 | screening_venue = schema.TextLine( |
---|
| 313 | title = _(u'Screening Venue'), |
---|
| 314 | required = False, |
---|
| 315 | ) |
---|
| 316 | screening_date = schema.TextLine( |
---|
| 317 | title = _(u'Screening Date'), |
---|
| 318 | required = False, |
---|
| 319 | ) |
---|
| 320 | screening_score = schema.Int( |
---|
| 321 | title = _(u'Screening Score (%)'), |
---|
| 322 | required = False, |
---|
| 323 | ) |
---|
| 324 | aggregate = schema.Int( |
---|
| 325 | title = _(u'Aggregate Score (%)'), |
---|
| 326 | description = _(u'(average of relative JAMB and PUTME scores)'), |
---|
| 327 | required = False, |
---|
| 328 | ) |
---|
| 329 | result_uploaded = schema.Bool( |
---|
| 330 | title = _(u'Result uploaded'), |
---|
| 331 | default = False, |
---|
[14335] | 332 | required = False, |
---|
[9465] | 333 | ) |
---|
| 334 | student_id = schema.TextLine( |
---|
| 335 | title = _(u'Student Id'), |
---|
| 336 | required = False, |
---|
| 337 | readonly = False, |
---|
| 338 | ) |
---|
| 339 | course_admitted = schema.Choice( |
---|
| 340 | title = _(u'Admitted Course of Study'), |
---|
| 341 | source = CertificateSource(), |
---|
| 342 | required = False, |
---|
| 343 | ) |
---|
| 344 | locked = schema.Bool( |
---|
| 345 | title = _(u'Form locked'), |
---|
| 346 | default = False, |
---|
[14335] | 347 | required = False, |
---|
[9465] | 348 | ) |
---|
[9463] | 349 | |
---|
| 350 | |
---|
[8933] | 351 | class ICustomPGApplicant(INigeriaPGApplicant): |
---|
[7853] | 352 | """A postgraduate applicant. |
---|
| 353 | |
---|
[8520] | 354 | This interface defines the least common multiple of all fields |
---|
| 355 | in pg application forms. In customized forms, fields can be excluded by |
---|
| 356 | adding them to the PG_OMIT* tuples. |
---|
[7866] | 357 | """ |
---|
| 358 | |
---|
[13877] | 359 | class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant, |
---|
| 360 | ITPURegistration): |
---|
| 361 | """An interface for all types of applicants. |
---|
[8012] | 362 | |
---|
[8933] | 363 | Attention: The ICustomPGApplicant field seetings will be overwritten |
---|
| 364 | by ICustomPGApplicant field settings. If a field is defined |
---|
[8729] | 365 | in both interfaces zope.schema validates only against the |
---|
[8933] | 366 | constraints in ICustomUGApplicant. This does not affect the forms |
---|
| 367 | since they are build on either ICustomUGApplicant or ICustomPGApplicant. |
---|
[8012] | 368 | """ |
---|
| 369 | |
---|
[8745] | 370 | def writeLogMessage(view, comment): |
---|
[8053] | 371 | """Adds an INFO message to the log file |
---|
| 372 | """ |
---|
| 373 | |
---|
| 374 | def createStudent(): |
---|
| 375 | """Create a student object from applicatnt data |
---|
| 376 | and copy applicant object. |
---|
| 377 | """ |
---|
| 378 | |
---|
[9497] | 379 | class ICustomUGApplicantEdit(ICustomUGApplicant): |
---|
[8729] | 380 | """An undergraduate applicant interface for edit forms. |
---|
[8012] | 381 | |
---|
| 382 | Here we can repeat the fields from base data and set the |
---|
| 383 | `required` and `readonly` attributes to True to further restrict |
---|
| 384 | the data access. Or we can allow only certain certificates to be |
---|
| 385 | selected by choosing the appropriate source. |
---|
| 386 | |
---|
| 387 | We cannot omit fields here. This has to be done in the |
---|
| 388 | respective form page. |
---|
| 389 | """ |
---|
| 390 | |
---|
[9497] | 391 | |
---|
| 392 | email = schema.ASCIILine( |
---|
| 393 | title = _(u'Email Address'), |
---|
| 394 | required = True, |
---|
| 395 | constraint=validate_email, |
---|
| 396 | ) |
---|
| 397 | date_of_birth = FormattedDate( |
---|
| 398 | title = _(u'Date of Birth'), |
---|
| 399 | required = True, |
---|
| 400 | show_year = True, |
---|
| 401 | ) |
---|
[11776] | 402 | jamb_reg_number = schema.TextLine( |
---|
| 403 | title = _(u'JAMB Registration Number'), |
---|
| 404 | required = True, |
---|
| 405 | ) |
---|
[13884] | 406 | course1 = schema.Choice( |
---|
| 407 | title = _(u'1st Choice Course of Study'), |
---|
| 408 | source = AppCatCertificateSource(), |
---|
| 409 | required = True, |
---|
| 410 | ) |
---|
[9497] | 411 | |
---|
[10500] | 412 | ICustomUGApplicantEdit[ |
---|
| 413 | 'date_of_birth'].order = ICustomUGApplicant['date_of_birth'].order |
---|
| 414 | ICustomUGApplicantEdit[ |
---|
| 415 | 'email'].order = ICustomUGApplicant['email'].order |
---|
| 416 | ICustomUGApplicantEdit[ |
---|
[13238] | 417 | 'jamb_reg_number'].order = ICustomUGApplicant['jamb_reg_number'].order |
---|
[13884] | 418 | ICustomUGApplicantEdit[ |
---|
| 419 | 'course1'].order = ICustomUGApplicant['course1'].order |
---|
[10500] | 420 | |
---|
[9497] | 421 | class ICustomPGApplicantEdit(ICustomPGApplicant): |
---|
[7866] | 422 | """A postgraduate applicant interface for editing. |
---|
| 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. |
---|
[8017] | 431 | """ |
---|
[8454] | 432 | |
---|
[9497] | 433 | email = schema.ASCIILine( |
---|
| 434 | title = _(u'Email Address'), |
---|
| 435 | required = True, |
---|
| 436 | constraint=validate_email, |
---|
| 437 | ) |
---|
| 438 | date_of_birth = FormattedDate( |
---|
| 439 | title = _(u'Date of Birth'), |
---|
| 440 | required = True, |
---|
| 441 | show_year = True, |
---|
| 442 | ) |
---|
| 443 | |
---|
[10500] | 444 | ICustomPGApplicantEdit[ |
---|
| 445 | 'date_of_birth'].order = ICustomPGApplicant['date_of_birth'].order |
---|
| 446 | ICustomPGApplicantEdit[ |
---|
| 447 | 'email'].order = ICustomPGApplicant['email'].order |
---|
| 448 | |
---|
| 449 | |
---|
[8933] | 450 | class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment): |
---|
[8247] | 451 | """An applicant payment via payment gateways. |
---|
| 452 | |
---|
| 453 | """ |
---|
[8531] | 454 | |
---|
[8979] | 455 | class IPUTMEApplicantEdit(IPUTMEApplicantEdit): |
---|
[8531] | 456 | """An undergraduate applicant interface for editing. |
---|
| 457 | |
---|
| 458 | Here we can repeat the fields from base data and set the |
---|
| 459 | `required` and `readonly` attributes to True to further restrict |
---|
| 460 | the data access. Or we can allow only certain certificates to be |
---|
| 461 | selected by choosing the appropriate source. |
---|
| 462 | |
---|
| 463 | We cannot omit fields here. This has to be done in the |
---|
| 464 | respective form page. |
---|
| 465 | """ |
---|
| 466 | |
---|
[8979] | 467 | class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo): |
---|
[8584] | 468 | """Representation of an applicant. |
---|
| 469 | |
---|
| 470 | Skip regular reg_number validation if reg_number is used for finding |
---|
| 471 | the applicant object. |
---|
| 472 | """ |
---|
[8979] | 473 | |
---|