[5638] | 1 | ## |
---|
| 2 | ## interfaces.py |
---|
| 3 | ## Login : <uli@pu.smp.net> |
---|
| 4 | ## Started on Sun Jan 16 15:30:01 2011 Uli Fouquet |
---|
| 5 | ## $Id$ |
---|
[6076] | 6 | ## |
---|
[6087] | 7 | ## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann |
---|
[5638] | 8 | ## This program is free software; you can redistribute it and/or modify |
---|
| 9 | ## it under the terms of the GNU General Public License as published by |
---|
| 10 | ## the Free Software Foundation; either version 2 of the License, or |
---|
| 11 | ## (at your option) any later version. |
---|
[6076] | 12 | ## |
---|
[5638] | 13 | ## This program is distributed in the hope that it will be useful, |
---|
| 14 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | ## GNU General Public License for more details. |
---|
[6076] | 17 | ## |
---|
[5638] | 18 | ## You should have received a copy of the GNU General Public License |
---|
| 19 | ## along with this program; if not, write to the Free Software |
---|
| 20 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
| 21 | ## |
---|
[5676] | 22 | """Interfaces regarding student applicants and related components. |
---|
[5638] | 23 | """ |
---|
[5753] | 24 | import os |
---|
| 25 | import waeup.sirp.browser |
---|
[6098] | 26 | from datetime import datetime |
---|
[5866] | 27 | from grokcore.content.interfaces import IContainer |
---|
[5758] | 28 | from zc.sourcefactory.basic import BasicSourceFactory |
---|
[5638] | 29 | from zope import schema |
---|
[6075] | 30 | from zope.component import getUtility, getUtilitiesFor |
---|
[5758] | 31 | from zope.interface import Interface, Attribute |
---|
| 32 | from zope.pluggableauth.interfaces import IPrincipalInfo |
---|
| 33 | from zope.security.interfaces import IGroupClosureAwarePrincipal as IPrincipal |
---|
[5753] | 34 | from waeup.sirp.image.schema import ImageFile |
---|
[5980] | 35 | from waeup.sirp.image.image import WAeUPImageFile |
---|
[5681] | 36 | from waeup.sirp.interfaces import IWAeUPObject, SimpleWAeUPVocabulary |
---|
[5638] | 37 | |
---|
[6075] | 38 | |
---|
[5753] | 39 | IMAGE_PATH = os.path.join( |
---|
| 40 | os.path.dirname(waeup.sirp.browser.__file__), |
---|
| 41 | 'static' |
---|
| 42 | ) |
---|
[5980] | 43 | DEFAULT_PASSPORT_IMAGE_MALE = WAeUPImageFile( |
---|
[5753] | 44 | 'passport.jpg', |
---|
| 45 | open(os.path.join(IMAGE_PATH, 'placeholder_m.jpg')).read(), |
---|
| 46 | ) |
---|
[5980] | 47 | DEFAULT_PASSPORT_IMAGE_FEMALE = WAeUPImageFile( |
---|
[5753] | 48 | 'passport.jpg', |
---|
| 49 | open(os.path.join(IMAGE_PATH, 'placeholder_f.jpg')).read(), |
---|
| 50 | ) |
---|
| 51 | |
---|
[6087] | 52 | #: Types of applications we support. |
---|
| 53 | APPLICATION_TYPES = ( |
---|
[6111] | 54 | ('General Studies', 'app','APP'), |
---|
| 55 | ('Pre-NCE Programme', 'prence','PRE'), |
---|
| 56 | ('Post UME Screening Test', 'pume','PUME'), |
---|
| 57 | ('Post UDE Screening', 'pude','PUDE'), |
---|
| 58 | ('Part Time Degree in Education', 'sandwich','SAND'), |
---|
| 59 | ('Part-Time Degree Programmes', 'pt','PTP'), |
---|
| 60 | ('Diploma Programmes', 'dp','DPP'), |
---|
| 61 | ('PCE Screening', 'pce','PCE'), |
---|
| 62 | ('Certificate Programmes', 'ct','CTP'), |
---|
| 63 | ('Common Entry Screening Test', 'cest','CEST'), |
---|
[5681] | 64 | ) |
---|
| 65 | |
---|
| 66 | #: A :class:`waeup.sirp.interfaces.SimpleWAeUPVocabulary` of supported |
---|
[6087] | 67 | #: application or screening types. |
---|
[6111] | 68 | application_types_vocab = SimpleWAeUPVocabulary(*[(x[0],x[1]) for x in APPLICATION_TYPES]) |
---|
| 69 | application_pins_vocab = SimpleWAeUPVocabulary(*[(u"%s (%s)" % (x[2],x[0]),x[2]) for x in APPLICATION_TYPES]) |
---|
[5681] | 70 | |
---|
[6109] | 71 | def yeararrange(): |
---|
| 72 | curr_year = datetime.now().year |
---|
| 73 | return range(curr_year - 2, curr_year + 5) |
---|
[6097] | 74 | |
---|
[5753] | 75 | class GenderSource(BasicSourceFactory): |
---|
| 76 | """A gender source delivers basically a mapping |
---|
| 77 | ``{'m': 'male', 'f': 'female'}`` |
---|
| 78 | |
---|
| 79 | Using a source, we make sure that the tokens (which are |
---|
| 80 | stored/expected for instance from CSV files) are something one |
---|
| 81 | can expect and not cryptic IntIDs. |
---|
| 82 | """ |
---|
| 83 | def getValues(self): |
---|
| 84 | return ['m', 'f'] |
---|
| 85 | |
---|
| 86 | def getToken(self, value): |
---|
| 87 | return value[0].lower() |
---|
[6076] | 88 | |
---|
[5753] | 89 | def getTitle(self, value): |
---|
| 90 | if value == 'm': |
---|
| 91 | return 'male' |
---|
| 92 | if value == 'f': |
---|
| 93 | return 'female' |
---|
[6076] | 94 | |
---|
[6069] | 95 | class ApplicantContainerProviderSource(BasicSourceFactory): |
---|
[6075] | 96 | """A source offering all available applicants container types. |
---|
| 97 | |
---|
| 98 | The values returned by this source are names of utilities that can |
---|
| 99 | create :class:`ApplicantContainer` instances. So, if you get a |
---|
| 100 | name like ``'myactype'`` from this source, then you can do: |
---|
| 101 | |
---|
| 102 | >>> from zope.component import getUtility |
---|
| 103 | >>> p = getUtility(IApplicantsContainerProvider, name=myactype) |
---|
| 104 | >>> my_applicants_container = p.factory() |
---|
| 105 | |
---|
| 106 | Or you can access class-attributes like |
---|
| 107 | |
---|
| 108 | >>> my_applicants_container.container_title |
---|
| 109 | 'Pretty' |
---|
[6076] | 110 | |
---|
[6069] | 111 | """ |
---|
| 112 | def getValues(self): |
---|
[6075] | 113 | """Returns a list of ``(<name>, <provider>)`` tuples. |
---|
[5753] | 114 | |
---|
[6075] | 115 | Here ``<name>`` is the name under which an |
---|
| 116 | :class:``ApplicantContainerProvider`` was registered as a |
---|
| 117 | utility and ``<provider>`` is the utility itself. |
---|
| 118 | """ |
---|
| 119 | return getUtilitiesFor(IApplicantsContainerProvider) |
---|
| 120 | |
---|
[6069] | 121 | def getToken(self, value): |
---|
[6075] | 122 | """Return the name of the ``(<name>, <provider>)`` tuple. |
---|
| 123 | """ |
---|
| 124 | return value[0] |
---|
| 125 | |
---|
[6069] | 126 | def getTitle(self, value): |
---|
[6075] | 127 | """Get a 'title - description' string for a container type. |
---|
| 128 | """ |
---|
| 129 | factory = value[1].factory |
---|
| 130 | return "%s - %s" % ( |
---|
| 131 | factory.container_title, factory.container_description) |
---|
[6069] | 132 | |
---|
[5753] | 133 | class IResultEntry(IWAeUPObject): |
---|
| 134 | subject = schema.TextLine( |
---|
| 135 | title = u'Subject', |
---|
| 136 | description = u'The subject', |
---|
| 137 | required=False, |
---|
| 138 | ) |
---|
| 139 | score = schema.TextLine( |
---|
| 140 | title = u'Score', |
---|
| 141 | description = u'The score', |
---|
| 142 | required=False, |
---|
| 143 | ) |
---|
| 144 | |
---|
[5866] | 145 | class IApplicantsRoot(IWAeUPObject, IContainer): |
---|
[5676] | 146 | """A container for university applicants containers. |
---|
[5645] | 147 | """ |
---|
[5866] | 148 | pass |
---|
[5638] | 149 | |
---|
[6076] | 150 | |
---|
[5676] | 151 | class IApplicantsContainer(IWAeUPObject): |
---|
| 152 | """An applicants container contains university applicants. |
---|
[5645] | 153 | |
---|
[5638] | 154 | """ |
---|
[6069] | 155 | |
---|
[6075] | 156 | container_title = Attribute( |
---|
| 157 | u'classattribute: title for type of container') |
---|
| 158 | container_description = Attribute( |
---|
| 159 | u'classattribute: description for type of container') |
---|
| 160 | |
---|
[6076] | 161 | |
---|
[6069] | 162 | code = schema.TextLine( |
---|
| 163 | title = u'Code', |
---|
[6087] | 164 | default = u'-', |
---|
[6069] | 165 | required = True, |
---|
| 166 | readonly = True, |
---|
[6076] | 167 | ) |
---|
[6096] | 168 | |
---|
[6087] | 169 | title = schema.TextLine( |
---|
| 170 | title = u'Title', |
---|
| 171 | required = True, |
---|
| 172 | default = u'-', |
---|
| 173 | readonly = True, |
---|
[6096] | 174 | ) |
---|
| 175 | |
---|
[6087] | 176 | prefix = schema.Choice( |
---|
| 177 | title = u'Application target', |
---|
| 178 | required = True, |
---|
| 179 | default = None, |
---|
| 180 | source = application_types_vocab, |
---|
| 181 | readonly = True, |
---|
| 182 | ) |
---|
[6076] | 183 | |
---|
[6087] | 184 | year = schema.Choice( |
---|
| 185 | title = u'Year of entrance', |
---|
| 186 | required = True, |
---|
| 187 | default = None, |
---|
[6109] | 188 | values = yeararrange(), |
---|
[6087] | 189 | readonly = True, |
---|
[6096] | 190 | ) |
---|
[6087] | 191 | |
---|
[6069] | 192 | provider = schema.Choice( |
---|
[6070] | 193 | title = u'Applicants container type', |
---|
[6069] | 194 | required = True, |
---|
| 195 | default = None, |
---|
| 196 | source = ApplicantContainerProviderSource(), |
---|
[6087] | 197 | readonly = True, |
---|
[6076] | 198 | ) |
---|
[6110] | 199 | |
---|
| 200 | ac_prefix = schema.Choice( |
---|
| 201 | title = u'Access code prefix', |
---|
| 202 | required = True, |
---|
| 203 | default = None, |
---|
[6111] | 204 | source = application_pins_vocab, |
---|
[6110] | 205 | ) |
---|
[6076] | 206 | |
---|
[5645] | 207 | description = schema.Text( |
---|
| 208 | title = u'Human readable description in reST format', |
---|
[5638] | 209 | required = False, |
---|
[6070] | 210 | default = u'No description yet.' |
---|
[5638] | 211 | ) |
---|
| 212 | |
---|
| 213 | startdate = schema.Date( |
---|
[5645] | 214 | title = u'Date when the application period starts', |
---|
[5638] | 215 | required = False, |
---|
| 216 | default = None, |
---|
| 217 | ) |
---|
| 218 | |
---|
| 219 | enddate = schema.Date( |
---|
[5645] | 220 | title = u'Date when the application period ends', |
---|
[5638] | 221 | required = False, |
---|
| 222 | default = None, |
---|
| 223 | ) |
---|
| 224 | |
---|
[5645] | 225 | strict_deadline = schema.Bool( |
---|
| 226 | title = u'Forbid additions after deadline (enddate)', |
---|
| 227 | required = True, |
---|
| 228 | default = True, |
---|
| 229 | ) |
---|
[5638] | 230 | |
---|
| 231 | def archive(id=None): |
---|
[5676] | 232 | """Create on-dist archive of applicants stored in this term. |
---|
[5638] | 233 | |
---|
[5676] | 234 | If id is `None`, all applicants are archived. |
---|
[5638] | 235 | |
---|
| 236 | If id contains a single id string, only the respective |
---|
[5676] | 237 | applicants are archived. |
---|
[5638] | 238 | |
---|
| 239 | If id contains a list of id strings all of the respective |
---|
[5676] | 240 | applicants types are saved to disk. |
---|
[5638] | 241 | """ |
---|
| 242 | |
---|
| 243 | def clear(id=None, archive=True): |
---|
[5676] | 244 | """Remove applicants of type given by 'id'. |
---|
[5638] | 245 | |
---|
[5676] | 246 | Optionally archive the applicants. |
---|
[6076] | 247 | |
---|
[5676] | 248 | If id is `None`, all applicants are archived. |
---|
[5638] | 249 | |
---|
| 250 | If id contains a single id string, only the respective |
---|
[5676] | 251 | applicants are archived. |
---|
[5638] | 252 | |
---|
| 253 | If id contains a list of id strings all of the respective |
---|
[5676] | 254 | applicant types are saved to disk. |
---|
[5638] | 255 | |
---|
| 256 | If `archive` is ``False`` none of the archive-handling is done |
---|
[5676] | 257 | and respective applicants are simply removed from the |
---|
[5638] | 258 | database. |
---|
| 259 | """ |
---|
[6073] | 260 | |
---|
[6069] | 261 | class IApplicantsContainerAdd(IApplicantsContainer): |
---|
| 262 | """An applicants container contains university applicants. |
---|
| 263 | """ |
---|
[6087] | 264 | prefix = schema.Choice( |
---|
| 265 | title = u'Application target', |
---|
[6069] | 266 | required = True, |
---|
[6087] | 267 | default = None, |
---|
| 268 | source = application_types_vocab, |
---|
[6069] | 269 | readonly = False, |
---|
[6076] | 270 | ) |
---|
[6073] | 271 | |
---|
[6087] | 272 | year = schema.Choice( |
---|
| 273 | title = u'Year of entrance', |
---|
| 274 | required = True, |
---|
| 275 | default = None, |
---|
[6109] | 276 | values = yeararrange(), |
---|
[6087] | 277 | readonly = False, |
---|
[6096] | 278 | ) |
---|
[6073] | 279 | |
---|
[6087] | 280 | provider = schema.Choice( |
---|
| 281 | title = u'Applicants container type', |
---|
| 282 | required = True, |
---|
| 283 | default = None, |
---|
| 284 | source = ApplicantContainerProviderSource(), |
---|
| 285 | readonly = False, |
---|
| 286 | ) |
---|
| 287 | |
---|
[6096] | 288 | IApplicantsContainerAdd[ |
---|
| 289 | 'prefix'].order = IApplicantsContainer['prefix'].order |
---|
| 290 | IApplicantsContainerAdd[ |
---|
| 291 | 'year'].order = IApplicantsContainer['year'].order |
---|
| 292 | IApplicantsContainerAdd[ |
---|
| 293 | 'provider'].order = IApplicantsContainer['provider'].order |
---|
[6087] | 294 | |
---|
[5753] | 295 | class IApplicantBaseData(IWAeUPObject): |
---|
| 296 | """The data for an applicant. |
---|
| 297 | |
---|
| 298 | This is a base interface with no field (except ``reg_no``) |
---|
| 299 | required. For use with importers, forms, etc., please use one of |
---|
| 300 | the derived interfaces below, which set more fields to required |
---|
| 301 | state, depending on use-case. |
---|
| 302 | """ |
---|
| 303 | reg_no = schema.TextLine( |
---|
| 304 | title = u'JAMB Registration Number', |
---|
| 305 | ) |
---|
| 306 | access_code = schema.TextLine( |
---|
| 307 | title = u'Access Code', |
---|
| 308 | required = False, |
---|
| 309 | ) |
---|
| 310 | serial = schema.TextLine( |
---|
| 311 | title = u'Serial Number', |
---|
| 312 | required = False, |
---|
| 313 | ) |
---|
| 314 | course1 = schema.TextLine( |
---|
| 315 | title = u'1st Choice Course of Study', |
---|
| 316 | required = False, |
---|
| 317 | ) |
---|
| 318 | course2 = schema.TextLine( |
---|
| 319 | title = u'2nd Choice Course of Study', |
---|
| 320 | required = False, |
---|
| 321 | ) |
---|
| 322 | course3 = schema.TextLine( |
---|
| 323 | title = u'3rd Choice Course of Study', |
---|
| 324 | required = False, |
---|
| 325 | ) |
---|
| 326 | firstname = schema.TextLine( |
---|
| 327 | title = u'First Name', |
---|
| 328 | required = False, |
---|
| 329 | ) |
---|
| 330 | middlenames = schema.TextLine( |
---|
| 331 | title = u'Middle Names', |
---|
| 332 | required = False, |
---|
| 333 | ) |
---|
| 334 | lastname = schema.TextLine( |
---|
| 335 | title = u'Surname/Full Name', |
---|
| 336 | required = False, |
---|
| 337 | ) |
---|
| 338 | date_of_birth = schema.Date( |
---|
| 339 | title = u'Date of Birth', |
---|
| 340 | required = False, |
---|
| 341 | ) |
---|
| 342 | lga = schema.TextLine( |
---|
| 343 | # XXX: should be choice |
---|
| 344 | title = u'State/LGA (confirmed by applicant)', |
---|
| 345 | required = False, |
---|
| 346 | ) |
---|
| 347 | sex = schema.Choice( |
---|
| 348 | title = u'Sex', |
---|
| 349 | source = GenderSource(), |
---|
| 350 | default = u'm', |
---|
| 351 | required = False, |
---|
| 352 | ) |
---|
| 353 | email = schema.TextLine( |
---|
| 354 | title = u'Email', |
---|
| 355 | required = False, |
---|
| 356 | ) |
---|
| 357 | phone = schema.TextLine( |
---|
| 358 | title = u'Phone', |
---|
| 359 | required = False, |
---|
| 360 | ) |
---|
| 361 | passport = ImageFile( |
---|
| 362 | title = u'Passport Photograph', |
---|
| 363 | default = DEFAULT_PASSPORT_IMAGE_MALE, |
---|
| 364 | required = True, |
---|
| 365 | ) |
---|
| 366 | aos = schema.TextLine( |
---|
| 367 | # XXX: should be choice |
---|
| 368 | title = u'Area of Specialisation', |
---|
| 369 | required = False, |
---|
| 370 | ) |
---|
| 371 | subj1 = schema.TextLine( |
---|
| 372 | # XXX: should be choice |
---|
| 373 | title = u'1st Choice of Study', |
---|
| 374 | required = False, |
---|
| 375 | ) |
---|
| 376 | subj2 = schema.TextLine( |
---|
| 377 | # XXX: should be choice |
---|
| 378 | title = u'2nd Choice of Study', |
---|
| 379 | required = False, |
---|
| 380 | ) |
---|
| 381 | subj3 = schema.TextLine( |
---|
| 382 | # XXX: should be choice |
---|
| 383 | title = u'3rd Choice of Study', |
---|
| 384 | required = False, |
---|
| 385 | ) |
---|
| 386 | # |
---|
| 387 | # Higher Educational Data |
---|
| 388 | # |
---|
| 389 | hq_matric_no = schema.TextLine( |
---|
| 390 | title = u'Former Matric Number', |
---|
| 391 | required = False, |
---|
| 392 | ) |
---|
| 393 | hq_type = schema.TextLine( |
---|
| 394 | title = u'Higher Qualification', |
---|
| 395 | required = False, |
---|
| 396 | ) |
---|
| 397 | hq_grade = schema.TextLine( |
---|
| 398 | title = u'Higher Qualification Grade', |
---|
| 399 | required = False, |
---|
| 400 | ) |
---|
| 401 | hq_school = schema.TextLine( |
---|
| 402 | title = u'School Attended', |
---|
| 403 | required = False, |
---|
| 404 | ) |
---|
| 405 | hq_session = schema.TextLine( |
---|
| 406 | title = u'Session Obtained', |
---|
| 407 | required = False, |
---|
| 408 | ) |
---|
| 409 | hq_disc = schema.TextLine( |
---|
| 410 | title = u'Discipline', |
---|
| 411 | required = False, |
---|
| 412 | ) |
---|
| 413 | # |
---|
| 414 | # First sitting data |
---|
| 415 | # |
---|
| 416 | fst_sit_fname = schema.TextLine( |
---|
| 417 | title = u'Full Name', |
---|
| 418 | required = False, |
---|
| 419 | ) |
---|
| 420 | fst_sit_no = schema.TextLine( |
---|
| 421 | title = u'Exam Number', |
---|
| 422 | required = False, |
---|
| 423 | ) |
---|
| 424 | fst_sit_date = schema.Date( |
---|
| 425 | title = u'Exam Date (dd/mm/yyyy)', |
---|
| 426 | required = False, |
---|
| 427 | ) |
---|
| 428 | fst_sit_type = schema.TextLine( |
---|
| 429 | # XXX: Should be choice |
---|
| 430 | title = u'Exam Type', |
---|
| 431 | required = False, |
---|
| 432 | ) |
---|
| 433 | fst_sit_results = schema.List( |
---|
| 434 | title = u'Results', |
---|
| 435 | required = False, |
---|
| 436 | value_type = schema.Object( |
---|
| 437 | title = u'Entries', |
---|
| 438 | schema = IResultEntry, |
---|
| 439 | required = False, |
---|
| 440 | ) |
---|
| 441 | ) |
---|
| 442 | scd_sit_fname = schema.TextLine( |
---|
| 443 | title = u'Full Name', |
---|
| 444 | required = False, |
---|
| 445 | ) |
---|
| 446 | scd_sit_no = schema.TextLine( |
---|
| 447 | title = u'Exam Number', |
---|
| 448 | required = False, |
---|
| 449 | ) |
---|
| 450 | scd_sit_date = schema.Date( |
---|
| 451 | title = u'Exam Date (dd/mm/yyyy)', |
---|
| 452 | required = False, |
---|
| 453 | ) |
---|
| 454 | scd_sit_type = schema.TextLine( |
---|
| 455 | # XXX: Should be choice |
---|
| 456 | title = u'Exam Type', |
---|
| 457 | required = False, |
---|
| 458 | ) |
---|
| 459 | scd_sit_results = schema.TextLine( |
---|
| 460 | # XXX: Should be nested list of choices |
---|
| 461 | title = u'Results', |
---|
| 462 | required = False, |
---|
| 463 | ) |
---|
| 464 | # |
---|
| 465 | # JAMB scores |
---|
| 466 | # |
---|
| 467 | eng_score = schema.TextLine( |
---|
| 468 | title = u"'English' score", |
---|
| 469 | required = False, |
---|
| 470 | ) |
---|
| 471 | subj1score = schema.TextLine( |
---|
| 472 | title = u'1st Choice of Study Score', |
---|
| 473 | required = False, |
---|
| 474 | ) |
---|
| 475 | subj2score = schema.TextLine( |
---|
| 476 | title = u'2nd Choice of Study Score', |
---|
| 477 | required = False, |
---|
| 478 | ) |
---|
| 479 | subj3score = schema.TextLine( |
---|
| 480 | title = u'3rd Choice of Study Score', |
---|
| 481 | required = False, |
---|
| 482 | ) |
---|
| 483 | # XXX: Total score??? |
---|
[6076] | 484 | |
---|
[5753] | 485 | # |
---|
| 486 | # Application Data |
---|
| 487 | # |
---|
| 488 | application_date = schema.Date( |
---|
| 489 | title = u'Application Date', |
---|
| 490 | required = False, |
---|
| 491 | ) |
---|
| 492 | status = schema.TextLine( |
---|
| 493 | # XXX: should be 'status' type |
---|
| 494 | title = u'Application Status', |
---|
| 495 | required = False, |
---|
| 496 | ) |
---|
| 497 | screening_date = schema.Date( |
---|
| 498 | title = u'Screening Date', |
---|
| 499 | required = False, |
---|
| 500 | ) |
---|
| 501 | screening_type = schema.TextLine( |
---|
| 502 | # XXX: schould be choice |
---|
| 503 | title = u'Screening Type', |
---|
| 504 | required = False, |
---|
| 505 | ) |
---|
| 506 | screening_score = schema.TextLine( |
---|
| 507 | title = u'Screening Score', |
---|
| 508 | required = False, |
---|
| 509 | ) |
---|
| 510 | screening_venue = schema.TextLine( |
---|
| 511 | title = u'Screening Venue', |
---|
| 512 | required = False, |
---|
| 513 | ) |
---|
| 514 | total_score = schema.TextLine( |
---|
| 515 | title = u'Total Score', |
---|
| 516 | required = False, |
---|
| 517 | ) |
---|
| 518 | course_admitted = schema.TextLine( |
---|
| 519 | # XXX: should be choice |
---|
| 520 | title = u'Admitted Course of Study', |
---|
| 521 | required = False, |
---|
| 522 | ) |
---|
| 523 | department = schema.TextLine( |
---|
| 524 | # XXX: if we have a course, dept. is not necessary |
---|
| 525 | title = u'Department', |
---|
| 526 | required = False, |
---|
| 527 | ) |
---|
| 528 | faculty = schema.TextLine( |
---|
| 529 | # XXX: if we have a course, faculty is not necessary |
---|
| 530 | title = u'Faculty', |
---|
| 531 | required = False, |
---|
| 532 | ) |
---|
| 533 | entry_session = schema.TextLine( |
---|
| 534 | # XXX: should be choice, should have sensible default: upcoming session |
---|
| 535 | title = u'Entry Session', |
---|
| 536 | required = False, |
---|
| 537 | ) |
---|
| 538 | notice = schema.Text( |
---|
| 539 | title = u'Notice', |
---|
| 540 | required = False, |
---|
| 541 | ) |
---|
| 542 | student_id = schema.TextLine( |
---|
| 543 | title = u'Student ID', |
---|
| 544 | required = False, |
---|
| 545 | ) |
---|
| 546 | import_record_no = schema.TextLine( |
---|
| 547 | title = u'Import Record No.', |
---|
| 548 | required = False, |
---|
| 549 | ) |
---|
| 550 | imported_by = schema.TextLine( |
---|
| 551 | title = u'Imported By', |
---|
| 552 | required = False, |
---|
| 553 | ) |
---|
| 554 | import_date = schema.Datetime( |
---|
| 555 | title = u'Import Date', |
---|
| 556 | required = False, |
---|
| 557 | ) |
---|
| 558 | import_from = schema.TextLine( |
---|
| 559 | title = u'Import Source', |
---|
| 560 | required = False, |
---|
| 561 | ) |
---|
[5952] | 562 | confirm_passport = schema.Bool( |
---|
| 563 | title = u"Confirmation that photograph represents applicant ticked.", |
---|
| 564 | default = False, |
---|
| 565 | required = True, |
---|
| 566 | ) |
---|
[5753] | 567 | |
---|
[6076] | 568 | |
---|
[5753] | 569 | class IApplicant(IApplicantBaseData): |
---|
| 570 | """An applicant. |
---|
| 571 | |
---|
| 572 | This is basically the applicant base data. Here we repeat the |
---|
| 573 | fields from base data only with the `required` attribute of |
---|
| 574 | required attributes set to True (which is the default). |
---|
| 575 | """ |
---|
[5941] | 576 | locked = schema.Bool( |
---|
| 577 | title = u'Form locked', |
---|
| 578 | default = False, |
---|
| 579 | readonly = True, |
---|
| 580 | ) |
---|
[5753] | 581 | access_code = schema.TextLine( |
---|
| 582 | title = u'Access Code', |
---|
| 583 | ) |
---|
| 584 | course1 = schema.TextLine( |
---|
| 585 | title = u'1st Choice Course of Study', |
---|
| 586 | ) |
---|
| 587 | firstname = schema.TextLine( |
---|
| 588 | title = u'First Name', |
---|
| 589 | ) |
---|
| 590 | middlenames = schema.TextLine( |
---|
| 591 | title = u'Middle Names', |
---|
| 592 | ) |
---|
| 593 | lastname = schema.TextLine( |
---|
| 594 | title = u'Surname/Full Name', |
---|
| 595 | ) |
---|
| 596 | date_of_birth = schema.Date( |
---|
| 597 | title = u'Date of Birth', |
---|
| 598 | ) |
---|
| 599 | jamb_state = schema.TextLine( |
---|
| 600 | title = u'State (provided by JAMB)', |
---|
| 601 | ) |
---|
| 602 | jamb_lga = schema.TextLine( |
---|
| 603 | title = u'LGA (provided by JAMB)', |
---|
| 604 | ) |
---|
| 605 | lga = schema.TextLine( |
---|
| 606 | # XXX: should be choice |
---|
| 607 | title = u'State/LGA (confirmed by applicant)', |
---|
| 608 | ) |
---|
| 609 | sex = schema.Choice( |
---|
| 610 | title = u'Sex', |
---|
| 611 | source = GenderSource(), |
---|
| 612 | default = u'm', |
---|
| 613 | ) |
---|
| 614 | #passport = schema.Bool( |
---|
| 615 | # title = u'Passport Photograph', |
---|
| 616 | # default = True, |
---|
| 617 | # ) |
---|
| 618 | passport = ImageFile( |
---|
| 619 | title = u'Passport Photograph', |
---|
| 620 | default = DEFAULT_PASSPORT_IMAGE_MALE, |
---|
[5980] | 621 | required = True , |
---|
[5753] | 622 | ) |
---|
| 623 | # |
---|
| 624 | # Higher Educational Data |
---|
| 625 | # |
---|
| 626 | |
---|
| 627 | # |
---|
| 628 | # First sitting data |
---|
| 629 | # |
---|
| 630 | fst_sit_fname = schema.TextLine( |
---|
| 631 | title = u'Full Name', |
---|
| 632 | ) |
---|
| 633 | |
---|
| 634 | # |
---|
| 635 | # Second sitting data |
---|
| 636 | # |
---|
| 637 | scd_sit_fname = schema.TextLine( |
---|
| 638 | title = u'Full Name', |
---|
| 639 | ) |
---|
| 640 | # |
---|
| 641 | # Application Data |
---|
| 642 | # |
---|
| 643 | application_date = schema.Date( |
---|
| 644 | title = u'Application Date', |
---|
| 645 | ) |
---|
| 646 | status = schema.TextLine( |
---|
| 647 | # XXX: should be 'status' type |
---|
| 648 | title = u'Application Status', |
---|
| 649 | ) |
---|
| 650 | screening_date = schema.Date( |
---|
| 651 | title = u'Screening Date', |
---|
| 652 | ) |
---|
| 653 | screening_type = schema.TextLine( |
---|
| 654 | # XXX: schould be choice |
---|
| 655 | title = u'Screening Type', |
---|
| 656 | ) |
---|
| 657 | screening_score = schema.TextLine( |
---|
| 658 | title = u'Screening Score', |
---|
| 659 | ) |
---|
| 660 | entry_session = schema.TextLine( |
---|
| 661 | # XXX: should be choice |
---|
| 662 | # XXX: should have sensible default: upcoming session |
---|
| 663 | title = u'Entry Session', |
---|
| 664 | ) |
---|
| 665 | import_record_no = schema.TextLine( |
---|
| 666 | title = u'Import Record No.', |
---|
| 667 | ) |
---|
| 668 | imported_by = schema.TextLine( |
---|
| 669 | title = u'Imported By', |
---|
| 670 | ) |
---|
| 671 | import_date = schema.Datetime( |
---|
| 672 | title = u'Import Date', |
---|
| 673 | ) |
---|
| 674 | import_from = schema.TextLine( |
---|
| 675 | title = u'Import Source', |
---|
| 676 | ) |
---|
| 677 | |
---|
| 678 | class IApplicantPDEEditData(IWAeUPObject): |
---|
| 679 | """The data set presented to PDE applicants. |
---|
| 680 | """ |
---|
[5941] | 681 | locked = schema.Bool( |
---|
| 682 | title = u'Form locked', |
---|
| 683 | default = False, |
---|
| 684 | readonly = True, |
---|
| 685 | ) |
---|
[5753] | 686 | access_code = schema.TextLine( |
---|
| 687 | title = u'Access Code', |
---|
| 688 | readonly = True, |
---|
| 689 | ) |
---|
| 690 | course1 = schema.TextLine( |
---|
| 691 | title = u'1st Choice Course of Study', |
---|
| 692 | readonly = True, |
---|
| 693 | ) |
---|
| 694 | course2 = schema.TextLine( |
---|
| 695 | title = u'2nd Choice Course of Study', |
---|
| 696 | required = False, |
---|
| 697 | ) |
---|
| 698 | course3 = schema.TextLine( |
---|
| 699 | title = u'3rd Choice Course of Study', |
---|
| 700 | required = False, |
---|
| 701 | ) |
---|
| 702 | lastname = schema.TextLine( |
---|
| 703 | title = u'Name', |
---|
| 704 | readonly = True, |
---|
| 705 | ) |
---|
| 706 | date_of_birth = schema.Date( |
---|
| 707 | title = u'Date of Birth', |
---|
| 708 | required = True, |
---|
| 709 | ) |
---|
| 710 | lga = schema.TextLine( |
---|
| 711 | # XXX: should be choice |
---|
| 712 | title = u'State/LGA (confirmed by applicant)', |
---|
| 713 | required = False, |
---|
| 714 | ) |
---|
| 715 | email = schema.TextLine( |
---|
| 716 | title = u'Email', |
---|
| 717 | required = False, |
---|
| 718 | ) |
---|
| 719 | phone = schema.TextLine( |
---|
| 720 | title = u'Phone', |
---|
| 721 | required = False, |
---|
| 722 | ) |
---|
| 723 | aos = schema.TextLine( |
---|
| 724 | # XXX: should be choice |
---|
| 725 | title = u'Area of Specialisation', |
---|
| 726 | required = False, |
---|
| 727 | ) |
---|
| 728 | subj1 = schema.TextLine( |
---|
| 729 | # XXX: should be choice |
---|
| 730 | title = u'1st Choice of Study', |
---|
| 731 | readonly = True, |
---|
| 732 | ) |
---|
| 733 | subj2 = schema.TextLine( |
---|
| 734 | # XXX: should be choice |
---|
| 735 | title = u'2nd Choice of Study', |
---|
| 736 | required = False, |
---|
| 737 | ) |
---|
| 738 | subj3 = schema.TextLine( |
---|
| 739 | # XXX: should be choice |
---|
| 740 | title = u'3rd Choice of Study', |
---|
| 741 | required = False, |
---|
| 742 | ) |
---|
[6076] | 743 | |
---|
[5753] | 744 | # |
---|
| 745 | # Application Data |
---|
| 746 | # |
---|
| 747 | application_date = schema.Date( |
---|
| 748 | title = u'Application Date', |
---|
| 749 | readonly = True, |
---|
| 750 | ) |
---|
| 751 | status = schema.TextLine( |
---|
| 752 | # XXX: should be 'status' type |
---|
| 753 | title = u'Application Status', |
---|
| 754 | readonly = True, |
---|
| 755 | ) |
---|
| 756 | screening_date = schema.Date( |
---|
| 757 | title = u'Screening Date', |
---|
| 758 | readonly = True, |
---|
| 759 | ) |
---|
| 760 | passport = ImageFile( |
---|
| 761 | title = u'Passport Photograph', |
---|
| 762 | default = DEFAULT_PASSPORT_IMAGE_MALE, |
---|
| 763 | required = True, |
---|
| 764 | ) |
---|
[5952] | 765 | confirm_passport = schema.Bool( |
---|
| 766 | title = u"Confirmation that photograph represents applicant ticked.", |
---|
| 767 | default = False, |
---|
| 768 | required = True, |
---|
| 769 | ) |
---|
[5758] | 770 | |
---|
[6076] | 771 | |
---|
[5758] | 772 | class IApplicantPrincipalInfo(IPrincipalInfo): |
---|
| 773 | """Infos about principals that are applicants. |
---|
| 774 | """ |
---|
| 775 | access_code = Attribute("The Access Code the user purchased") |
---|
| 776 | |
---|
| 777 | class IApplicantPrincipal(IPrincipal): |
---|
| 778 | """A principal that is an applicant. |
---|
| 779 | |
---|
| 780 | This interface extends zope.security.interfaces.IPrincipal and |
---|
| 781 | requires also an `id` and other attributes defined there. |
---|
| 782 | """ |
---|
| 783 | access_code = schema.TextLine( |
---|
| 784 | title = u'Access Code', |
---|
| 785 | description = u'The access code purchased by the user.', |
---|
| 786 | required = True, |
---|
| 787 | readonly = True) |
---|
| 788 | |
---|
| 789 | class IApplicantsFormChallenger(Interface): |
---|
| 790 | """A challenger that uses a browser form to collect applicant |
---|
| 791 | credentials. |
---|
| 792 | """ |
---|
| 793 | loginpagename = schema.TextLine( |
---|
| 794 | title = u'Loginpagename', |
---|
| 795 | description = u"""Name of the login form used by challenger. |
---|
| 796 | |
---|
| 797 | The form must provide an ``access_code`` input field. |
---|
| 798 | """) |
---|
| 799 | |
---|
| 800 | accesscode_field = schema.TextLine( |
---|
| 801 | title = u'Access code field', |
---|
| 802 | description = u'''Field of the login page which is looked up for |
---|
| 803 | access_code''', |
---|
| 804 | default = u'access_code', |
---|
| 805 | ) |
---|
| 806 | |
---|
| 807 | |
---|
| 808 | class IApplicantSessionCredentials(Interface): |
---|
| 809 | """Interface for storing and accessing applicant credentials in a |
---|
| 810 | session. |
---|
| 811 | """ |
---|
| 812 | |
---|
| 813 | def __init__(access_code): |
---|
| 814 | """Create applicant session credentials.""" |
---|
| 815 | |
---|
| 816 | def getAccessCode(): |
---|
| 817 | """Return the access code.""" |
---|
| 818 | |
---|
| 819 | |
---|
[5846] | 820 | class IApplicantsContainerProvider(Interface): |
---|
[5820] | 821 | """A provider for applicants containers. |
---|
| 822 | |
---|
| 823 | Applicants container providers are meant to be looked up as |
---|
| 824 | utilities. This way we can find all applicant container types |
---|
| 825 | defined somewhere. |
---|
| 826 | |
---|
| 827 | Each applicants container provider registered as utility provides |
---|
| 828 | one container type and one should be able to call the `factory` |
---|
| 829 | attribute to create an instance of the requested container type. |
---|
| 830 | |
---|
| 831 | .. THE FOLLOWING SHOULD GO INTO SPHINX DOCS (and be tested) |
---|
[6076] | 832 | |
---|
[5820] | 833 | Samples |
---|
| 834 | ******* |
---|
[6076] | 835 | |
---|
[5820] | 836 | Given, you had an IApplicantsContainer implementation somewhere |
---|
| 837 | and you would like to make it findable on request, then you would |
---|
| 838 | normally create an appropriate provider utility like this:: |
---|
| 839 | |
---|
| 840 | import grok |
---|
[5846] | 841 | from waeup.sirp.applicants.interfaces import IApplicantsContainerProvider |
---|
[5820] | 842 | |
---|
| 843 | class MyContainerProvider(grok.GlobalUtility): |
---|
[5846] | 844 | grok.implements(IApplicantsContainerProvider) |
---|
[5820] | 845 | grok.name('MyContainerProvider') # Must be unique |
---|
| 846 | factory = MyContainer # A class implementing IApplicantsContainer |
---|
| 847 | # or derivations thereof. |
---|
| 848 | |
---|
| 849 | This utility would be registered on startup and could then be used |
---|
| 850 | like this: |
---|
| 851 | |
---|
| 852 | >>> from zope.component import getAllUtilitiesRegisteredFor |
---|
| 853 | >>> from waeup.sirp.applicants.interfaces import ( |
---|
[5846] | 854 | ... IApplicantsContainerProvider) |
---|
[5820] | 855 | >>> all_providers = getAllUtilitiesRegisteredFor( |
---|
[5846] | 856 | ... IApplicantsContainerProvider) |
---|
[5820] | 857 | >>> all_providers |
---|
| 858 | [<MyContainerProvider object at 0x...>] |
---|
| 859 | |
---|
| 860 | You could look up this specific provider by name: |
---|
| 861 | |
---|
| 862 | >>> from zope.component import getUtility |
---|
[5846] | 863 | >>> p = getUtility(IApplicantsContainerProvider, name='MyProvider') |
---|
[5820] | 864 | >>> p |
---|
| 865 | <MyContainerProvider object at 0x...> |
---|
[6076] | 866 | |
---|
[5820] | 867 | An applicants container would then be created like this: |
---|
| 868 | |
---|
| 869 | >>> provider = all_providers[0] |
---|
| 870 | >>> container = provider.factory() |
---|
| 871 | >>> container |
---|
| 872 | <MyContainer object at 0x...> |
---|
| 873 | |
---|
| 874 | """ |
---|
| 875 | factory = Attribute("A class that can create instances of the " |
---|
| 876 | "requested container type") |
---|