[7853] | 1 | ## $Id: interfaces.py 8844 2012-06-28 06:15:15Z 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 |
---|
[8051] | 22 | from waeup.kofa.applicants.interfaces import ( |
---|
[8053] | 23 | IApplicantBaseData, |
---|
[8051] | 24 | AppCatCertificateSource, CertificateSource) |
---|
| 25 | from waeup.kofa.schoolgrades import ResultEntryField |
---|
[8530] | 26 | from waeup.kofa.interfaces import ( |
---|
| 27 | SimpleKofaVocabulary, academic_sessions_vocab, validate_email) |
---|
| 28 | from waeup.kofa.schema import FormattedDate, TextLineChoice |
---|
| 29 | from waeup.kofa.students.vocabularies import nats_vocab, GenderSource |
---|
| 30 | from waeup.kofa.applicants.interfaces import contextual_reg_num_source |
---|
[8821] | 31 | from kofacustom.nigeria.interfaces import ( |
---|
[8502] | 32 | LGASource, high_qual, high_grade, exam_types) |
---|
[8020] | 33 | from waeup.uniben.interfaces import MessageFactory as _ |
---|
[8247] | 34 | from waeup.uniben.payments.interfaces import ICustomOnlinePayment |
---|
[7853] | 35 | |
---|
[8844] | 36 | ############################################################ |
---|
| 37 | # Use former lgas for Uniben. Must be removed after application. |
---|
| 38 | from waeup.uniben.applicants.lgas import LGAS |
---|
| 39 | class LGASource(LGASource): |
---|
| 40 | """A source for school subjects used in exam documentation. |
---|
| 41 | """ |
---|
| 42 | lga_dict = dict(LGAS) |
---|
| 43 | ############################################################ |
---|
| 44 | |
---|
[8803] | 45 | UG_OMIT_DISPLAY_FIELDS = ('locked', 'course_admitted', |
---|
| 46 | 'password', 'result_uploaded') |
---|
[8551] | 47 | UG_OMIT_PDF_FIELDS = UG_OMIT_DISPLAY_FIELDS + ('email', 'phone') |
---|
[8519] | 48 | UG_OMIT_MANAGE_FIELDS = () |
---|
| 49 | UG_OMIT_EDIT_FIELDS = UG_OMIT_MANAGE_FIELDS + ('locked', 'course_admitted', |
---|
[8577] | 50 | 'student_id', 'screening_score', 'screening_venue', 'notice', |
---|
[8803] | 51 | 'screening_date', 'result_uploaded') |
---|
[8530] | 52 | PUTME_OMIT_EDIT_FIELDS = UG_OMIT_EDIT_FIELDS + ( |
---|
| 53 | 'firstname', 'middlename', 'lastname', 'sex', |
---|
[8535] | 54 | 'course1', 'lga', 'jamb_score', 'jamb_subjects') |
---|
[8803] | 55 | UG_OMIT_RESULT_SLIP_FIELDS = UG_OMIT_DISPLAY_FIELDS + ('email', 'phone', |
---|
| 56 | 'date_of_birth', 'sex', |
---|
| 57 | 'nationality', 'lga', 'perm_address', 'course2', 'screening_venue', |
---|
| 58 | 'screening_date') |
---|
[8519] | 59 | |
---|
| 60 | PG_OMIT_DISPLAY_FIELDS = ('locked', 'course_admitted', 'password') |
---|
[8551] | 61 | PG_OMIT_PDF_FIELDS = UG_OMIT_DISPLAY_FIELDS + ('email', 'phone') |
---|
[8519] | 62 | PG_OMIT_MANAGE_FIELDS = () |
---|
[8530] | 63 | PG_OMIT_EDIT_FIELDS = PG_OMIT_MANAGE_FIELDS + ( |
---|
| 64 | 'locked', 'course_admitted', |
---|
[8582] | 65 | 'student_id', 'screening_score', 'screening_venue', 'notice', |
---|
| 66 | 'screening_date') |
---|
[8519] | 67 | |
---|
[8053] | 68 | class IUGApplicant(IApplicantBaseData): |
---|
[8012] | 69 | """An undergraduate applicant. |
---|
| 70 | |
---|
[8519] | 71 | This interface defines the least common multiple of all fields |
---|
| 72 | in ug application forms. In customized forms, fields can be excluded by |
---|
| 73 | adding them to the UG_OMIT* tuples. |
---|
[8012] | 74 | """ |
---|
| 75 | |
---|
[8071] | 76 | nationality = schema.Choice( |
---|
| 77 | source = nats_vocab, |
---|
| 78 | title = _(u'Nationality'), |
---|
| 79 | required = False, |
---|
| 80 | ) |
---|
| 81 | lga = schema.Choice( |
---|
[8502] | 82 | source = LGASource(), |
---|
[8071] | 83 | title = _(u'State/LGA (Nigerians only)'), |
---|
| 84 | required = False, |
---|
| 85 | ) |
---|
[8530] | 86 | perm_address = schema.Text( |
---|
| 87 | title = _(u'Permanent Address'), |
---|
| 88 | required = False, |
---|
| 89 | ) |
---|
| 90 | course1 = schema.Choice( |
---|
| 91 | title = _(u'1st Choice Course of Study'), |
---|
| 92 | source = AppCatCertificateSource(), |
---|
| 93 | required = True, |
---|
| 94 | ) |
---|
| 95 | course2 = schema.Choice( |
---|
| 96 | title = _(u'2nd Choice Course of Study'), |
---|
| 97 | source = AppCatCertificateSource(), |
---|
| 98 | required = False, |
---|
| 99 | ) |
---|
[8535] | 100 | jamb_subjects = schema.Text( |
---|
| 101 | title = _(u'Subjects and Scores'), |
---|
[8530] | 102 | required = False, |
---|
| 103 | ) |
---|
[8535] | 104 | jamb_score = schema.Int( |
---|
| 105 | title = _(u'Total Score'), |
---|
| 106 | required = False, |
---|
| 107 | ) |
---|
[8530] | 108 | notice = schema.Text( |
---|
| 109 | title = _(u'Notice'), |
---|
| 110 | required = False, |
---|
| 111 | ) |
---|
| 112 | screening_venue = schema.TextLine( |
---|
| 113 | title = _(u'Screening Venue'), |
---|
| 114 | required = False, |
---|
| 115 | ) |
---|
[8577] | 116 | screening_date = schema.TextLine( |
---|
| 117 | title = _(u'Screening Date'), |
---|
| 118 | required = False, |
---|
| 119 | ) |
---|
[8530] | 120 | screening_score = schema.Int( |
---|
[8803] | 121 | title = _(u'Screening Score (%)'), |
---|
[8530] | 122 | required = False, |
---|
| 123 | ) |
---|
[8803] | 124 | aggregate = schema.Int( |
---|
| 125 | title = _(u'Aggregate Score (%)'), |
---|
| 126 | description = _(u'(average of relative JAMB and PUTME scores)'), |
---|
| 127 | required = False, |
---|
| 128 | ) |
---|
| 129 | result_uploaded = schema.Bool( |
---|
| 130 | title = _(u'Result uploaded'), |
---|
| 131 | default = False, |
---|
| 132 | ) |
---|
[8530] | 133 | student_id = schema.TextLine( |
---|
| 134 | title = _(u'Student Id'), |
---|
| 135 | required = False, |
---|
| 136 | readonly = False, |
---|
| 137 | ) |
---|
| 138 | course_admitted = schema.Choice( |
---|
| 139 | title = _(u'Admitted Course of Study'), |
---|
| 140 | source = CertificateSource(), |
---|
| 141 | required = False, |
---|
| 142 | ) |
---|
| 143 | locked = schema.Bool( |
---|
| 144 | title = _(u'Form locked'), |
---|
| 145 | default = False, |
---|
| 146 | ) |
---|
| 147 | |
---|
[8053] | 148 | class IPGApplicant(IApplicantBaseData): |
---|
[7853] | 149 | """A postgraduate applicant. |
---|
| 150 | |
---|
[8519] | 151 | This interface defines the least common multiple of all fields |
---|
| 152 | in pg application forms. In customized forms, fields can be excluded by |
---|
| 153 | adding them to the PG_OMIT* tuples. |
---|
[7866] | 154 | """ |
---|
| 155 | |
---|
[8071] | 156 | nationality = schema.Choice( |
---|
| 157 | source = nats_vocab, |
---|
| 158 | title = _(u'Nationality'), |
---|
| 159 | required = False, |
---|
| 160 | ) |
---|
| 161 | lga = schema.Choice( |
---|
[8502] | 162 | source = LGASource(), |
---|
[8071] | 163 | title = _(u'State/LGA (Nigerians only)'), |
---|
| 164 | required = False, |
---|
| 165 | ) |
---|
[8051] | 166 | perm_address = schema.Text( |
---|
| 167 | title = _(u'Permanent Address'), |
---|
| 168 | required = False, |
---|
| 169 | ) |
---|
| 170 | course1 = schema.Choice( |
---|
| 171 | title = _(u'1st Choice Course of Study'), |
---|
| 172 | source = AppCatCertificateSource(), |
---|
| 173 | required = True, |
---|
| 174 | ) |
---|
| 175 | course2 = schema.Choice( |
---|
| 176 | title = _(u'2nd Choice Course of Study'), |
---|
| 177 | source = AppCatCertificateSource(), |
---|
| 178 | required = False, |
---|
| 179 | ) |
---|
| 180 | hq_type = schema.Choice( |
---|
| 181 | title = _(u'Qualification Obtained'), |
---|
| 182 | required = False, |
---|
| 183 | readonly = False, |
---|
| 184 | vocabulary = high_qual, |
---|
| 185 | ) |
---|
| 186 | hq_matric_no = schema.TextLine( |
---|
| 187 | title = _(u'Former Matric Number'), |
---|
| 188 | required = False, |
---|
| 189 | readonly = False, |
---|
| 190 | ) |
---|
| 191 | hq_degree = schema.Choice( |
---|
| 192 | title = _(u'Class of Degree'), |
---|
| 193 | required = False, |
---|
| 194 | readonly = False, |
---|
| 195 | vocabulary = high_grade, |
---|
| 196 | ) |
---|
| 197 | hq_school = schema.TextLine( |
---|
| 198 | title = _(u'Institution Attended'), |
---|
| 199 | required = False, |
---|
| 200 | readonly = False, |
---|
| 201 | ) |
---|
| 202 | hq_session = schema.TextLine( |
---|
| 203 | title = _(u'Years Attended'), |
---|
| 204 | required = False, |
---|
| 205 | readonly = False, |
---|
| 206 | ) |
---|
| 207 | hq_disc = schema.TextLine( |
---|
| 208 | title = _(u'Discipline'), |
---|
| 209 | required = False, |
---|
| 210 | readonly = False, |
---|
| 211 | ) |
---|
| 212 | pp_school = schema.Choice( |
---|
| 213 | title = _(u'Qualification Obtained'), |
---|
| 214 | required = False, |
---|
| 215 | readonly = False, |
---|
| 216 | vocabulary = exam_types, |
---|
| 217 | ) |
---|
[8101] | 218 | #presently = schema.Bool( |
---|
| 219 | # title = _(u'Attending'), |
---|
| 220 | # required = False, |
---|
| 221 | # readonly = False, |
---|
| 222 | # ) |
---|
| 223 | presently_inst = schema.TextLine( |
---|
| 224 | title = _(u'If yes, name of institution'), |
---|
| 225 | required = False, |
---|
| 226 | readonly = False, |
---|
| 227 | ) |
---|
| 228 | nysc_year = schema.Int( |
---|
| 229 | title = _(u'Nysc Year'), |
---|
| 230 | required = False, |
---|
| 231 | readonly = False, |
---|
| 232 | ) |
---|
| 233 | nysc_lga = schema.Choice( |
---|
[8502] | 234 | source = LGASource(), |
---|
[8101] | 235 | title = _(u'Nysc Location'), |
---|
| 236 | required = False, |
---|
| 237 | ) |
---|
[8012] | 238 | employer = schema.TextLine( |
---|
| 239 | title = _(u'Employer'), |
---|
| 240 | required = False, |
---|
| 241 | readonly = False, |
---|
| 242 | ) |
---|
[8051] | 243 | emp_position = schema.TextLine( |
---|
| 244 | title = _(u'Employer Position'), |
---|
| 245 | required = False, |
---|
| 246 | readonly = False, |
---|
| 247 | ) |
---|
[8184] | 248 | emp_start = FormattedDate( |
---|
[8051] | 249 | title = _(u'Start Date'), |
---|
| 250 | required = False, |
---|
| 251 | readonly = False, |
---|
[8378] | 252 | show_year = True, |
---|
[8051] | 253 | ) |
---|
[8184] | 254 | emp_end = FormattedDate( |
---|
[8051] | 255 | title = _(u'End Date'), |
---|
| 256 | required = False, |
---|
| 257 | readonly = False, |
---|
[8378] | 258 | show_year = True, |
---|
[8051] | 259 | ) |
---|
| 260 | emp_reason = schema.TextLine( |
---|
| 261 | title = _(u'Reason for Leaving'), |
---|
| 262 | required = False, |
---|
| 263 | readonly = False, |
---|
| 264 | ) |
---|
| 265 | employer2 = schema.TextLine( |
---|
| 266 | title = _(u'2nd Employer'), |
---|
| 267 | required = False, |
---|
| 268 | readonly = False, |
---|
| 269 | ) |
---|
| 270 | emp2_position = schema.TextLine( |
---|
| 271 | title = _(u'2nd Employer Position'), |
---|
| 272 | required = False, |
---|
| 273 | readonly = False, |
---|
| 274 | ) |
---|
[8184] | 275 | emp2_start = FormattedDate( |
---|
[8051] | 276 | title = _(u'Start Date'), |
---|
| 277 | required = False, |
---|
| 278 | readonly = False, |
---|
[8378] | 279 | show_year = True, |
---|
[8051] | 280 | ) |
---|
[8184] | 281 | emp2_end = FormattedDate( |
---|
[8051] | 282 | title = _(u'End Date'), |
---|
| 283 | required = False, |
---|
| 284 | readonly = False, |
---|
[8378] | 285 | show_year = True, |
---|
[8051] | 286 | ) |
---|
| 287 | emp2_reason = schema.TextLine( |
---|
| 288 | title = _(u'Reason for Leaving'), |
---|
| 289 | required = False, |
---|
| 290 | readonly = False, |
---|
| 291 | ) |
---|
| 292 | notice = schema.Text( |
---|
| 293 | title = _(u'Notice'), |
---|
| 294 | required = False, |
---|
| 295 | readonly = False, |
---|
| 296 | ) |
---|
| 297 | screening_venue = schema.TextLine( |
---|
| 298 | title = _(u'Screening Venue'), |
---|
| 299 | required = False, |
---|
| 300 | readonly = False, |
---|
| 301 | ) |
---|
[8582] | 302 | screening_date = schema.TextLine( |
---|
| 303 | title = _(u'Screening Date'), |
---|
| 304 | required = False, |
---|
| 305 | ) |
---|
[8051] | 306 | screening_score = schema.Int( |
---|
| 307 | title = _(u'Screening Score'), |
---|
| 308 | required = False, |
---|
| 309 | readonly = False, |
---|
| 310 | ) |
---|
[8530] | 311 | student_id = schema.TextLine( |
---|
| 312 | title = _(u'Student Id'), |
---|
| 313 | required = False, |
---|
| 314 | readonly = False, |
---|
| 315 | ) |
---|
[8051] | 316 | course_admitted = schema.Choice( |
---|
| 317 | title = _(u'Admitted Course of Study'), |
---|
| 318 | source = CertificateSource(), |
---|
| 319 | required = False, |
---|
| 320 | readonly = False, |
---|
| 321 | ) |
---|
[8530] | 322 | locked = schema.Bool( |
---|
| 323 | title = _(u'Form locked'), |
---|
| 324 | default = False, |
---|
| 325 | ) |
---|
[8012] | 326 | |
---|
[8727] | 327 | class ICustomApplicant(IUGApplicant, IPGApplicant): |
---|
[8012] | 328 | """An interface for both types of applicants. |
---|
| 329 | |
---|
[8727] | 330 | Attention: The IPGApplicant field seetings will be overwritten |
---|
| 331 | by IPGApplicant field settings. If a field is defined |
---|
| 332 | in both interfaces zope.schema validates only against the |
---|
| 333 | constraints in IUGApplicant. This does not affect the forms |
---|
| 334 | since they are build on either IUGApplicant or IPGApplicant. |
---|
[8012] | 335 | """ |
---|
| 336 | |
---|
[8743] | 337 | def writeLogMessage(view, comment): |
---|
[8053] | 338 | """Adds an INFO message to the log file |
---|
| 339 | """ |
---|
| 340 | |
---|
| 341 | def createStudent(): |
---|
[8668] | 342 | """Create a student object from applicant data |
---|
[8053] | 343 | and copy applicant object. |
---|
| 344 | """ |
---|
| 345 | |
---|
[8017] | 346 | class IUGApplicantEdit(IUGApplicant): |
---|
[8727] | 347 | """An undergraduate applicant interface for edit forms. |
---|
[8012] | 348 | |
---|
| 349 | Here we can repeat the fields from base data and set the |
---|
| 350 | `required` and `readonly` attributes to True to further restrict |
---|
| 351 | the data access. Or we can allow only certain certificates to be |
---|
| 352 | selected by choosing the appropriate source. |
---|
| 353 | |
---|
| 354 | We cannot omit fields here. This has to be done in the |
---|
| 355 | respective form page. |
---|
| 356 | """ |
---|
| 357 | |
---|
[8646] | 358 | email = schema.ASCIILine( |
---|
| 359 | title = _(u'Email Address'), |
---|
| 360 | required = True, |
---|
| 361 | constraint=validate_email, |
---|
| 362 | ) |
---|
| 363 | date_of_birth = FormattedDate( |
---|
| 364 | title = _(u'Date of Birth'), |
---|
| 365 | required = True, |
---|
| 366 | show_year = True, |
---|
| 367 | ) |
---|
| 368 | |
---|
| 369 | IUGApplicantEdit[ |
---|
| 370 | 'date_of_birth'].order = IUGApplicant['date_of_birth'].order |
---|
| 371 | IUGApplicantEdit[ |
---|
| 372 | 'email'].order = IUGApplicant['email'].order |
---|
| 373 | |
---|
[8017] | 374 | class IPGApplicantEdit(IPGApplicant): |
---|
[7866] | 375 | """A postgraduate applicant interface for editing. |
---|
| 376 | |
---|
| 377 | Here we can repeat the fields from base data and set the |
---|
| 378 | `required` and `readonly` attributes to True to further restrict |
---|
| 379 | the data access. Or we can allow only certain certificates to be |
---|
| 380 | selected by choosing the appropriate source. |
---|
| 381 | |
---|
| 382 | We cannot omit fields here. This has to be done in the |
---|
| 383 | respective form page. |
---|
[8017] | 384 | """ |
---|
[8454] | 385 | |
---|
[8646] | 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 | ) |
---|
| 396 | |
---|
| 397 | IPGApplicantEdit[ |
---|
| 398 | 'date_of_birth'].order = IPGApplicant['date_of_birth'].order |
---|
| 399 | IPGApplicantEdit[ |
---|
| 400 | 'email'].order = IPGApplicant['email'].order |
---|
| 401 | |
---|
[8247] | 402 | class ICustomApplicantOnlinePayment(ICustomOnlinePayment): |
---|
| 403 | """An applicant payment via payment gateways. |
---|
| 404 | |
---|
| 405 | """ |
---|
[8530] | 406 | |
---|
| 407 | class IPUTMEApplicantEdit(IUGApplicant): |
---|
| 408 | """An undergraduate applicant interface for editing. |
---|
| 409 | |
---|
| 410 | Here we can repeat the fields from base data and set the |
---|
| 411 | `required` and `readonly` attributes to True to further restrict |
---|
| 412 | the data access. Or we can allow only certain certificates to be |
---|
| 413 | selected by choosing the appropriate source. |
---|
| 414 | |
---|
| 415 | We cannot omit fields here. This has to be done in the |
---|
| 416 | respective form page. |
---|
| 417 | """ |
---|
| 418 | email = schema.ASCIILine( |
---|
| 419 | title = _(u'Email Address'), |
---|
| 420 | required = True, |
---|
| 421 | constraint=validate_email, |
---|
| 422 | ) |
---|
[8539] | 423 | date_of_birth = FormattedDate( |
---|
| 424 | title = _(u'Date of Birth'), |
---|
| 425 | required = True, |
---|
| 426 | show_year = True, |
---|
| 427 | ) |
---|
[8530] | 428 | |
---|
| 429 | IPUTMEApplicantEdit[ |
---|
[8539] | 430 | 'date_of_birth'].order = IUGApplicant['date_of_birth'].order |
---|
| 431 | IPUTMEApplicantEdit[ |
---|
[8530] | 432 | 'email'].order = IUGApplicant['email'].order |
---|
[8582] | 433 | |
---|
| 434 | class ICustomApplicantUpdateByRegNo(ICustomApplicant): |
---|
| 435 | """Representation of an applicant. |
---|
| 436 | |
---|
| 437 | Skip regular reg_number validation if reg_number is used for finding |
---|
| 438 | the applicant object. |
---|
| 439 | """ |
---|
| 440 | reg_number = schema.TextLine( |
---|
| 441 | title = u'Registration Number', |
---|
| 442 | required = False, |
---|
| 443 | ) |
---|