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