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

Last change on this file since 10591 was 10591, checked in by Henrik Bettermann, 11 years ago

Enable import of missing sex and course1.

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