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