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