source: main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/applicants/interfaces.py @ 13142

Last change on this file since 13142 was 13142, checked in by Henrik Bettermann, 9 years ago

Implement CBT application (Uniben).
Extend ug application interface. Redefine omit tuples.
Remove jamb_age field.

  • Property svn:keywords set to Id
File size: 18.3 KB
Line 
1## $Id: interfaces.py 13142 2015-07-06 10:43:26Z 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
21from zope import schema
22from waeup.kofa.applicants.interfaces import (
23    contextual_reg_num_source,
24    IApplicantBaseData,
25    AppCatCertificateSource, CertificateSource)
26from waeup.kofa.schoolgrades import ResultEntryField
27from waeup.kofa.interfaces import (
28    SimpleKofaVocabulary, academic_sessions_vocab, validate_email)
29from waeup.kofa.schema import FormattedDate, TextLineChoice
30from waeup.kofa.students.vocabularies import nats_vocab, GenderSource
31from kofacustom.nigeria.interfaces import (
32    LGASource, high_qual, high_grade, exam_types)
33from kofacustom.nigeria.interfaces import MessageFactory as _
34from kofacustom.nigeria.payments.interfaces import INigeriaOnlinePayment
35
36# Fields to be omitted in all display forms. course_admitted is
37# rendered separately.
38
39OMIT_DISPLAY_FIELDS = ('locked', 'course_admitted',
40    'result_uploaded', 'suspended', 'special_application')
41
42# UG students are all undergraduate students.
43UG_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS
44UG_OMIT_PDF_FIELDS = UG_OMIT_DISPLAY_FIELDS + ('phone',)
45UG_OMIT_MANAGE_FIELDS = ('special_application',)
46UG_OMIT_EDIT_FIELDS = UG_OMIT_MANAGE_FIELDS + OMIT_DISPLAY_FIELDS + (
47    'student_id',
48    'notice',
49    'screening_score',
50    'screening_venue',
51    'screening_date',
52    #'jamb_age',
53    'jamb_subjects',
54    'jamb_score',
55    'jamb_reg_number',
56    'aggregate')
57
58# CBT is a subgroup of UG with the same interface.
59CBT_OMIT_FIELDS = (
60    'hq_type', 'hq_matric_no',
61    'hq_degree', 'hq_school',
62    'hq_session', 'hq_disc',)
63CBT_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS + CBT_OMIT_FIELDS
64CBT_OMIT_MANAGE_FIELDS = UG_OMIT_MANAGE_FIELDS + CBT_OMIT_FIELDS
65CBT_OMIT_EDIT_FIELDS = UG_OMIT_MANAGE_FIELDS + OMIT_DISPLAY_FIELDS + CBT_OMIT_FIELDS + (
66    'student_id',
67    'notice',
68    'screening_score',
69    'screening_venue',
70    'screening_date',
71    #'jamb_age',
72    #'jamb_subjects',
73    #'jamb_score',
74    #'jamb_reg_number',
75    'aggregate')
76CBT_OMIT_PDF_FIELDS = CBT_OMIT_DISPLAY_FIELDS + ('phone',)
77
78# PUTME is a subgroup of UG with the same interface.
79PUTME_OMIT_FIELDS = (
80    'hq_type', 'hq_matric_no',
81    'hq_degree', 'hq_school',
82    'hq_session', 'hq_disc',)
83PUTME_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS + PUTME_OMIT_FIELDS
84PUTME_OMIT_MANAGE_FIELDS = UG_OMIT_MANAGE_FIELDS + PUTME_OMIT_FIELDS
85PUTME_OMIT_EDIT_FIELDS = UG_OMIT_EDIT_FIELDS + PUTME_OMIT_FIELDS + (
86    'firstname', 'middlename', 'lastname', 'sex',
87    'course1', 'lga')
88PUTME_OMIT_PDF_FIELDS = PUTME_OMIT_DISPLAY_FIELDS + ('phone',)
89PUTME_OMIT_RESULT_SLIP_FIELDS = PUTME_OMIT_DISPLAY_FIELDS + (
90    'phone',
91    'date_of_birth', 'sex',
92    'nationality', 'lga', #'perm_address',
93    'course2', 'screening_venue',
94    'screening_date')
95
96# PUDE is a subgroup of UG with the same interface.
97PUDE_OMIT_FIELDS = (
98    'jamb_subjects','jamb_score', 'jamb_age', 'aggregate')
99PUDE_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS + PUDE_OMIT_FIELDS
100PUDE_OMIT_MANAGE_FIELDS = UG_OMIT_MANAGE_FIELDS + PUDE_OMIT_FIELDS
101PUDE_OMIT_EDIT_FIELDS = set(UG_OMIT_EDIT_FIELDS + PUDE_OMIT_FIELDS + (
102    'firstname', 'middlename', 'lastname', 'sex',
103    'course1', 'lga'))
104PUDE_OMIT_PDF_FIELDS = PUDE_OMIT_DISPLAY_FIELDS + ('phone',)
105PUDE_OMIT_RESULT_SLIP_FIELDS = PUDE_OMIT_DISPLAY_FIELDS + (
106    'phone',
107    'date_of_birth', 'sex',
108    'nationality', 'lga', #'perm_address',
109    'course2', 'screening_venue',
110    'screening_date')
111
112# PG has its own interface
113PG_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS
114PG_OMIT_PDF_FIELDS = PG_OMIT_DISPLAY_FIELDS + ('phone',)
115PG_OMIT_MANAGE_FIELDS = ('special_application',)
116PG_OMIT_EDIT_FIELDS = PG_OMIT_MANAGE_FIELDS + PG_OMIT_DISPLAY_FIELDS + (
117    'student_id', 'notice',
118    'screening_score', 'screening_venue',
119    'screening_date',)
120
121class INigeriaUGApplicant(IApplicantBaseData):
122    """An undergraduate applicant.
123
124    This interface defines the least common multiple of all fields
125    in ug application forms. In customized forms, fields can be excluded by
126    adding them to the UG_OMIT* tuples.
127    """
128
129    nationality = schema.Choice(
130        source = nats_vocab,
131        title = _(u'Nationality'),
132        required = False,
133        )
134    lga = schema.Choice(
135        source = LGASource(),
136        title = _(u'State/LGA (Nigerians only)'),
137        required = False,
138        )
139    #perm_address = schema.Text(
140    #    title = _(u'Permanent Address'),
141    #    required = False,
142    #    )
143    course1 = schema.Choice(
144        title = _(u'1st Choice Course of Study'),
145        source = AppCatCertificateSource(),
146        required = True,
147        )
148    course2 = schema.Choice(
149        title = _(u'2nd Choice Course of Study'),
150        source = AppCatCertificateSource(),
151        required = False,
152        )
153    hq_type = schema.Choice(
154        title = _(u'Qualification Obtained'),
155        required = False,
156        readonly = False,
157        vocabulary = high_qual,
158        )
159    hq_matric_no = schema.TextLine(
160        title = _(u'Former Matric Number'),
161        required = False,
162        readonly = False,
163        )
164    hq_degree = schema.Choice(
165        title = _(u'Class of Degree'),
166        required = False,
167        readonly = False,
168        vocabulary = high_grade,
169        )
170    hq_school = schema.TextLine(
171        title = _(u'Institution Attended'),
172        required = False,
173        readonly = False,
174        )
175    hq_session = schema.TextLine(
176        title = _(u'Years Attended'),
177        required = False,
178        readonly = False,
179        )
180    hq_disc = schema.TextLine(
181        title = _(u'Discipline'),
182        required = False,
183        readonly = False,
184        )
185    jamb_subjects = schema.Text(
186        title = _(u'Subjects and Scores'),
187        description = _(u'(one subject with score per line)'),
188        required = False,
189        )
190    jamb_score = schema.Int(
191        title = _(u'Total JAMB Score'),
192        required = False,
193        )
194    #jamb_age = schema.Int(
195    #    title = _(u'Age (provided by JAMB)'),
196    #    required = False,
197    #    )
198    jamb_reg_number = schema.TextLine(
199        title = _(u'JAMB Registration Number'),
200        required = False,
201        )
202    notice = schema.Text(
203        title = _(u'Notice'),
204        required = False,
205        )
206    screening_venue = schema.TextLine(
207        title = _(u'Screening Venue'),
208        required = False,
209        )
210    screening_date = schema.TextLine(
211        title = _(u'Screening Date'),
212        required = False,
213        )
214    screening_score = schema.Int(
215        title = _(u'Screening Score (%)'),
216        required = False,
217        )
218    aggregate = schema.Int(
219        title = _(u'Aggregate Score (%)'),
220        description = _(u'(average of relative JAMB and PUTME scores)'),
221        required = False,
222        )
223    result_uploaded = schema.Bool(
224        title = _(u'Result uploaded'),
225        default = False,
226        required = False,
227        )
228    student_id = schema.TextLine(
229        title = _(u'Student Id'),
230        required = False,
231        readonly = False,
232        )
233    course_admitted = schema.Choice(
234        title = _(u'Admitted Course of Study'),
235        source = CertificateSource(),
236        required = False,
237        )
238    locked = schema.Bool(
239        title = _(u'Form locked'),
240        default = False,
241        required = False,
242        )
243
244INigeriaUGApplicant[
245    'locked'].order =  IApplicantBaseData['suspended'].order
246INigeriaUGApplicant[
247    'result_uploaded'].order =  INigeriaUGApplicant['suspended'].order
248
249class INigeriaPGApplicant(IApplicantBaseData):
250    """A postgraduate applicant.
251
252    This interface defines the least common multiple of all fields
253    in pg application forms. In customized forms, fields can be excluded by
254    adding them to the PG_OMIT* tuples.
255    """
256
257    nationality = schema.Choice(
258        source = nats_vocab,
259        title = _(u'Nationality'),
260        required = True,
261        )
262    lga = schema.Choice(
263        source = LGASource(),
264        title = _(u'State/LGA (Nigerians only)'),
265        required = False,
266        )
267    #perm_address = schema.Text(
268    #    title = _(u'Permanent Address'),
269    #    required = False,
270    #    )
271    course1 = schema.Choice(
272        title = _(u'1st Choice Course of Study'),
273        source = AppCatCertificateSource(),
274        required = True,
275        )
276    course2 = schema.Choice(
277        title = _(u'2nd Choice Course of Study'),
278        source = AppCatCertificateSource(),
279        required = False,
280        )
281    hq_type = schema.Choice(
282        title = _(u'Qualification Obtained'),
283        required = False,
284        readonly = False,
285        vocabulary = high_qual,
286        )
287    hq_matric_no = schema.TextLine(
288        title = _(u'Former Matric Number'),
289        required = False,
290        readonly = False,
291        )
292    hq_degree = schema.Choice(
293        title = _(u'Class of Degree'),
294        required = False,
295        readonly = False,
296        vocabulary = high_grade,
297        )
298    hq_school = schema.TextLine(
299        title = _(u'Institution Attended'),
300        required = False,
301        readonly = False,
302        )
303    hq_session = schema.TextLine(
304        title = _(u'Years Attended'),
305        required = False,
306        readonly = False,
307        )
308    hq_disc = schema.TextLine(
309        title = _(u'Discipline'),
310        required = False,
311        readonly = False,
312        )
313    fst_sit_fname = schema.TextLine(
314        title = _(u'Full Name'),
315        required = False,
316        readonly = False,
317        )
318    fst_sit_no = schema.TextLine(
319        title = _(u'Exam Number'),
320        required = False,
321        readonly = False,
322        )
323    fst_sit_date = FormattedDate(
324        title = _(u'Exam Date'),
325        required = False,
326        readonly = False,
327        show_year = True,
328        )
329    fst_sit_type = schema.Choice(
330        title = _(u'Exam Type'),
331        required = False,
332        readonly = False,
333        vocabulary = exam_types,
334        )
335    fst_sit_results = schema.List(
336        title = _(u'Exam Results'),
337        value_type = ResultEntryField(),
338        required = False,
339        readonly = False,
340        default = [],
341        )
342    scd_sit_fname = schema.TextLine(
343        title = _(u'Full Name'),
344        required = False,
345        readonly = False,
346        )
347    scd_sit_no = schema.TextLine(
348        title = _(u'Exam Number'),
349        required = False,
350        readonly = False,
351        )
352    scd_sit_date = FormattedDate(
353        title = _(u'Exam Date'),
354        required = False,
355        readonly = False,
356        show_year = True,
357        )
358    scd_sit_type = schema.Choice(
359        title = _(u'Exam Type'),
360        required = False,
361        readonly = False,
362        vocabulary = exam_types,
363        )
364    scd_sit_results = schema.List(
365        title = _(u'Exam Results'),
366        value_type = ResultEntryField(),
367        required = False,
368        readonly = False,
369        default = [],
370        )
371    # Replaced by first and second sitting
372    #pp_school = schema.Choice(
373    #    title = _(u'Qualification Obtained'),
374    #    required = False,
375    #    readonly = False,
376    #    vocabulary = exam_types,
377    #    )
378    presently_inst = schema.TextLine(
379        title = _(u'If yes, name of institution'),
380        required = False,
381        readonly = False,
382        )
383    nysc_year = schema.Int(
384        title = _(u'Nysc Year'),
385        required = False,
386        readonly = False,
387        )
388    nysc_lga = schema.Choice(
389        source = LGASource(),
390        title = _(u'Nysc Location'),
391        required = False,
392        )
393    employer = schema.TextLine(
394        title = _(u'Employer'),
395        required = False,
396        readonly = False,
397        )
398    emp_position = schema.TextLine(
399        title = _(u'Employer Position'),
400        required = False,
401        readonly = False,
402        )
403    emp_start = FormattedDate(
404        title = _(u'Start Date'),
405        required = False,
406        readonly = False,
407        show_year = True,
408        )
409    emp_end = FormattedDate(
410        title = _(u'End Date'),
411        required = False,
412        readonly = False,
413        show_year = True,
414        )
415    emp_reason = schema.TextLine(
416        title = _(u'Reason for Leaving'),
417        required = False,
418        readonly = False,
419        )
420    employer2 = schema.TextLine(
421        title = _(u'2nd Employer'),
422        required = False,
423        readonly = False,
424        )
425    emp2_position = schema.TextLine(
426        title = _(u'2nd Employer Position'),
427        required = False,
428        readonly = False,
429        )
430    emp2_start = FormattedDate(
431        title = _(u'Start Date'),
432        required = False,
433        readonly = False,
434        show_year = True,
435        )
436    emp2_end = FormattedDate(
437        title = _(u'End Date'),
438        required = False,
439        readonly = False,
440        show_year = True,
441        )
442    emp2_reason = schema.TextLine(
443        title = _(u'Reason for Leaving'),
444        required = False,
445        readonly = False,
446        )
447    notice = schema.Text(
448        title = _(u'Notice'),
449        required = False,
450        readonly = False,
451        )
452    screening_venue = schema.TextLine(
453        title = _(u'Screening Venue'),
454        required = False,
455        )
456    screening_date = schema.TextLine(
457        title = _(u'Screening Date'),
458        required = False,
459        )
460    screening_score = schema.Int(
461        title = _(u'Screening Score (%)'),
462        required = False,
463        )
464    student_id = schema.TextLine(
465        title = _(u'Student Id'),
466        required = False,
467        readonly = False,
468        )
469    course_admitted = schema.Choice(
470        title = _(u'Admitted Course of Study'),
471        source = CertificateSource(),
472        required = False,
473        readonly = False,
474        )
475    locked = schema.Bool(
476        title = _(u'Form locked'),
477        default = False,
478        required = False,
479        )
480
481INigeriaPGApplicant[
482    'locked'].order =  IApplicantBaseData['suspended'].order
483
484class INigeriaApplicant(INigeriaUGApplicant, INigeriaPGApplicant):
485    """An interface for both types of applicants.
486
487    Attention: The INigeriaPGApplicant field seetings will be overwritten
488    by INigeriaPGApplicant field settings. If a field is defined
489    in both interfaces zope.schema validates only against the
490    constraints in INigeriaUGApplicant. This does not affect the forms
491    since they are build on either INigeriaUGApplicant or INigeriaPGApplicant.
492    """
493
494    def writeLogMessage(view, comment):
495        """Adds an INFO message to the log file
496        """
497
498    def createStudent():
499        """Create a student object from applicant data
500        and copy applicant object.
501        """
502
503class INigeriaUGApplicantEdit(INigeriaUGApplicant):
504    """An undergraduate applicant interface for edit forms.
505
506    Here we can repeat the fields from base data and set the
507    `required` and `readonly` attributes to True to further restrict
508    the data access. Or we can allow only certain certificates to be
509    selected by choosing the appropriate source.
510
511    We cannot omit fields here. This has to be done in the
512    respective form page.
513    """
514
515    email = schema.ASCIILine(
516        title = _(u'Email Address'),
517        required = True,
518        constraint=validate_email,
519        )
520    date_of_birth = FormattedDate(
521        title = _(u'Date of Birth'),
522        required = True,
523        show_year = True,
524        )
525
526INigeriaUGApplicantEdit[
527    'date_of_birth'].order =  INigeriaUGApplicant['date_of_birth'].order
528INigeriaUGApplicantEdit[
529    'email'].order =  INigeriaUGApplicant['email'].order
530
531class INigeriaPGApplicantEdit(INigeriaPGApplicant):
532    """A postgraduate applicant interface for editing.
533
534    Here we can repeat the fields from base data and set the
535    `required` and `readonly` attributes to True to further restrict
536    the data access. Or we can allow only certain certificates to be
537    selected by choosing the appropriate source.
538
539    We cannot omit fields here. This has to be done in the
540    respective form page.
541    """
542
543    email = schema.ASCIILine(
544        title = _(u'Email Address'),
545        required = True,
546        constraint=validate_email,
547        )
548    date_of_birth = FormattedDate(
549        title = _(u'Date of Birth'),
550        required = True,
551        show_year = True,
552        )
553
554INigeriaPGApplicantEdit[
555    'date_of_birth'].order =  INigeriaPGApplicant['date_of_birth'].order
556INigeriaPGApplicantEdit[
557    'email'].order =  INigeriaPGApplicant['email'].order
558
559class INigeriaApplicantOnlinePayment(INigeriaOnlinePayment):
560    """An applicant payment via payment gateways.
561
562    """
563
564class IPUTMEApplicantEdit(INigeriaUGApplicant):
565    """An undergraduate applicant interface for editing.
566
567    Here we can repeat the fields from base data and set the
568    `required` and `readonly` attributes to True to further restrict
569    the data access. Or we can allow only certain certificates to be
570    selected by choosing the appropriate source.
571
572    We cannot omit fields here. This has to be done in the
573    respective form page.
574    """
575    email = schema.ASCIILine(
576        title = _(u'Email Address'),
577        required = True,
578        constraint=validate_email,
579        )
580    date_of_birth = FormattedDate(
581        title = _(u'Date of Birth'),
582        required = True,
583        show_year = True,
584        )
585    nationality = schema.Choice(
586        source = nats_vocab,
587        title = _(u'Nationality'),
588        required = True,
589        )
590
591IPUTMEApplicantEdit[
592    'date_of_birth'].order =  INigeriaUGApplicant['date_of_birth'].order
593IPUTMEApplicantEdit[
594    'email'].order =  INigeriaUGApplicant['email'].order
595IPUTMEApplicantEdit[
596    'nationality'].order =  INigeriaUGApplicant['nationality'].order
597
598class INigeriaApplicantUpdateByRegNo(INigeriaApplicant):
599    """Representation of an applicant.
600
601    Skip regular reg_number validation if reg_number is used for finding
602    the applicant object.
603    """
604    reg_number = schema.TextLine(
605        title = u'Registration Number',
606        required = False,
607        )
Note: See TracBrowser for help on using the repository browser.