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

Last change on this file since 12774 was 11810, checked in by Henrik Bettermann, 10 years ago

Update versions.cfg.

Add jamb_age to PUDE_OMIT_FIELDS.

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