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

Last change on this file since 8947 was 8926, checked in by Henrik Bettermann, 13 years ago

Setup Nigerian applicant components with interfaces. (More tests will follow.)

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