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