source: main/waeup.futminna/trunk/src/waeup/futminna/applicants/interfaces.py @ 8730

Last change on this file since 8730 was 8730, checked in by Henrik Bettermann, 12 years ago

Merged with waeup.uniben 8726:8727.

  • Property svn:keywords set to Id
File size: 12.6 KB
Line 
1## $Id: interfaces.py 8730 2012-06-15 06:48:10Z 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 waeup.futminna.interfaces import (
32    LGASource, high_qual, high_grade, exam_types)
33from waeup.futminna.interfaces import MessageFactory as _
34from waeup.futminna.payments.interfaces import ICustomOnlinePayment
35
36UG_OMIT_DISPLAY_FIELDS = ('locked', 'course_admitted', 'password')
37UG_OMIT_PDF_FIELDS = UG_OMIT_DISPLAY_FIELDS + ('email', 'phone')
38UG_OMIT_MANAGE_FIELDS = ()
39UG_OMIT_EDIT_FIELDS = UG_OMIT_MANAGE_FIELDS + ('locked', 'course_admitted',
40    'student_id', 'screening_score', 'screening_venue', 'notice',
41    'screening_date')
42PUTME_OMIT_EDIT_FIELDS = UG_OMIT_EDIT_FIELDS + (
43    'firstname', 'middlename', 'lastname', 'sex',
44    'course1', 'lga', 'jamb_score', 'jamb_subjects')
45
46PG_OMIT_DISPLAY_FIELDS = ('locked', 'course_admitted', 'password')
47PG_OMIT_PDF_FIELDS = UG_OMIT_DISPLAY_FIELDS + ('email', 'phone')
48PG_OMIT_MANAGE_FIELDS = ()
49PG_OMIT_EDIT_FIELDS = PG_OMIT_MANAGE_FIELDS + (
50    'locked', 'course_admitted',
51    'student_id', 'screening_score', 'screening_venue', 'notice',
52    'screening_date')
53
54class IUGApplicant(IApplicantBaseData):
55    """An undergraduate applicant.
56
57    This interface defines the least common multiple of all fields
58    in ug application forms. In customized forms, fields can be excluded by
59    adding them to the UG_OMIT* tuples.
60    """
61
62    nationality = schema.Choice(
63        source = nats_vocab,
64        title = _(u'Nationality'),
65        required = False,
66        )
67    lga = schema.Choice(
68        source = LGASource(),
69        title = _(u'State/LGA (Nigerians only)'),
70        required = False,
71        )
72    perm_address = schema.Text(
73        title = _(u'Permanent Address'),
74        required = False,
75        )
76    course1 = schema.Choice(
77        title = _(u'1st Choice Course of Study'),
78        source = AppCatCertificateSource(),
79        required = True,
80        )
81    course2 = schema.Choice(
82        title = _(u'2nd Choice Course of Study'),
83        source = AppCatCertificateSource(),
84        required = False,
85        )
86    jamb_subjects = schema.Text(
87        title = _(u'Subjects and Scores'),
88        required = False,
89        )
90    jamb_score = schema.Int(
91        title = _(u'Total Score'),
92        required = False,
93        )
94    notice = schema.Text(
95        title = _(u'Notice'),
96        required = False,
97        )
98    screening_venue = schema.TextLine(
99        title = _(u'Screening Venue'),
100        required = False,
101        )
102    screening_date = schema.TextLine(
103        title = _(u'Screening Date'),
104        required = False,
105        )
106    screening_score = schema.Int(
107        title = _(u'Screening Score'),
108        required = False,
109        )
110    student_id = schema.TextLine(
111        title = _(u'Student Id'),
112        required = False,
113        readonly = False,
114        )
115    course_admitted = schema.Choice(
116        title = _(u'Admitted Course of Study'),
117        source = CertificateSource(),
118        required = False,
119        )
120    locked = schema.Bool(
121        title = _(u'Form locked'),
122        default = False,
123        )
124
125class IPGApplicant(IApplicantBaseData):
126    """A postgraduate applicant.
127
128    This interface defines the least common multiple of all fields
129    in pg application forms. In customized forms, fields can be excluded by
130    adding them to the PG_OMIT* tuples.
131    """
132
133    nationality = schema.Choice(
134        source = nats_vocab,
135        title = _(u'Nationality'),
136        required = False,
137        )
138    lga = schema.Choice(
139        source = LGASource(),
140        title = _(u'State/LGA (Nigerians only)'),
141        required = False,
142        )
143    perm_address = schema.Text(
144        title = _(u'Permanent Address'),
145        required = False,
146        )
147    course1 = schema.Choice(
148        title = _(u'1st Choice Course of Study'),
149        source = AppCatCertificateSource(),
150        required = True,
151        )
152    course2 = schema.Choice(
153        title = _(u'2nd Choice Course of Study'),
154        source = AppCatCertificateSource(),
155        required = False,
156        )
157    hq_type = schema.Choice(
158        title = _(u'Qualification Obtained'),
159        required = False,
160        readonly = False,
161        vocabulary = high_qual,
162        )
163    hq_matric_no = schema.TextLine(
164        title = _(u'Former Matric Number'),
165        required = False,
166        readonly = False,
167        )
168    hq_degree = schema.Choice(
169        title = _(u'Class of Degree'),
170        required = False,
171        readonly = False,
172        vocabulary = high_grade,
173        )
174    hq_school = schema.TextLine(
175        title = _(u'Institution Attended'),
176        required = False,
177        readonly = False,
178        )
179    hq_session = schema.TextLine(
180        title = _(u'Years Attended'),
181        required = False,
182        readonly = False,
183        )
184    hq_disc = schema.TextLine(
185        title = _(u'Discipline'),
186        required = False,
187        readonly = False,
188        )
189    pp_school = schema.Choice(
190        title = _(u'Qualification Obtained'),
191        required = False,
192        readonly = False,
193        vocabulary = exam_types,
194        )
195    #presently = schema.Bool(
196    #    title = _(u'Attending'),
197    #    required = False,
198    #    readonly = False,
199    #    )
200    presently_inst = schema.TextLine(
201        title = _(u'If yes, name of institution'),
202        required = False,
203        readonly = False,
204        )
205    nysc_year = schema.Int(
206        title = _(u'Nysc Year'),
207        required = False,
208        readonly = False,
209        )
210    nysc_lga = schema.Choice(
211        source = LGASource(),
212        title = _(u'Nysc Location'),
213        required = False,
214        )
215    employer = schema.TextLine(
216        title = _(u'Employer'),
217        required = False,
218        readonly = False,
219        )
220    emp_position = schema.TextLine(
221        title = _(u'Employer Position'),
222        required = False,
223        readonly = False,
224        )
225    emp_start = FormattedDate(
226        title = _(u'Start Date'),
227        required = False,
228        readonly = False,
229        show_year = True,
230        )
231    emp_end = FormattedDate(
232        title = _(u'End Date'),
233        required = False,
234        readonly = False,
235        show_year = True,
236        )
237    emp_reason = schema.TextLine(
238        title = _(u'Reason for Leaving'),
239        required = False,
240        readonly = False,
241        )
242    employer2 = schema.TextLine(
243        title = _(u'2nd Employer'),
244        required = False,
245        readonly = False,
246        )
247    emp2_position = schema.TextLine(
248        title = _(u'2nd Employer Position'),
249        required = False,
250        readonly = False,
251        )
252    emp2_start = FormattedDate(
253        title = _(u'Start Date'),
254        required = False,
255        readonly = False,
256        show_year = True,
257        )
258    emp2_end = FormattedDate(
259        title = _(u'End Date'),
260        required = False,
261        readonly = False,
262        show_year = True,
263        )
264    emp2_reason = schema.TextLine(
265        title = _(u'Reason for Leaving'),
266        required = False,
267        readonly = False,
268        )
269    notice = schema.Text(
270        title = _(u'Notice'),
271        required = False,
272        readonly = False,
273        )
274    screening_venue = schema.TextLine(
275        title = _(u'Screening Venue'),
276        required = False,
277        readonly = False,
278        )
279    screening_date = schema.TextLine(
280        title = _(u'Screening Date'),
281        required = False,
282        )
283    screening_score = schema.Int(
284        title = _(u'Screening Score'),
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 ICustomApplicant(IUGApplicant, IPGApplicant):
305    """An interface for both types of applicants.
306
307    Attention: The IPGApplicant field seetings will be overwritten
308    by IPGApplicant field settings. If a field is defined
309    in both interfaces zope.schema validates only against the
310    constraints in IUGApplicant. This does not affect the forms
311    since they are build on either IUGApplicant or IPGApplicant.
312    """
313
314    def loggerInfo(ob_class, comment):
315        """Adds an INFO message to the log file
316        """
317
318    def createStudent():
319        """Create a student object from applicatnt data
320        and copy applicant object.
321        """
322
323class IUGApplicantEdit(IUGApplicant):
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
346IUGApplicantEdit[
347    'date_of_birth'].order =  IUGApplicant['date_of_birth'].order
348IUGApplicantEdit[
349    'email'].order =  IUGApplicant['email'].order
350
351class IPGApplicantEdit(IPGApplicant):
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
374IPGApplicantEdit[
375    'date_of_birth'].order =  IPGApplicant['date_of_birth'].order
376IPGApplicantEdit[
377    'email'].order =  IPGApplicant['email'].order
378
379class ICustomApplicantOnlinePayment(ICustomOnlinePayment):
380    """An applicant payment via payment gateways.
381
382    """
383
384class IPUTMEApplicantEdit(IUGApplicant):
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 =  IUGApplicant['date_of_birth'].order
408IPUTMEApplicantEdit[
409    'email'].order =  IUGApplicant['email'].order
410
411class ICustomApplicantUpdateByRegNo(ICustomApplicant):
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.