source: main/kofacustom.nigeria/branches/henrik-diazo-themed/src/kofacustom/nigeria/applicants/interfaces.py @ 11150

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

Revert reversion. Omitting special_application is necessary.

  • Property svn:keywords set to Id
File size: 15.8 KB
Line 
1## $Id: interfaces.py 10851 2013-12-15 07:30:03Z 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', '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 = ('special_application',)
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
103    nationality = schema.Choice(
104        source = nats_vocab,
105        title = _(u'Nationality'),
106        required = False,
107        )
108    lga = schema.Choice(
109        source = LGASource(),
110        title = _(u'State/LGA (Nigerians only)'),
111        required = False,
112        )
113    #perm_address = schema.Text(
114    #    title = _(u'Permanent Address'),
115    #    required = False,
116    #    )
117    course1 = schema.Choice(
118        title = _(u'1st Choice Course of Study'),
119        source = AppCatCertificateSource(),
120        required = True,
121        )
122    course2 = schema.Choice(
123        title = _(u'2nd Choice Course of Study'),
124        source = AppCatCertificateSource(),
125        required = False,
126        )
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        )
159    jamb_subjects = schema.Text(
160        title = _(u'Subjects and Scores'),
161        required = False,
162        )
163    jamb_score = schema.Int(
164        title = _(u'Total JAMB Score'),
165        required = False,
166        )
167    notice = schema.Text(
168        title = _(u'Notice'),
169        required = False,
170        )
171    screening_venue = schema.TextLine(
172        title = _(u'Screening Venue'),
173        required = False,
174        )
175    screening_date = schema.TextLine(
176        title = _(u'Screening Date'),
177        required = False,
178        )
179    screening_score = schema.Int(
180        title = _(u'Screening Score (%)'),
181        required = False,
182        )
183    aggregate = schema.Int(
184        title = _(u'Aggregate Score (%)'),
185        description = _(u'(average of relative JAMB and PUTME scores)'),
186        required = False,
187        )
188    result_uploaded = schema.Bool(
189        title = _(u'Result uploaded'),
190        default = False,
191        required = False,
192        )
193    student_id = schema.TextLine(
194        title = _(u'Student Id'),
195        required = False,
196        readonly = False,
197        )
198    course_admitted = schema.Choice(
199        title = _(u'Admitted Course of Study'),
200        source = CertificateSource(),
201        required = False,
202        )
203    locked = schema.Bool(
204        title = _(u'Form locked'),
205        default = False,
206        required = False,
207        )
208
209INigeriaUGApplicant[
210    'locked'].order =  IApplicantBaseData['suspended'].order
211INigeriaUGApplicant[
212    'result_uploaded'].order =  INigeriaUGApplicant['suspended'].order
213
214class INigeriaPGApplicant(IApplicantBaseData):
215    """A postgraduate applicant.
216
217    This interface defines the least common multiple of all fields
218    in pg application forms. In customized forms, fields can be excluded by
219    adding them to the PG_OMIT* tuples.
220    """
221
222    nationality = schema.Choice(
223        source = nats_vocab,
224        title = _(u'Nationality'),
225        required = True,
226        )
227    lga = schema.Choice(
228        source = LGASource(),
229        title = _(u'State/LGA (Nigerians only)'),
230        required = False,
231        )
232    #perm_address = schema.Text(
233    #    title = _(u'Permanent Address'),
234    #    required = False,
235    #    )
236    course1 = schema.Choice(
237        title = _(u'1st Choice Course of Study'),
238        source = AppCatCertificateSource(),
239        required = True,
240        )
241    course2 = schema.Choice(
242        title = _(u'2nd Choice Course of Study'),
243        source = AppCatCertificateSource(),
244        required = False,
245        )
246    hq_type = schema.Choice(
247        title = _(u'Qualification Obtained'),
248        required = False,
249        readonly = False,
250        vocabulary = high_qual,
251        )
252    hq_matric_no = schema.TextLine(
253        title = _(u'Former Matric Number'),
254        required = False,
255        readonly = False,
256        )
257    hq_degree = schema.Choice(
258        title = _(u'Class of Degree'),
259        required = False,
260        readonly = False,
261        vocabulary = high_grade,
262        )
263    hq_school = schema.TextLine(
264        title = _(u'Institution Attended'),
265        required = False,
266        readonly = False,
267        )
268    hq_session = schema.TextLine(
269        title = _(u'Years Attended'),
270        required = False,
271        readonly = False,
272        )
273    hq_disc = schema.TextLine(
274        title = _(u'Discipline'),
275        required = False,
276        readonly = False,
277        )
278    pp_school = schema.Choice(
279        title = _(u'Qualification Obtained'),
280        required = False,
281        readonly = False,
282        vocabulary = exam_types,
283        )
284    presently_inst = schema.TextLine(
285        title = _(u'If yes, name of institution'),
286        required = False,
287        readonly = False,
288        )
289    nysc_year = schema.Int(
290        title = _(u'Nysc Year'),
291        required = False,
292        readonly = False,
293        )
294    nysc_lga = schema.Choice(
295        source = LGASource(),
296        title = _(u'Nysc Location'),
297        required = False,
298        )
299    employer = schema.TextLine(
300        title = _(u'Employer'),
301        required = False,
302        readonly = False,
303        )
304    emp_position = schema.TextLine(
305        title = _(u'Employer Position'),
306        required = False,
307        readonly = False,
308        )
309    emp_start = FormattedDate(
310        title = _(u'Start Date'),
311        required = False,
312        readonly = False,
313        show_year = True,
314        )
315    emp_end = FormattedDate(
316        title = _(u'End Date'),
317        required = False,
318        readonly = False,
319        show_year = True,
320        )
321    emp_reason = schema.TextLine(
322        title = _(u'Reason for Leaving'),
323        required = False,
324        readonly = False,
325        )
326    employer2 = schema.TextLine(
327        title = _(u'2nd Employer'),
328        required = False,
329        readonly = False,
330        )
331    emp2_position = schema.TextLine(
332        title = _(u'2nd Employer Position'),
333        required = False,
334        readonly = False,
335        )
336    emp2_start = FormattedDate(
337        title = _(u'Start Date'),
338        required = False,
339        readonly = False,
340        show_year = True,
341        )
342    emp2_end = FormattedDate(
343        title = _(u'End Date'),
344        required = False,
345        readonly = False,
346        show_year = True,
347        )
348    emp2_reason = schema.TextLine(
349        title = _(u'Reason for Leaving'),
350        required = False,
351        readonly = False,
352        )
353    notice = schema.Text(
354        title = _(u'Notice'),
355        required = False,
356        readonly = False,
357        )
358    screening_venue = schema.TextLine(
359        title = _(u'Screening Venue'),
360        required = False,
361        )
362    screening_date = schema.TextLine(
363        title = _(u'Screening Date'),
364        required = False,
365        )
366    screening_score = schema.Int(
367        title = _(u'Screening Score (%)'),
368        required = False,
369        )
370    student_id = schema.TextLine(
371        title = _(u'Student Id'),
372        required = False,
373        readonly = False,
374        )
375    course_admitted = schema.Choice(
376        title = _(u'Admitted Course of Study'),
377        source = CertificateSource(),
378        required = False,
379        readonly = False,
380        )
381    locked = schema.Bool(
382        title = _(u'Form locked'),
383        default = False,
384        required = False,
385        )
386
387INigeriaPGApplicant[
388    'locked'].order =  IApplicantBaseData['suspended'].order
389
390class INigeriaApplicant(INigeriaUGApplicant, INigeriaPGApplicant):
391    """An interface for both types of applicants.
392
393    Attention: The INigeriaPGApplicant field seetings will be overwritten
394    by INigeriaPGApplicant field settings. If a field is defined
395    in both interfaces zope.schema validates only against the
396    constraints in INigeriaUGApplicant. This does not affect the forms
397    since they are build on either INigeriaUGApplicant or INigeriaPGApplicant.
398    """
399
400    def writeLogMessage(view, comment):
401        """Adds an INFO message to the log file
402        """
403
404    def createStudent():
405        """Create a student object from applicant data
406        and copy applicant object.
407        """
408
409class INigeriaUGApplicantEdit(INigeriaUGApplicant):
410    """An undergraduate applicant interface for edit forms.
411
412    Here we can repeat the fields from base data and set the
413    `required` and `readonly` attributes to True to further restrict
414    the data access. Or we can allow only certain certificates to be
415    selected by choosing the appropriate source.
416
417    We cannot omit fields here. This has to be done in the
418    respective form page.
419    """
420
421    email = schema.ASCIILine(
422        title = _(u'Email Address'),
423        required = True,
424        constraint=validate_email,
425        )
426    date_of_birth = FormattedDate(
427        title = _(u'Date of Birth'),
428        required = True,
429        show_year = True,
430        )
431
432INigeriaUGApplicantEdit[
433    'date_of_birth'].order =  INigeriaUGApplicant['date_of_birth'].order
434INigeriaUGApplicantEdit[
435    'email'].order =  INigeriaUGApplicant['email'].order
436
437class INigeriaPGApplicantEdit(INigeriaPGApplicant):
438    """A postgraduate applicant interface for editing.
439
440    Here we can repeat the fields from base data and set the
441    `required` and `readonly` attributes to True to further restrict
442    the data access. Or we can allow only certain certificates to be
443    selected by choosing the appropriate source.
444
445    We cannot omit fields here. This has to be done in the
446    respective form page.
447    """
448
449    email = schema.ASCIILine(
450        title = _(u'Email Address'),
451        required = True,
452        constraint=validate_email,
453        )
454    date_of_birth = FormattedDate(
455        title = _(u'Date of Birth'),
456        required = True,
457        show_year = True,
458        )
459
460INigeriaPGApplicantEdit[
461    'date_of_birth'].order =  INigeriaPGApplicant['date_of_birth'].order
462INigeriaPGApplicantEdit[
463    'email'].order =  INigeriaPGApplicant['email'].order
464
465class INigeriaApplicantOnlinePayment(INigeriaOnlinePayment):
466    """An applicant payment via payment gateways.
467
468    """
469
470class IPUTMEApplicantEdit(INigeriaUGApplicant):
471    """An undergraduate applicant interface for editing.
472
473    Here we can repeat the fields from base data and set the
474    `required` and `readonly` attributes to True to further restrict
475    the data access. Or we can allow only certain certificates to be
476    selected by choosing the appropriate source.
477
478    We cannot omit fields here. This has to be done in the
479    respective form page.
480    """
481    email = schema.ASCIILine(
482        title = _(u'Email Address'),
483        required = True,
484        constraint=validate_email,
485        )
486    date_of_birth = FormattedDate(
487        title = _(u'Date of Birth'),
488        required = True,
489        show_year = True,
490        )
491    nationality = schema.Choice(
492        source = nats_vocab,
493        title = _(u'Nationality'),
494        required = True,
495        )
496
497IPUTMEApplicantEdit[
498    'date_of_birth'].order =  INigeriaUGApplicant['date_of_birth'].order
499IPUTMEApplicantEdit[
500    'email'].order =  INigeriaUGApplicant['email'].order
501IPUTMEApplicantEdit[
502    'nationality'].order =  INigeriaUGApplicant['nationality'].order
503
504class INigeriaApplicantUpdateByRegNo(INigeriaApplicant):
505    """Representation of an applicant.
506
507    Skip regular reg_number validation if reg_number is used for finding
508    the applicant object.
509    """
510    reg_number = schema.TextLine(
511        title = u'Registration Number',
512        required = False,
513        )
Note: See TracBrowser for help on using the repository browser.