source: main/waeup.sirp/trunk/src/waeup/sirp/applicants/interfaces.py @ 5755

Last change on this file since 5755 was 5753, checked in by uli, 14 years ago

Move main applicant interfaces to applicants package and try to fix first imports.

File size: 18.6 KB
Line 
1##
2## interfaces.py
3## Login : <uli@pu.smp.net>
4## Started on  Sun Jan 16 15:30:01 2011 Uli Fouquet
5## $Id$
6##
7## Copyright (C) 2011 Uli Fouquet
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.
12##
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.
17##
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##
22"""Interfaces regarding student applicants and related components.
23"""
24import os
25import waeup.sirp.browser
26from hurry.file import HurryFile
27from zope import schema
28from zc.sourcefactory.basic import BasicSourceFactory
29from waeup.sirp.image.schema import ImageFile
30from waeup.sirp.interfaces import IWAeUPObject, SimpleWAeUPVocabulary
31
32IMAGE_PATH = os.path.join(
33    os.path.dirname(waeup.sirp.browser.__file__),
34    'static'
35    )
36DEFAULT_PASSPORT_IMAGE_MALE = HurryFile(
37    'passport.jpg',
38    open(os.path.join(IMAGE_PATH, 'placeholder_m.jpg')).read(),
39    )
40DEFAULT_PASSPORT_IMAGE_FEMALE = HurryFile(
41    'passport.jpg',
42    open(os.path.join(IMAGE_PATH, 'placeholder_f.jpg')).read(),
43    )
44
45#: Categories of applications we support.
46#: Yet not complete nor correct.
47APPLICATION_CATEGORIES = (
48    ('Direct Entry Screening Exam (PDE)', 'pde'),
49    ('Post-UME', 'pume'),
50    ('Post-UDE', 'pude'),
51    ('PCE', 'pce'),
52    ('Common Entry Screening Test (CEST)', 'cest'),
53    )
54
55#: A :class:`waeup.sirp.interfaces.SimpleWAeUPVocabulary` of supported
56#: application categories.
57application_categories_vocab = SimpleWAeUPVocabulary(*APPLICATION_CATEGORIES)
58
59class GenderSource(BasicSourceFactory):
60    """A gender source delivers basically a mapping
61       ``{'m': 'male', 'f': 'female'}``
62
63       Using a source, we make sure that the tokens (which are
64       stored/expected for instance from CSV files) are something one
65       can expect and not cryptic IntIDs.
66    """
67    def getValues(self):
68        return ['m', 'f']
69
70    def getToken(self, value):
71        return value[0].lower()
72       
73    def getTitle(self, value):
74        if value == 'm':
75            return 'male'
76        if value == 'f':
77            return 'female'
78
79class IResultEntry(IWAeUPObject):
80    subject = schema.TextLine(
81        title = u'Subject',
82        description = u'The subject',
83        required=False,
84        )
85    score = schema.TextLine(
86        title = u'Score',
87        description = u'The score',
88        required=False,
89        )
90
91class IApplicantsRoot(IWAeUPObject):
92    """A container for university applicants containers.
93    """
94    def addApplicantsContainer(container, name=None):
95        """Add an applicants container.
96
97        Adds an applicants container that implements `interface`
98        under the name `name`.
99
100        `container` the container instance to be added. Should
101          implement :class:`IApplicantsContainer`.
102
103        `name`
104          the name under which the container will be accessible. We
105          usually use names like ``pume_2011`` to indicate, that the
106          new container will contain university applicants for a
107          certain screening type (``pume``) and of the year 2011.
108        """
109
110class IApplicantsContainer(IWAeUPObject):
111    """An applicants container contains university applicants.
112
113    """
114    REQUIRES_JAMBDATA = schema.Bool(
115        title = u'JAMB data required',
116        description = u'This container requires JAMB data to be available.',
117        required = True,
118        default = False,
119        )
120       
121    name = schema.TextLine(
122        title = u'Internal ID',
123        required = True,
124        )
125
126    title = schema.TextLine(
127        title = u'Short description of the type of applicants stored here.',
128        required = True,
129        default = u'Untitled',
130        )
131   
132    description = schema.Text(
133        title = u'Human readable description in reST format',
134        required = False,
135        default = u'Not set.'
136        )
137
138    startdate = schema.Date(
139        title = u'Date when the application period starts',
140        required = False,
141        default = None,
142        )
143
144    enddate = schema.Date(
145        title = u'Date when the application period ends',
146        required = False,
147        default = None,
148        )
149
150    strict_deadline = schema.Bool(
151        title = u'Forbid additions after deadline (enddate)',
152        required = True,
153        default = True,
154        )
155
156    def archive(id=None):
157        """Create on-dist archive of applicants stored in this term.
158
159        If id is `None`, all applicants are archived.
160
161        If id contains a single id string, only the respective
162        applicants are archived.
163
164        If id contains a list of id strings all of the respective
165        applicants types are saved to disk.
166        """
167
168    def clear(id=None, archive=True):
169        """Remove applicants of type given by 'id'.
170
171        Optionally archive the applicants.
172       
173        If id is `None`, all applicants are archived.
174
175        If id contains a single id string, only the respective
176        applicants are archived.
177
178        If id contains a list of id strings all of the respective
179        applicant types are saved to disk.
180
181        If `archive` is ``False`` none of the archive-handling is done
182        and respective applicants are simply removed from the
183        database.
184        """
185class IApplicantBaseData(IWAeUPObject):
186    """The data for an applicant.
187
188    This is a base interface with no field (except ``reg_no``)
189    required. For use with importers, forms, etc., please use one of
190    the derived interfaces below, which set more fields to required
191    state, depending on use-case.
192    """
193    reg_no = schema.TextLine(
194        title = u'JAMB Registration Number',
195        )
196    access_code = schema.TextLine(
197        title = u'Access Code',
198        required = False,
199        )
200    serial = schema.TextLine(
201        title = u'Serial Number',
202        required = False,
203        )
204    course1 = schema.TextLine(
205        title = u'1st Choice Course of Study',
206        required = False,
207        )
208    course2 = schema.TextLine(
209        title = u'2nd Choice Course of Study',
210        required = False,
211        )
212    course3 = schema.TextLine(
213        title = u'3rd Choice Course of Study',
214        required = False,
215        )
216    firstname = schema.TextLine(
217        title = u'First Name',
218        required = False,
219        )
220    middlenames = schema.TextLine(
221        title = u'Middle Names',
222        required = False,
223        )
224    lastname = schema.TextLine(
225        title = u'Surname/Full Name',
226        required = False,
227        )
228    jamb_age = schema.Int(
229        title = u'Age (provided by JAMB)',
230        required = False,
231        )
232    date_of_birth = schema.Date(
233        title = u'Date of Birth',
234        required = False,
235        )
236    jamb_state = schema.TextLine(
237        title = u'State (provided by JAMB)',
238        required = False,
239        )
240    jamb_lga = schema.TextLine(
241        title = u'LGA (provided by JAMB)',
242        required = False,
243        )
244    lga = schema.TextLine(
245        # XXX: should be choice
246        title = u'State/LGA (confirmed by applicant)',
247        required = False,
248        )
249    sex = schema.Choice(
250        title = u'Sex',
251        source = GenderSource(),
252        default = u'm',
253        required = False,
254        )
255    email = schema.TextLine(
256        title = u'Email',
257        required = False,
258        )
259    phone = schema.TextLine(
260        title = u'Phone',
261        required = False,
262        )
263    #passport = schema.Bool(
264    #    title = u'Passport Photograph',
265    #    default = True,
266    #    required = False,
267    #    )
268    passport = ImageFile(
269        title = u'Passport Photograph',
270        default = DEFAULT_PASSPORT_IMAGE_MALE,
271        required = True,
272        )
273    aos = schema.TextLine(
274        # XXX: should be choice
275        title = u'Area of Specialisation',
276        required = False,
277        )
278    subj1 = schema.TextLine(
279        # XXX: should be choice
280        title = u'1st Choice of Study',
281        required = False,
282        )
283    subj2 = schema.TextLine(
284        # XXX: should be choice
285        title = u'2nd Choice of Study',
286        required = False,
287        )
288    subj3 = schema.TextLine(
289        # XXX: should be choice
290        title = u'3rd Choice of Study',
291        required = False,
292        )
293    #
294    # Higher Educational Data
295    #
296    hq_matric_no = schema.TextLine(
297        title = u'Former Matric Number',
298        required = False,
299        )
300    hq_type = schema.TextLine(
301        title = u'Higher Qualification',
302        required = False,
303        )
304    hq_grade = schema.TextLine(
305        title = u'Higher Qualification Grade',
306        required = False,
307        )
308    hq_school = schema.TextLine(
309        title = u'School Attended',
310        required = False,
311        )
312    hq_session = schema.TextLine(
313        title = u'Session Obtained',
314        required = False,
315        )
316    hq_disc = schema.TextLine(
317        title = u'Discipline',
318        required = False,
319        )
320    #
321    # First sitting data
322    #
323    fst_sit_fname = schema.TextLine(
324        title = u'Full Name',
325        required = False,
326        )
327    fst_sit_no = schema.TextLine(
328        title = u'Exam Number',
329        required = False,
330        )
331    fst_sit_date = schema.Date(
332        title = u'Exam Date (dd/mm/yyyy)',
333        required = False,
334        )
335    fst_sit_type = schema.TextLine(
336        # XXX: Should be choice
337        title = u'Exam Type',
338        required = False,
339        )
340    fst_sit_results = schema.List(
341        title = u'Results',
342        required = False,
343        value_type = schema.Object(
344            title = u'Entries',
345            schema = IResultEntry,
346            required = False,
347            )
348        )
349    scd_sit_fname = schema.TextLine(
350        title = u'Full Name',
351        required = False,
352        )
353    scd_sit_no = schema.TextLine(
354        title = u'Exam Number',
355        required = False,
356        )
357    scd_sit_date = schema.Date(
358        title = u'Exam Date (dd/mm/yyyy)',
359        required = False,
360        )
361    scd_sit_type = schema.TextLine(
362        # XXX: Should be choice
363        title = u'Exam Type',
364        required = False,
365        )
366    scd_sit_results = schema.TextLine(
367        # XXX: Should be nested list of choices
368        title = u'Results',
369        required = False,
370        )
371    #
372    # JAMB scores
373    #
374    eng_score = schema.TextLine(
375        title = u"'English' score",
376        required = False,
377        )
378    subj1score = schema.TextLine(
379        title = u'1st Choice of Study Score',
380        required = False,
381        )
382    subj2score = schema.TextLine(
383        title = u'2nd Choice of Study Score',
384        required = False,
385        )
386    subj3score = schema.TextLine(
387        title = u'3rd Choice of Study Score',
388        required = False,
389        )
390    # XXX: Total score???
391   
392    #
393    # Application Data
394    #
395    application_date = schema.Date(
396        title = u'Application Date',
397        required = False,
398        )
399    status = schema.TextLine(
400        # XXX: should be 'status' type
401        title = u'Application Status',
402        required = False,
403        )
404    screening_date = schema.Date(
405        title = u'Screening Date',
406        required = False,
407        )
408    screening_type = schema.TextLine(
409        # XXX: schould be choice
410        title = u'Screening Type',
411        required = False,
412        )
413    screening_score = schema.TextLine(
414        title = u'Screening Score',
415        required = False,
416        )
417    screening_venue = schema.TextLine(
418        title = u'Screening Venue',
419        required = False,
420        )
421    total_score = schema.TextLine(
422        title = u'Total Score',
423        required = False,
424        )
425    course_admitted = schema.TextLine(
426        # XXX: should be choice
427        title = u'Admitted Course of Study',
428        required = False,
429        )
430    department = schema.TextLine(
431        # XXX: if we have a course, dept. is not necessary
432        title = u'Department',
433        required = False,
434        )
435    faculty = schema.TextLine(
436        # XXX: if we have a course, faculty is not necessary
437        title = u'Faculty',
438        required = False,
439        )
440    entry_session = schema.TextLine(
441        # XXX: should be choice, should have sensible default: upcoming session
442        title = u'Entry Session',
443        required = False,
444        )
445    notice = schema.Text(
446        title = u'Notice',
447        required = False,
448        )
449    student_id = schema.TextLine(
450        title = u'Student ID',
451        required = False,
452        )
453    import_record_no = schema.TextLine(
454        title = u'Import Record No.',
455        required = False,
456        )
457    imported_by = schema.TextLine(
458        title = u'Imported By',
459        required = False,
460        )
461    import_date = schema.Datetime(
462        title = u'Import Date',
463        required = False,
464        )
465    import_from = schema.TextLine(
466        title = u'Import Source',
467        required = False,
468        )
469
470   
471class IApplicant(IApplicantBaseData):
472    """An applicant.
473
474    This is basically the applicant base data. Here we repeat the
475    fields from base data only with the `required` attribute of
476    required attributes set to True (which is the default).
477    """
478    access_code = schema.TextLine(
479        title = u'Access Code',
480        )
481    course1 = schema.TextLine(
482        title = u'1st Choice Course of Study',
483        )
484    firstname = schema.TextLine(
485        title = u'First Name',
486        )
487    middlenames = schema.TextLine(
488        title = u'Middle Names',
489        )
490    lastname = schema.TextLine(
491        title = u'Surname/Full Name',
492        )
493    date_of_birth = schema.Date(
494        title = u'Date of Birth',
495        )
496    jamb_state = schema.TextLine(
497        title = u'State (provided by JAMB)',
498        )
499    jamb_lga = schema.TextLine(
500        title = u'LGA (provided by JAMB)',
501        )
502    lga = schema.TextLine(
503        # XXX: should be choice
504        title = u'State/LGA (confirmed by applicant)',
505        )
506    sex = schema.Choice(
507        title = u'Sex',
508        source = GenderSource(),
509        default = u'm',
510        )
511    #passport = schema.Bool(
512    #    title = u'Passport Photograph',
513    #    default = True,
514    #    )
515    passport = ImageFile(
516        title = u'Passport Photograph',
517        default = DEFAULT_PASSPORT_IMAGE_MALE,
518        required = True,
519        )
520    #
521    # Higher Educational Data
522    #
523
524    #
525    # First sitting data
526    #
527    fst_sit_fname = schema.TextLine(
528        title = u'Full Name',
529        )
530
531    #
532    # Second sitting data
533    #
534    scd_sit_fname = schema.TextLine(
535        title = u'Full Name',
536        )
537    #
538    # JAMB scores
539    #
540   
541    #
542    # Application Data
543    #
544    application_date = schema.Date(
545        title = u'Application Date',
546        )
547    status = schema.TextLine(
548        # XXX: should be 'status' type
549        title = u'Application Status',
550        )
551    screening_date = schema.Date(
552        title = u'Screening Date',
553        )
554    screening_type = schema.TextLine(
555        # XXX: schould be choice
556        title = u'Screening Type',
557        )
558    screening_score = schema.TextLine(
559        title = u'Screening Score',
560        )
561    entry_session = schema.TextLine(
562        # XXX: should be choice
563        # XXX: should have sensible default: upcoming session
564        title = u'Entry Session',
565        )
566    import_record_no = schema.TextLine(
567        title = u'Import Record No.',
568        )
569    imported_by = schema.TextLine(
570        title = u'Imported By',
571        )
572    import_date = schema.Datetime(
573        title = u'Import Date',
574        )
575    import_from = schema.TextLine(
576        title = u'Import Source',
577        )
578
579class IApplicantPDEEditData(IWAeUPObject):
580    """The data set presented to PDE applicants.
581    """
582    reg_no = schema.TextLine(
583        title = u'JAMB Registration Number',
584        readonly = True,
585        )
586    access_code = schema.TextLine(
587        title = u'Access Code',
588        readonly = True,
589        )
590    course1 = schema.TextLine(
591        title = u'1st Choice Course of Study',
592        readonly = True,
593        )
594    course2 = schema.TextLine(
595        title = u'2nd Choice Course of Study',
596        required = False,
597        )
598    course3 = schema.TextLine(
599        title = u'3rd Choice Course of Study',
600        required = False,
601        )
602    lastname = schema.TextLine(
603        title = u'Name',
604        readonly = True,
605        )
606    jamb_age = schema.Int(
607        title = u'Age',
608        readonly = True,
609        )
610    date_of_birth = schema.Date(
611        title = u'Date of Birth',
612        required = True,
613        )
614    jamb_state = schema.TextLine(
615        title = u'State (provided by JAMB)',
616        readonly = True,
617        )
618    jamb_lga = schema.TextLine(
619        title = u'LGA (provided by JAMB)',
620        readonly = True,
621        )
622    lga = schema.TextLine(
623        # XXX: should be choice
624        title = u'State/LGA (confirmed by applicant)',
625        required = False,
626        )
627    email = schema.TextLine(
628        title = u'Email',
629        required = False,
630        )
631    phone = schema.TextLine(
632        title = u'Phone',
633        required = False,
634        )
635    aos = schema.TextLine(
636        # XXX: should be choice
637        title = u'Area of Specialisation',
638        required = False,
639        )
640    subj1 = schema.TextLine(
641        # XXX: should be choice
642        title = u'1st Choice of Study',
643        readonly = True,
644        )
645    subj2 = schema.TextLine(
646        # XXX: should be choice
647        title = u'2nd Choice of Study',
648        required = False,
649        )
650    subj3 = schema.TextLine(
651        # XXX: should be choice
652        title = u'3rd Choice of Study',
653        required = False,
654        )
655   
656    #
657    # Application Data
658    #
659    application_date = schema.Date(
660        title = u'Application Date',
661        readonly = True,
662        )
663    status = schema.TextLine(
664        # XXX: should be 'status' type
665        title = u'Application Status',
666        readonly = True,
667        )
668    screening_date = schema.Date(
669        title = u'Screening Date',
670        readonly = True,
671        )
672    #passport = schema.Bool(
673    #    title = u'Passport Photograph',
674    #    default = True,
675    #    required = False,
676    #    ),
677    #passport = schema.Bytes(
678    #    title = u'Passport Photograph',
679    #    required = True,
680    #    )
681    #passport = schema.Object(
682    #    title = u'Passport Photograph',
683    #    required = True,
684    #    schema = IImage)
685    passport = ImageFile(
686        title = u'Passport Photograph',
687        default = DEFAULT_PASSPORT_IMAGE_MALE,
688        required = True,
689        )
Note: See TracBrowser for help on using the repository browser.