source: main/waeup.sirp/branches/ulif-fasttables/src/waeup/sirp/jambtables/interfaces.py @ 5320

Last change on this file since 5320 was 5319, checked in by uli, 14 years ago
  • Add a source for gender field.
  • Add applicant interfaces designed for use with special cases (importing PDE data, applicant editing, etc.).
  • Clean up some fields.
File size: 14.4 KB
Line 
1##
2## interfaces.py
3## Login : <uli@pu.smp.net>
4## Started on  Sun Jun 27 11:06:23 2010 Uli Fouquet
5## $Id$
6##
7## Copyright (C) 2010 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 for JAMB data tables and related components.
23"""
24from waeup.sirp.interfaces import IWAeUPObject
25from zc.sourcefactory.basic import BasicSourceFactory
26from zope.interface import Interface
27from zope import schema
28
29class GenderSource(BasicSourceFactory):
30    """A gender source delivers basically a mapping
31       ``{'m': 'male', 'f': 'female'}``
32
33       Using a source, we make sure that the tokens (which are
34       stored/expected for instance from CSV files) are something one
35       can expect and not cryptic IntIDs.
36    """
37    def getValues(self):
38        return ['m', 'f']
39
40    def getToken(self, value):
41        return value[0].lower()
42       
43    def getTitle(self, value):
44        if value == 'm':
45            return 'male'
46        if value == 'f':
47            return 'female'
48
49class IJAMBDataTable(IWAeUPObject):
50    """A table containing JAMB data.
51    """
52    import_datetime = schema.Datetime(
53        title = u'Datetime of import of contained data.',
54        required = False,
55        )
56
57    importer_username = schema.TextLine(
58        title = u'Name of user who initiated import.',
59        required = False,
60        )
61
62    def __iter__():
63        """An iterator over all data elements.
64        """
65
66    def keys():
67        """Get iterator over all registration numbers of data.
68        """
69
70    def items():
71        """Get iterator over tuples of registration numbers and datasets.
72        """
73
74    def clear():
75        """Clear all data contained.
76
77        This will also erase any import data.
78        """
79
80    def importFromCSV(filepath, username=None):
81        """Import data from filepath.
82
83        `filepath` - the path to the CSV file to import data from.
84
85        `username` - the (optional) username of the importing person.
86        """
87       
88class IResultEntry(IWAeUPObject):
89    subject = schema.TextLine(
90        title = u'Subject',
91        description = u'The subject',
92        required=False,
93        )
94    score = schema.TextLine(
95        title = u'Score',
96        description = u'The score',
97        required=False,
98        )
99
100class IApplicantBaseData(IWAeUPObject):
101    """The data for an applicant.
102
103    This is a base interface with no field (except ``reg_no``)
104    required. For use with importers, forms, etc., please use one of
105    the derived interfaces below, which set more fields to required
106    state, depending on use-case.
107    """
108    reg_no = schema.TextLine(
109        title = u'JAMB Registration Number',
110        )
111    access_code = schema.TextLine(
112        title = u'Access Code',
113        required = False,
114        )
115    serial = schema.TextLine(
116        title = u'Serial Number',
117        required = False,
118        )
119    course1 = schema.TextLine(
120        title = u'1st Choice Course of Study',
121        required = False,
122        )
123    course2 = schema.TextLine(
124        title = u'2nd Choice Course of Study',
125        required = False,
126        )
127    course3 = schema.TextLine(
128        title = u'3rd Choice Course of Study',
129        required = False,
130        )
131    firstname = schema.TextLine(
132        title = u'First Name',
133        required = False,
134        )
135    middlenames = schema.TextLine(
136        title = u'Middle Names',
137        required = False,
138        )
139    lastname = schema.TextLine(
140        title = u'Surname/Full Name',
141        required = False,
142        )
143    jamb_age = schema.Int(
144        title = u'Age (provided by JAMB)',
145        required = False,
146        )
147    date_of_birth = schema.Date(
148        title = u'Date of Birth',
149        required = False,
150        )
151    jamb_state = schema.TextLine(
152        title = u'State (provided by JAMB)',
153        required = False,
154        )
155    jamb_lga = schema.TextLine(
156        title = u'LGA (provided by JAMB)',
157        required = False,
158        )
159    lga = schema.TextLine(
160        # XXX: should be choice
161        title = u'State/LGA (confirmed by applicant)',
162        required = False,
163        )
164    sex = schema.Choice(
165        title = u'Sex',
166        source = GenderSource(),
167        default = u'm',
168        required = False,
169        )
170    email = schema.TextLine(
171        title = u'Email',
172        required = False,
173        )
174    phone = schema.TextLine(
175        title = u'Phone',
176        required = False,
177        )
178    passport = schema.Bool(
179        title = u'Passport Photograph',
180        default = True,
181        required = False,
182        )
183    aos = schema.TextLine(
184        # XXX: should be choice
185        title = u'Area of Specialisation',
186        required = False,
187        )
188    subj1 = schema.TextLine(
189        # XXX: should be choice
190        title = u'1st Choice of Study',
191        required = False,
192        )
193    subj2 = schema.TextLine(
194        # XXX: should be choice
195        title = u'2nd Choice of Study',
196        required = False,
197        )
198    subj3 = schema.TextLine(
199        # XXX: should be choice
200        title = u'3rd Choice of Study',
201        required = False,
202        )
203    #
204    # Higher Educational Data
205    #
206    hq_matric_no = schema.TextLine(
207        title = u'Former Matric Number',
208        required = False,
209        )
210    hq_type = schema.TextLine(
211        title = u'Higher Qualification',
212        required = False,
213        )
214    hq_grade = schema.TextLine(
215        title = u'Higher Qualification Grade',
216        required = False,
217        )
218    hq_school = schema.TextLine(
219        title = u'School Attended',
220        required = False,
221        )
222    hq_session = schema.TextLine(
223        title = u'Session Obtained',
224        required = False,
225        )
226    hq_disc = schema.TextLine(
227        title = u'Discipline',
228        required = False,
229        )
230    #
231    # First sitting data
232    #
233    fst_sit_fname = schema.TextLine(
234        title = u'Full Name',
235        required = False,
236        )
237    fst_sit_no = schema.TextLine(
238        title = u'Exam Number',
239        required = False,
240        )
241    fst_sit_date = schema.Date(
242        title = u'Exam Date (dd/mm/yyyy)',
243        required = False,
244        )
245    fst_sit_type = schema.TextLine(
246        # XXX: Should be choice
247        title = u'Exam Type',
248        required = False,
249        )
250    fst_sit_results = schema.List(
251        title = u'Results',
252        required = False,
253        value_type = schema.Object(
254            title = u'Entries',
255            schema = IResultEntry,
256            required = False,
257            )
258        )
259    scd_sit_fname = schema.TextLine(
260        title = u'Full Name',
261        required = False,
262        )
263    scd_sit_no = schema.TextLine(
264        title = u'Exam Number',
265        required = False,
266        )
267    scd_sit_date = schema.Date(
268        title = u'Exam Date (dd/mm/yyyy)',
269        required = False,
270        )
271    scd_sit_type = schema.TextLine(
272        # XXX: Should be choice
273        title = u'Exam Type',
274        required = False,
275        )
276    scd_sit_results = schema.TextLine(
277        # XXX: Should be nested list of choices
278        title = u'Results',
279        required = False,
280        )
281    #
282    # JAMB scores
283    #
284    eng_score = schema.TextLine(
285        title = u"'English' score",
286        required = False,
287        )
288    subj1score = schema.TextLine(
289        title = u'1st Choice of Study Score',
290        required = False,
291        )
292    subj2score = schema.TextLine(
293        title = u'2nd Choice of Study Score',
294        required = False,
295        )
296    subj3score = schema.TextLine(
297        title = u'3rd Choice of Study Score',
298        required = False,
299        )
300    # XXX: Total score???
301   
302    #
303    # Application Data
304    #
305    application_date = schema.Date(
306        title = u'Application Date',
307        required = False,
308        )
309    status = schema.TextLine(
310        # XXX: should be 'status' type
311        title = u'Application Status',
312        required = False,
313        )
314    screening_date = schema.Date(
315        title = u'Screening Date',
316        required = False,
317        )
318    screening_type = schema.TextLine(
319        # XXX: schould be choice
320        title = u'Screening Type',
321        required = False,
322        )
323    screening_score = schema.TextLine(
324        title = u'Screening Score',
325        required = False,
326        )
327    screening_venue = schema.TextLine(
328        title = u'Screening Venue',
329        required = False,
330        )
331    total_score = schema.TextLine(
332        title = u'Total Score',
333        required = False,
334        )
335    course_admitted = schema.TextLine(
336        # XXX: should be choice
337        title = u'Admitted Course of Study',
338        required = False,
339        )
340    department = schema.TextLine(
341        # XXX: if we have a course, dept. is not necessary
342        title = u'Department',
343        required = False,
344        )
345    faculty = schema.TextLine(
346        # XXX: if we have a course, faculty is not necessary
347        title = u'Faculty',
348        required = False,
349        )
350    entry_session = schema.TextLine(
351        # XXX: should be choice
352        # XXX: should have sensible default: upcoming session
353        title = u'Entry Session',
354        required = False,
355        )
356    notice = schema.Text(
357        title = u'Notice',
358        required = False,
359        )
360    student_id = schema.TextLine(
361        title = u'Student ID',
362        required = False,
363        )
364    import_record_no = schema.TextLine(
365        title = u'Import Record No.',
366        required = False,
367        )
368    imported_by = schema.TextLine(
369        title = u'Imported By',
370        required = False,
371        )
372    import_date = schema.Datetime(
373        title = u'Import Date',
374        required = False,
375        )
376    import_from = schema.TextLine(
377        title = u'Import Source',
378        required = False,
379        )
380
381   
382class IApplicant(IApplicantBaseData):
383    """An applicant.
384
385    This is basically the applicant base data. Here we repeat the
386    fields from base data only with the `required` attribute of
387    required attributes set to True (which is the default).
388    """
389    access_code = schema.TextLine(
390        title = u'Access Code',
391        )
392    course1 = schema.TextLine(
393        title = u'1st Choice Course of Study',
394        )
395    firstname = schema.TextLine(
396        title = u'First Name',
397        )
398    middlenames = schema.TextLine(
399        title = u'Middle Names',
400        )
401    lastname = schema.TextLine(
402        title = u'Surname/Full Name',
403        )
404    date_of_birth = schema.Date(
405        title = u'Date of Birth',
406        )
407    jamb_state = schema.TextLine(
408        title = u'State (provided by JAMB)',
409        )
410    jamb_lga = schema.TextLine(
411        title = u'LGA (provided by JAMB)',
412        )
413    lga = schema.TextLine(
414        # XXX: should be choice
415        title = u'State/LGA (confirmed by applicant)',
416        )
417    sex = schema.Choice(
418        title = u'Sex',
419        source = GenderSource(),
420        default = u'm',
421        )
422    passport = schema.Bool(
423        title = u'Passport Photograph',
424        default = True,
425        )
426    #
427    # Higher Educational Data
428    #
429
430    #
431    # First sitting data
432    #
433    fst_sit_fname = schema.TextLine(
434        title = u'Full Name',
435        )
436
437    #
438    # Second sitting data
439    #
440    scd_sit_fname = schema.TextLine(
441        title = u'Full Name',
442        )
443    #
444    # JAMB scores
445    #
446   
447    #
448    # Application Data
449    #
450    application_date = schema.Date(
451        title = u'Application Date',
452        )
453    status = schema.TextLine(
454        # XXX: should be 'status' type
455        title = u'Application Status',
456        )
457    screening_date = schema.Date(
458        title = u'Screening Date',
459        )
460    screening_type = schema.TextLine(
461        # XXX: schould be choice
462        title = u'Screening Type',
463        )
464    screening_score = schema.TextLine(
465        title = u'Screening Score',
466        )
467    entry_session = schema.TextLine(
468        # XXX: should be choice
469        # XXX: should have sensible default: upcoming session
470        title = u'Entry Session',
471        )
472    import_record_no = schema.TextLine(
473        title = u'Import Record No.',
474        )
475    imported_by = schema.TextLine(
476        title = u'Imported By',
477        )
478    import_date = schema.Datetime(
479        title = u'Import Date',
480        )
481    import_from = schema.TextLine(
482        title = u'Import Source',
483        )
484
485class IApplicantPDEImportData(IApplicantBaseData):
486    """Data for applicants, that passed PDE screening.
487
488    This data set should be suitable for imports from JAMB tables. It
489    is also basicall the basic applicant data from
490    :class:`IApplicantBaseData` only with the required fields set.
491
492    """
493    firstname = schema.TextLine(
494        title = u'First Name',
495        required = True,
496        )
497    middlenames = schema.TextLine(
498        title = u'Middle Names',
499        required = True,
500        )
501    lastname = schema.TextLine(
502        title = u'Surname/Full Name',
503        required = True,
504        )
505    date_of_birth = schema.Date(
506        title = u'Date of Birth',
507        required = True,
508        )
509    jamb_state = schema.TextLine(
510        title = u'State (provided by JAMB)',
511        required = True,
512        )
513    jamb_lga = schema.TextLine(
514        title = u'LGA (provided by JAMB)',
515        required = True,
516        )
517    course1 = schema.TextLine(
518        title = u'1st Choice Course of Study',
519        required = True,
520        )
521    screening_date = schema.Date(
522        title = u'Screening Date',
523        required = True,
524        )
525    screening_type = schema.TextLine(
526        # XXX: schould be choice
527        title = u'Screening Type',
528        required = True,
529        )
530    screening_venue = schema.TextLine(
531        title = u'Screening Venue',
532        required = True,
533        )
534    entry_session = schema.TextLine(
535        # XXX: should be choice
536        # XXX: should have sensible default: upcoming session
537        title = u'Entry Session',
538        required = True,
539        )
540   
541class IApplicantContainer(IWAeUPObject):
542    """A container for applicants.
543    """
Note: See TracBrowser for help on using the repository browser.