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

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

Show boolean fields at top.

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