[10765] | 1 | ## $Id: interfaces.py 15858 2019-11-27 09:17:47Z 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 |
---|
[15807] | 30 | from waeup.kofa.applicants.interfaces import ( |
---|
| 31 | contextual_reg_num_source, IApplicantBaseData) |
---|
[10765] | 32 | from kofacustom.nigeria.applicants.interfaces import ( |
---|
[15838] | 33 | LGASource, high_qual, high_grade, exam_types, DisabilitiesSource, |
---|
| 34 | programme_types_vocab, jambsubjects, validate_jamb_reg_number, |
---|
[10765] | 35 | INigeriaUGApplicant, INigeriaPGApplicant, |
---|
| 36 | INigeriaApplicantOnlinePayment, |
---|
| 37 | INigeriaUGApplicantEdit, INigeriaPGApplicantEdit, |
---|
| 38 | INigeriaApplicantUpdateByRegNo, |
---|
| 39 | IPUTMEApplicantEdit, |
---|
| 40 | ) |
---|
[15563] | 41 | from kofacustom.iuokada.interfaces import MessageFactory as _ |
---|
| 42 | from kofacustom.iuokada.payments.interfaces import ICustomOnlinePayment |
---|
[10765] | 43 | |
---|
[15793] | 44 | sponsors_vocab = SimpleKofaVocabulary( |
---|
| 45 | (_('Bauchi Government'), 'bauchi'), |
---|
| 46 | (_('Company'), 'company'), |
---|
| 47 | (_('Federal Government (Amnesty)'), 'federalgov'), |
---|
| 48 | (_('Dangote Group'), 'dangote'), |
---|
| 49 | (_('Kano Government'), 'kano'), |
---|
| 50 | (_('Parent/Guardian'), 'parent'), |
---|
| 51 | (_('Rosula Organization'), 'rosula'), |
---|
| 52 | (_('Self'), 'self'), |
---|
| 53 | (_('Social Impact Project'), 'social'), |
---|
| 54 | ) |
---|
| 55 | |
---|
| 56 | heard_about_types_vocab = SimpleKofaVocabulary( |
---|
| 57 | (_('Facebook/Twitter/Other Social Media'), 'socmedia'), |
---|
| 58 | (_('From a Friend'), 'friend'), |
---|
| 59 | (_('Newspaper Advertisement'), 'newspaper'), |
---|
| 60 | (_('Radio Advertisement'), 'radio'), |
---|
| 61 | (_('Television Advertisement'), 'television'), |
---|
| 62 | ) |
---|
| 63 | |
---|
[15858] | 64 | subtype_vocab = SimpleKofaVocabulary( |
---|
| 65 | (_('UTME'), 'utme'), |
---|
| 66 | (_('Direct Entry'), 'de'), |
---|
| 67 | (_('Inter Uni Transfer'), 'transfer'), |
---|
| 68 | ) |
---|
| 69 | |
---|
[15838] | 70 | class ICustomUGApplicant(IApplicantBaseData): |
---|
[10765] | 71 | """An undergraduate applicant. |
---|
| 72 | |
---|
| 73 | This interface defines the least common multiple of all fields |
---|
| 74 | in ug application forms. In customized forms, fields can be excluded by |
---|
| 75 | adding them to the UG_OMIT* tuples. |
---|
| 76 | """ |
---|
| 77 | |
---|
[15858] | 78 | subtype = schema.Choice( |
---|
| 79 | title = _(u'Application Subtype'), |
---|
| 80 | vocabulary = subtype_vocab, |
---|
| 81 | required = False, |
---|
| 82 | ) |
---|
[15838] | 83 | disabilities = schema.Choice( |
---|
| 84 | title = _(u'Disability'), |
---|
| 85 | source = DisabilitiesSource(), |
---|
| 86 | required = False, |
---|
| 87 | ) |
---|
| 88 | nationality = schema.Choice( |
---|
| 89 | source = nats_vocab, |
---|
| 90 | title = _(u'Nationality'), |
---|
| 91 | required = False, |
---|
| 92 | ) |
---|
| 93 | lga = schema.Choice( |
---|
| 94 | source = LGASource(), |
---|
| 95 | title = _(u'State/LGA (Nigerians only)'), |
---|
| 96 | required = False, |
---|
| 97 | ) |
---|
| 98 | #perm_address = schema.Text( |
---|
| 99 | # title = _(u'Permanent Address'), |
---|
| 100 | # required = False, |
---|
| 101 | # ) |
---|
| 102 | course1 = schema.Choice( |
---|
| 103 | title = _(u'1st Choice Course of Study'), |
---|
| 104 | source = AppCatCertificateSource(), |
---|
| 105 | required = True, |
---|
| 106 | ) |
---|
| 107 | course2 = schema.Choice( |
---|
| 108 | title = _(u'2nd Choice Course of Study'), |
---|
| 109 | source = AppCatCertificateSource(), |
---|
| 110 | required = False, |
---|
| 111 | ) |
---|
| 112 | programme_type = schema.Choice( |
---|
| 113 | title = _(u'Programme Type'), |
---|
| 114 | vocabulary = programme_types_vocab, |
---|
| 115 | required = False, |
---|
| 116 | ) |
---|
[15793] | 117 | sponsor = schema.Choice( |
---|
| 118 | title = _(u'Sponsor'), |
---|
| 119 | vocabulary = sponsors_vocab, |
---|
| 120 | required = False, |
---|
| 121 | ) |
---|
| 122 | heard_about = schema.Choice( |
---|
| 123 | title = _(u'How did you hear about IU?'), |
---|
| 124 | vocabulary = heard_about_types_vocab, |
---|
| 125 | required = False, |
---|
| 126 | ) |
---|
[15838] | 127 | fst_sit_fname = schema.TextLine( |
---|
| 128 | title = _(u'Full Name'), |
---|
| 129 | required = False, |
---|
| 130 | readonly = False, |
---|
| 131 | ) |
---|
| 132 | fst_sit_no = schema.TextLine( |
---|
| 133 | title = _(u'Exam Number'), |
---|
| 134 | required = False, |
---|
| 135 | readonly = False, |
---|
| 136 | ) |
---|
| 137 | fst_sit_date = FormattedDate( |
---|
| 138 | title = _(u'Exam Date'), |
---|
| 139 | required = False, |
---|
| 140 | readonly = False, |
---|
| 141 | show_year = True, |
---|
| 142 | ) |
---|
| 143 | fst_sit_type = schema.Choice( |
---|
| 144 | title = _(u'Exam Type'), |
---|
| 145 | required = False, |
---|
| 146 | readonly = False, |
---|
| 147 | vocabulary = exam_types, |
---|
| 148 | ) |
---|
| 149 | fst_sit_results = schema.List( |
---|
| 150 | title = _(u'Exam Results'), |
---|
| 151 | value_type = ResultEntryField(), |
---|
| 152 | required = False, |
---|
| 153 | readonly = False, |
---|
| 154 | defaultFactory=list, |
---|
| 155 | ) |
---|
| 156 | scd_sit_fname = schema.TextLine( |
---|
| 157 | title = _(u'Full Name'), |
---|
| 158 | required = False, |
---|
| 159 | readonly = False, |
---|
| 160 | ) |
---|
| 161 | scd_sit_no = schema.TextLine( |
---|
| 162 | title = _(u'Exam Number'), |
---|
| 163 | required = False, |
---|
| 164 | readonly = False, |
---|
| 165 | ) |
---|
| 166 | scd_sit_date = FormattedDate( |
---|
| 167 | title = _(u'Exam Date'), |
---|
| 168 | required = False, |
---|
| 169 | readonly = False, |
---|
| 170 | show_year = True, |
---|
| 171 | ) |
---|
| 172 | scd_sit_type = schema.Choice( |
---|
| 173 | title = _(u'Exam Type'), |
---|
| 174 | required = False, |
---|
| 175 | readonly = False, |
---|
| 176 | vocabulary = exam_types, |
---|
| 177 | ) |
---|
| 178 | scd_sit_results = schema.List( |
---|
| 179 | title = _(u'Exam Results'), |
---|
| 180 | value_type = ResultEntryField(), |
---|
| 181 | required = False, |
---|
| 182 | readonly = False, |
---|
| 183 | defaultFactory=list, |
---|
| 184 | ) |
---|
[15858] | 185 | hq_type = schema.Choice( |
---|
| 186 | title = _(u'Qualification Obtained'), |
---|
| 187 | required = False, |
---|
| 188 | readonly = False, |
---|
| 189 | vocabulary = high_qual, |
---|
| 190 | ) |
---|
| 191 | hq_matric_no = schema.TextLine( |
---|
| 192 | title = _(u'Former Matric Number'), |
---|
| 193 | required = False, |
---|
| 194 | readonly = False, |
---|
| 195 | ) |
---|
| 196 | hq_degree = schema.Choice( |
---|
| 197 | title = _(u'Class of Degree'), |
---|
| 198 | required = False, |
---|
| 199 | readonly = False, |
---|
| 200 | vocabulary = high_grade, |
---|
| 201 | ) |
---|
| 202 | hq_school = schema.TextLine( |
---|
| 203 | title = _(u'Institution Attended'), |
---|
| 204 | required = False, |
---|
| 205 | readonly = False, |
---|
| 206 | ) |
---|
| 207 | hq_session = schema.TextLine( |
---|
| 208 | title = _(u'Years Attended'), |
---|
| 209 | required = False, |
---|
| 210 | readonly = False, |
---|
| 211 | ) |
---|
| 212 | hq_disc = schema.TextLine( |
---|
| 213 | title = _(u'Discipline'), |
---|
| 214 | required = False, |
---|
| 215 | readonly = False, |
---|
| 216 | ) |
---|
[15838] | 217 | jamb_subjects = schema.Text( |
---|
| 218 | title = _(u'Subjects and Scores'), |
---|
| 219 | required = False, |
---|
| 220 | ) |
---|
[15858] | 221 | jamb_subjects = schema.Text( |
---|
| 222 | title = _(u'Subjects and Scores'), |
---|
| 223 | required = False, |
---|
| 224 | ) |
---|
[15838] | 225 | jamb_subjects_list = schema.List( |
---|
| 226 | title = _(u'JAMB Subjects'), |
---|
| 227 | required = False, |
---|
| 228 | defaultFactory=list, |
---|
| 229 | value_type = schema.Choice( |
---|
| 230 | vocabulary = jambsubjects |
---|
| 231 | #source = JAMBSubjectSource(), |
---|
| 232 | ), |
---|
| 233 | ) |
---|
| 234 | jamb_score = schema.Int( |
---|
| 235 | title = _(u'Total JAMB Score'), |
---|
| 236 | required = False, |
---|
| 237 | ) |
---|
| 238 | #jamb_age = schema.Int( |
---|
| 239 | # title = _(u'Age (provided by JAMB)'), |
---|
| 240 | # required = False, |
---|
| 241 | # ) |
---|
| 242 | jamb_reg_number = schema.TextLine( |
---|
| 243 | title = _(u'JAMB Registration Number'), |
---|
| 244 | required = False, |
---|
| 245 | constraint=validate_jamb_reg_number, |
---|
| 246 | ) |
---|
| 247 | notice = schema.Text( |
---|
| 248 | title = _(u'Notice'), |
---|
| 249 | required = False, |
---|
| 250 | ) |
---|
| 251 | screening_venue = schema.TextLine( |
---|
| 252 | title = _(u'Screening Venue'), |
---|
| 253 | required = False, |
---|
| 254 | ) |
---|
| 255 | screening_date = schema.TextLine( |
---|
| 256 | title = _(u'Screening Date'), |
---|
| 257 | required = False, |
---|
| 258 | ) |
---|
| 259 | screening_score = schema.Int( |
---|
| 260 | title = _(u'Screening Score (%)'), |
---|
| 261 | required = False, |
---|
| 262 | ) |
---|
| 263 | aggregate = schema.Int( |
---|
| 264 | title = _(u'Aggregate Score (%)'), |
---|
| 265 | description = _(u'(average of relative JAMB and PUTME scores)'), |
---|
| 266 | required = False, |
---|
| 267 | ) |
---|
| 268 | result_uploaded = schema.Bool( |
---|
| 269 | title = _(u'Result uploaded'), |
---|
| 270 | default = False, |
---|
| 271 | required = False, |
---|
| 272 | ) |
---|
| 273 | student_id = schema.TextLine( |
---|
| 274 | title = _(u'Student Id'), |
---|
| 275 | required = False, |
---|
| 276 | readonly = False, |
---|
| 277 | ) |
---|
| 278 | course_admitted = schema.Choice( |
---|
| 279 | title = _(u'Admitted Course of Study'), |
---|
| 280 | source = CertificateSource(), |
---|
| 281 | required = False, |
---|
| 282 | ) |
---|
| 283 | locked = schema.Bool( |
---|
| 284 | title = _(u'Form locked'), |
---|
| 285 | default = False, |
---|
| 286 | required = False, |
---|
| 287 | ) |
---|
[15793] | 288 | |
---|
[15807] | 289 | ICustomUGApplicant[ |
---|
[15858] | 290 | 'subtype'].order = ICustomUGApplicant['lga'].order |
---|
| 291 | ICustomUGApplicant[ |
---|
[15838] | 292 | 'locked'].order = ICustomUGApplicant['suspended'].order |
---|
[15807] | 293 | ICustomUGApplicant[ |
---|
[15838] | 294 | 'result_uploaded'].order = ICustomUGApplicant['suspended'].order |
---|
[15807] | 295 | |
---|
[10765] | 296 | class ICustomPGApplicant(INigeriaPGApplicant): |
---|
| 297 | """A postgraduate applicant. |
---|
| 298 | |
---|
| 299 | This interface defines the least common multiple of all fields |
---|
| 300 | in pg application forms. In customized forms, fields can be excluded by |
---|
| 301 | adding them to the PG_OMIT* tuples. |
---|
| 302 | """ |
---|
| 303 | |
---|
[15809] | 304 | sponsor = schema.Choice( |
---|
| 305 | title = _(u'Sponsor'), |
---|
| 306 | vocabulary = sponsors_vocab, |
---|
| 307 | required = False, |
---|
| 308 | ) |
---|
[10765] | 309 | |
---|
[15809] | 310 | heard_about = schema.Choice( |
---|
| 311 | title = _(u'How did you hear about IU?'), |
---|
| 312 | vocabulary = heard_about_types_vocab, |
---|
| 313 | required = False, |
---|
| 314 | ) |
---|
| 315 | |
---|
| 316 | ICustomPGApplicant[ |
---|
| 317 | 'sponsor'].order = ICustomPGApplicant['lga'].order |
---|
| 318 | ICustomPGApplicant[ |
---|
| 319 | 'heard_about'].order = ICustomPGApplicant['lga'].order |
---|
| 320 | ICustomPGApplicant[ |
---|
| 321 | 'sponsor'].order = ICustomPGApplicant['lga'].order |
---|
| 322 | ICustomPGApplicant[ |
---|
| 323 | 'lga'].order = ICustomPGApplicant['nationality'].order |
---|
| 324 | |
---|
[10765] | 325 | class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant): |
---|
| 326 | """An interface for both types of applicants. |
---|
| 327 | |
---|
| 328 | Attention: The ICustomPGApplicant field seetings will be overwritten |
---|
| 329 | by ICustomPGApplicant field settings. If a field is defined |
---|
| 330 | in both interfaces zope.schema validates only against the |
---|
| 331 | constraints in ICustomUGApplicant. This does not affect the forms |
---|
| 332 | since they are build on either ICustomUGApplicant or ICustomPGApplicant. |
---|
| 333 | """ |
---|
| 334 | |
---|
| 335 | def writeLogMessage(view, comment): |
---|
| 336 | """Adds an INFO message to the log file |
---|
| 337 | """ |
---|
| 338 | |
---|
| 339 | def createStudent(): |
---|
| 340 | """Create a student object from applicant data |
---|
| 341 | and copy applicant object. |
---|
| 342 | """ |
---|
| 343 | |
---|
[15858] | 344 | class ICustomUGApplicantEdit(ICustomUGApplicant): |
---|
[10765] | 345 | """An undergraduate applicant interface for edit forms. |
---|
| 346 | |
---|
| 347 | Here we can repeat the fields from base data and set the |
---|
| 348 | `required` and `readonly` attributes to True to further restrict |
---|
| 349 | the data access. Or we can allow only certain certificates to be |
---|
| 350 | selected by choosing the appropriate source. |
---|
| 351 | |
---|
| 352 | We cannot omit fields here. This has to be done in the |
---|
| 353 | respective form page. |
---|
| 354 | """ |
---|
| 355 | |
---|
[15858] | 356 | class ICustomPGApplicantEdit(ICustomPGApplicant): |
---|
[10765] | 357 | """A postgraduate applicant interface for editing. |
---|
| 358 | |
---|
| 359 | Here we can repeat the fields from base data and set the |
---|
| 360 | `required` and `readonly` attributes to True to further restrict |
---|
| 361 | the data access. Or we can allow only certain certificates to be |
---|
| 362 | selected by choosing the appropriate source. |
---|
| 363 | |
---|
| 364 | We cannot omit fields here. This has to be done in the |
---|
| 365 | respective form page. |
---|
| 366 | """ |
---|
| 367 | |
---|
| 368 | class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment): |
---|
| 369 | """An applicant payment via payment gateways. |
---|
| 370 | |
---|
| 371 | """ |
---|
| 372 | |
---|
| 373 | class IPUTMEApplicantEdit(IPUTMEApplicantEdit): |
---|
| 374 | """An undergraduate applicant interface for editing. |
---|
| 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 | |
---|
| 385 | class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo): |
---|
| 386 | """Representation of an applicant. |
---|
| 387 | |
---|
| 388 | Skip regular reg_number validation if reg_number is used for finding |
---|
| 389 | the applicant object. |
---|
| 390 | """ |
---|