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

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

Remove aggregate score field.

  • Property svn:keywords set to Id
File size: 18.6 KB
Line 
1## $Id: interfaces.py 13157 2015-07-08 10:55:01Z 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',
63    'aggregate')
64CBT_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS + CBT_OMIT_FIELDS
65CBT_OMIT_MANAGE_FIELDS = UG_OMIT_MANAGE_FIELDS + CBT_OMIT_FIELDS
66CBT_OMIT_EDIT_FIELDS = UG_OMIT_MANAGE_FIELDS + OMIT_DISPLAY_FIELDS + CBT_OMIT_FIELDS + (
67    'student_id',
68    'notice',
69    'screening_score',
70    'screening_venue',
71    'screening_date',
72    #'jamb_age',
73    #'jamb_subjects',
74    #'jamb_score',
75    #'jamb_reg_number',
76    )
77CBT_OMIT_PDF_FIELDS = CBT_OMIT_DISPLAY_FIELDS + ('phone',)
78
79# PUTME is a subgroup of UG with the same interface.
80PUTME_OMIT_FIELDS = (
81    'hq_type', 'hq_matric_no',
82    'hq_degree', 'hq_school',
83    'hq_session', 'hq_disc',)
84PUTME_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS + PUTME_OMIT_FIELDS
85PUTME_OMIT_MANAGE_FIELDS = UG_OMIT_MANAGE_FIELDS + PUTME_OMIT_FIELDS
86PUTME_OMIT_EDIT_FIELDS = UG_OMIT_EDIT_FIELDS + PUTME_OMIT_FIELDS + (
87    'firstname', 'middlename', 'lastname', 'sex',
88    'course1', 'lga')
89PUTME_OMIT_PDF_FIELDS = PUTME_OMIT_DISPLAY_FIELDS + ('phone',)
90PUTME_OMIT_RESULT_SLIP_FIELDS = PUTME_OMIT_DISPLAY_FIELDS + (
91    'phone',
92    'date_of_birth', 'sex',
93    'nationality', 'lga', #'perm_address',
94    'course2', 'screening_venue',
95    'screening_date')
96
97# PUDE is a subgroup of UG with the same interface.
98PUDE_OMIT_FIELDS = (
99    'jamb_subjects','jamb_score', 'jamb_age', 'aggregate')
100PUDE_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS + PUDE_OMIT_FIELDS
101PUDE_OMIT_MANAGE_FIELDS = UG_OMIT_MANAGE_FIELDS + PUDE_OMIT_FIELDS
102PUDE_OMIT_EDIT_FIELDS = set(UG_OMIT_EDIT_FIELDS + PUDE_OMIT_FIELDS + (
103    'firstname', 'middlename', 'lastname', 'sex',
104    'course1', 'lga'))
105PUDE_OMIT_PDF_FIELDS = PUDE_OMIT_DISPLAY_FIELDS + ('phone',)
106PUDE_OMIT_RESULT_SLIP_FIELDS = PUDE_OMIT_DISPLAY_FIELDS + (
107    'phone',
108    'date_of_birth', 'sex',
109    'nationality', 'lga', #'perm_address',
110    'course2', 'screening_venue',
111    'screening_date')
112
113# PG has its own interface
114PG_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS
115PG_OMIT_PDF_FIELDS = PG_OMIT_DISPLAY_FIELDS + ('phone',)
116PG_OMIT_MANAGE_FIELDS = ('special_application',)
117PG_OMIT_EDIT_FIELDS = PG_OMIT_MANAGE_FIELDS + PG_OMIT_DISPLAY_FIELDS + (
118    'student_id', 'notice',
119    'screening_score', 'screening_venue',
120    'screening_date',)
121
122class INigeriaUGApplicant(IApplicantBaseData):
123    """An undergraduate applicant.
124
125    This interface defines the least common multiple of all fields
126    in ug application forms. In customized forms, fields can be excluded by
127    adding them to the UG_OMIT* tuples.
128    """
129
130    nationality = schema.Choice(
131        source = nats_vocab,
132        title = _(u'Nationality'),
133        required = False,
134        )
135    lga = schema.Choice(
136        source = LGASource(),
137        title = _(u'State/LGA (Nigerians only)'),
138        required = False,
139        )
140    #perm_address = schema.Text(
141    #    title = _(u'Permanent Address'),
142    #    required = False,
143    #    )
144    course1 = schema.Choice(
145        title = _(u'1st Choice Course of Study'),
146        source = AppCatCertificateSource(),
147        required = True,
148        )
149    course2 = schema.Choice(
150        title = _(u'2nd Choice Course of Study'),
151        source = AppCatCertificateSource(),
152        required = False,
153        )
154    hq_type = schema.Choice(
155        title = _(u'Qualification Obtained'),
156        required = False,
157        readonly = False,
158        vocabulary = high_qual,
159        )
160    hq_matric_no = schema.TextLine(
161        title = _(u'Former Matric Number'),
162        required = False,
163        readonly = False,
164        )
165    hq_degree = schema.Choice(
166        title = _(u'Class of Degree'),
167        required = False,
168        readonly = False,
169        vocabulary = high_grade,
170        )
171    hq_school = schema.TextLine(
172        title = _(u'Institution Attended'),
173        required = False,
174        readonly = False,
175        )
176    hq_session = schema.TextLine(
177        title = _(u'Years Attended'),
178        required = False,
179        readonly = False,
180        )
181    hq_disc = schema.TextLine(
182        title = _(u'Discipline'),
183        required = False,
184        readonly = False,
185        )
186    jamb_subjects = schema.Text(
187        title = _(u'Subjects and Scores'),
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    jamb_subjects = schema.Text(
526        title = _(u'Subjects and Scores'),
527        description = _(u'Enter all four subjects, one subject with score per line!'),
528        required = True,
529        )
530
531INigeriaUGApplicantEdit[
532    'date_of_birth'].order = INigeriaUGApplicant['date_of_birth'].order
533INigeriaUGApplicantEdit[
534    'email'].order = INigeriaUGApplicant['email'].order
535INigeriaUGApplicantEdit[
536    'jamb_subjects'].order = INigeriaUGApplicant['jamb_subjects'].order
537
538class INigeriaPGApplicantEdit(INigeriaPGApplicant):
539    """A postgraduate applicant interface for editing.
540
541    Here we can repeat the fields from base data and set the
542    `required` and `readonly` attributes to True to further restrict
543    the data access. Or we can allow only certain certificates to be
544    selected by choosing the appropriate source.
545
546    We cannot omit fields here. This has to be done in the
547    respective form page.
548    """
549
550    email = schema.ASCIILine(
551        title = _(u'Email Address'),
552        required = True,
553        constraint=validate_email,
554        )
555    date_of_birth = FormattedDate(
556        title = _(u'Date of Birth'),
557        required = True,
558        show_year = True,
559        )
560
561INigeriaPGApplicantEdit[
562    'date_of_birth'].order =  INigeriaPGApplicant['date_of_birth'].order
563INigeriaPGApplicantEdit[
564    'email'].order =  INigeriaPGApplicant['email'].order
565
566class INigeriaApplicantOnlinePayment(INigeriaOnlinePayment):
567    """An applicant payment via payment gateways.
568    """
569
570class IPUTMEApplicantEdit(INigeriaUGApplicant):
571    """An undergraduate applicant interface for editing.
572
573    Here we can repeat the fields from base data and set the
574    `required` and `readonly` attributes to True to further restrict
575    the data access. Or we can allow only certain certificates to be
576    selected by choosing the appropriate source.
577
578    We cannot omit fields here. This has to be done in the
579    respective form page.
580    """
581    email = schema.ASCIILine(
582        title = _(u'Email Address'),
583        required = True,
584        constraint=validate_email,
585        )
586    date_of_birth = FormattedDate(
587        title = _(u'Date of Birth'),
588        required = True,
589        show_year = True,
590        )
591    nationality = schema.Choice(
592        source = nats_vocab,
593        title = _(u'Nationality'),
594        required = True,
595        )
596
597IPUTMEApplicantEdit[
598    'date_of_birth'].order =  INigeriaUGApplicant['date_of_birth'].order
599IPUTMEApplicantEdit[
600    'email'].order =  INigeriaUGApplicant['email'].order
601IPUTMEApplicantEdit[
602    'nationality'].order =  INigeriaUGApplicant['nationality'].order
603
604class INigeriaApplicantUpdateByRegNo(INigeriaApplicant):
605    """Representation of an applicant.
606
607    Skip regular reg_number validation if reg_number is used for finding
608    the applicant object.
609    """
610    reg_number = schema.TextLine(
611        title = u'Registration Number',
612        required = False,
613        )
Note: See TracBrowser for help on using the repository browser.