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