source: main/waeup.uniben/branches/uli-autoinclude-less/src/waeup/uniben/applicants/interfaces.py @ 8880

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

Use former lgas for Uniben. Must be removed after application.

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