source: main/waeup.fceokene/trunk/src/waeup/fceokene/applicants/interfaces.py @ 15115

Last change on this file since 15115 was 15111, checked in by Henrik Bettermann, 6 years ago

school1 is not required during import.

  • Property svn:keywords set to Id
File size: 13.8 KB
Line 
1## $Id: interfaces.py 15111 2018-08-20 12:29:28Z 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 zc.sourcefactory.basic import BasicSourceFactory
23from waeup.kofa.applicants.interfaces import (
24    IApplicantBaseData,
25    AppCatCertificateSource, CertificateSource)
26from waeup.kofa.schoolgrades import ResultEntryField
27from waeup.kofa.interfaces import (
28    SimpleKofaVocabulary, academic_sessions_vocab, validate_email,
29    IKofaObject)
30from waeup.kofa.schema import FormattedDate, TextLineChoice, PhoneNumber
31from waeup.kofa.schoolgrades import ResultEntryField
32from waeup.kofa.students.vocabularies import nats_vocab, GenderSource
33from waeup.kofa.applicants.interfaces import contextual_reg_num_source
34from kofacustom.nigeria.applicants.interfaces import (
35    LGASource, high_qual, high_grade, exam_types,
36    INigeriaUGApplicant, INigeriaPGApplicant,
37    INigeriaApplicantOnlinePayment,
38    INigeriaUGApplicantEdit,
39    INigeriaApplicantUpdateByRegNo,
40    IPUTMEApplicantEdit,
41    OMIT_DISPLAY_FIELDS
42    )
43from waeup.fceokene.applicants.schools import SCHOOLS
44from waeup.fceokene.interfaces import MessageFactory as _
45
46BEC_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS
47BEC_OMIT_PDF_FIELDS = BEC_OMIT_DISPLAY_FIELDS + ('phone',)
48BEC_OMIT_MANAGE_FIELDS = ('special_application',)
49BEC_OMIT_EDIT_FIELDS = BEC_OMIT_MANAGE_FIELDS + OMIT_DISPLAY_FIELDS + (
50    'student_id', 'notice',
51    'screening_score',
52    'screening_venue',
53    'screening_date',
54    #'jamb_subjects',
55    #'jamb_score',
56    'aggregate')
57
58class SchoolSource(BasicSourceFactory):
59    """A source that delivers all kinds of schools.
60    """
61    def getValues(self):
62        sorted_items = sorted(
63            SCHOOLS.items(),
64            key=lambda element: element[1][0] + element[1][1] +element[1][2])
65        return [item[0] for item in sorted_items]
66
67    def getToken(self, value):
68        return value
69
70    def getTitle(self, value):
71        return u"%s: %s -- %s" % (
72            SCHOOLS[value][0],
73            SCHOOLS[value][1],
74            SCHOOLS[value][2],)
75
76class ITPURegistration(IKofaObject):
77    """A TPU registrant.
78    """
79
80    suspended = schema.Bool(
81        title = _(u'Account suspended'),
82        default = False,
83        required = False,
84        )
85
86    locked = schema.Bool(
87        title = _(u'Form locked'),
88        default = False,
89        required = False,
90        )
91
92    applicant_id = schema.TextLine(
93        title = _(u'Applicant Id'),
94        required = False,
95        readonly = False,
96        )
97
98    reg_number = schema.TextLine(
99        title = _(u'Registration Number'),
100        required = False,
101        readonly = False,
102        )
103
104    matric_number = schema.TextLine(
105        title = _(u'Matriculation Number'),
106        required = False,
107        readonly = False,
108        )
109
110    firstname = schema.TextLine(
111        title = _(u'First Name'),
112        required = True,
113        )
114
115    middlename = schema.TextLine(
116        title = _(u'Middle Name'),
117        required = False,
118        )
119
120    lastname = schema.TextLine(
121        title = _(u'Last Name (Surname)'),
122        required = True,
123        )
124
125    email = schema.ASCIILine(
126        title = _(u'Email Address'),
127        required = True,
128        constraint=validate_email,
129        )
130
131    phone = PhoneNumber(
132        title = _(u'Phone'),
133        description = u'',
134        required = False,
135        )
136
137    perm_address = schema.Text(
138        title = _(u'Home Address'),
139        required = False,
140        readonly = False,
141        )
142
143    lga = schema.Choice(
144        source = LGASource(),
145        title = _(u'State/LGA'),
146        required = False,
147        )
148
149    subj_comb = schema.TextLine(
150        title = _(u'Subject Combination'),
151        required = False,
152        readonly = False,
153        )
154
155    school1 = schema.Choice(
156        title = _(u'1st Choice TPZ and School'),
157        source = SchoolSource(),
158        required = False,
159        )
160
161    #school2 = schema.Choice(
162    #    title = _(u'2nd Choice TPZ and School'),
163    #    source = SchoolSource(),
164    #    required = False,
165    #    )
166
167    #school3 = schema.Choice(
168    #    title = _(u'3rd Choice TPZ and School'),
169    #    source = SchoolSource(),
170    #    required = False,
171    #    )
172
173class ICustomUGApplicant(INigeriaUGApplicant):
174    """An undergraduate applicant.
175
176    This interface defines the least common multiple of all fields
177    in ug application forms. In customized forms, fields can be excluded by
178    adding them to the OMIT* tuples.
179    """
180
181    nationality = schema.Choice(
182        source = nats_vocab,
183        title = _(u'Nationality'),
184        required = True,
185        )
186    lga = schema.Choice(
187        source = LGASource(),
188        title = _(u'State/LGA (Nigerians only)'),
189        required = False,
190        )
191    #perm_address = schema.Text(
192    #    title = _(u'Permanent Address'),
193    #    required = False,
194    #    )
195    course1 = schema.Choice(
196        title = _(u'1st Choice Course of Study'),
197        source = AppCatCertificateSource(),
198        required = False,
199        )
200    course2 = schema.Choice(
201        title = _(u'2nd Choice Course of Study'),
202        source = AppCatCertificateSource(),
203        required = False,
204        )
205    olevel_type = schema.Choice(
206        title = _(u'1st Qualification Obtained'),
207        required = False,
208        readonly = False,
209        vocabulary = exam_types,
210        )
211    olevel_school = schema.TextLine(
212        title = _(u'1st Institution Attended'),
213        required = False,
214        readonly = False,
215        )
216    olevel_exam_number = schema.TextLine(
217        title = _(u'1st Exam Number'),
218        required = False,
219        readonly = False,
220        )
221    olevel_exam_date = FormattedDate(
222        title = _(u'1st Exam Date'),
223        required = False,
224        readonly = False,
225        show_year = True,
226        )
227    olevel_results = schema.List(
228        title = _(u'1st Exam Results'),
229        value_type = ResultEntryField(),
230        required = False,
231        readonly = False,
232        defaultFactory=list,
233        )
234    olevel_type2 = schema.Choice(
235        title = _(u'2nd Qualification Obtained'),
236        required = False,
237        readonly = False,
238        vocabulary = exam_types,
239        )
240    olevel_school2 = schema.TextLine(
241        title = _(u'2nd Institution Attended'),
242        required = False,
243        readonly = False,
244        )
245    olevel_exam_number2 = schema.TextLine(
246        title = _(u'2nd Exam Number'),
247        required = False,
248        readonly = False,
249        )
250    olevel_exam_date2 = FormattedDate(
251        title = _(u'2nd Exam Date'),
252        required = False,
253        readonly = False,
254        show_year = True,
255        )
256    olevel_results2 = schema.List(
257        title = _(u'2nd Exam Results'),
258        value_type = ResultEntryField(),
259        required = False,
260        readonly = False,
261        defaultFactory=list,
262        )
263    hq_type = schema.Choice(
264        title = _(u'Qualification Obtained'),
265        required = False,
266        readonly = False,
267        vocabulary = high_qual,
268        )
269    hq_matric_no = schema.TextLine(
270        title = _(u'Former Matric Number'),
271        required = False,
272        readonly = False,
273        )
274    hq_degree = schema.Choice(
275        title = _(u'Class of Degree'),
276        required = False,
277        readonly = False,
278        vocabulary = high_grade,
279        )
280    hq_school = schema.TextLine(
281        title = _(u'Institution Attended'),
282        required = False,
283        readonly = False,
284        )
285    hq_session = schema.TextLine(
286        title = _(u'Years Attended'),
287        required = False,
288        readonly = False,
289        )
290    hq_disc = schema.TextLine(
291        title = _(u'Discipline'),
292        required = False,
293        readonly = False,
294        )
295    jamb_subjects = schema.Text(
296        title = _(u'Subjects and Scores'),
297        description = _(u'(one subject with score per line)'),
298        required = False,
299        )
300    jamb_score = schema.Int(
301        title = _(u'Total JAMB Score'),
302        required = False,
303        )
304    jamb_reg_number = schema.TextLine(
305        title = _(u'JAMB Registration Number'),
306        required = False,
307        )
308    notice = schema.Text(
309        title = _(u'Notice'),
310        required = False,
311        )
312    screening_venue = schema.TextLine(
313        title = _(u'Screening Venue'),
314        required = False,
315        )
316    screening_date = schema.TextLine(
317        title = _(u'Screening Date'),
318        required = False,
319        )
320    screening_score = schema.Int(
321        title = _(u'Screening Score (%)'),
322        required = False,
323        )
324    aggregate = schema.Int(
325        title = _(u'Aggregate Score (%)'),
326        description = _(u'(average of relative JAMB and PUTME scores)'),
327        required = False,
328        )
329    result_uploaded = schema.Bool(
330        title = _(u'Result uploaded'),
331        default = False,
332        required = False,
333        )
334    student_id = schema.TextLine(
335        title = _(u'Student Id'),
336        required = False,
337        readonly = False,
338        )
339    course_admitted = schema.Choice(
340        title = _(u'Admitted Course of Study'),
341        source = CertificateSource(),
342        required = False,
343        )
344    locked = schema.Bool(
345        title = _(u'Form locked'),
346        default = False,
347        required = False,
348        )
349
350
351class ICustomPGApplicant(INigeriaPGApplicant):
352    """A postgraduate applicant.
353
354    This interface defines the least common multiple of all fields
355    in pg application forms. In customized forms, fields can be excluded by
356    adding them to the PG_OMIT* tuples.
357    """
358
359class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant,
360    ITPURegistration):
361    """An interface for all types of applicants.
362
363    Attention: The ICustomPGApplicant field seetings will be overwritten
364    by ICustomPGApplicant field settings. If a field is defined
365    in both interfaces zope.schema validates only against the
366    constraints in ICustomUGApplicant. This does not affect the forms
367    since they are build on either ICustomUGApplicant or ICustomPGApplicant.
368    """
369
370    def writeLogMessage(view, comment):
371        """Adds an INFO message to the log file
372        """
373
374    def createStudent():
375        """Create a student object from applicatnt data
376        and copy applicant object.
377        """
378
379class ICustomUGApplicantEdit(ICustomUGApplicant):
380    """An undergraduate applicant interface for edit forms.
381
382    Here we can repeat the fields from base data and set the
383    `required` and `readonly` attributes to True to further restrict
384    the data access. Or we can allow only certain certificates to be
385    selected by choosing the appropriate source.
386
387    We cannot omit fields here. This has to be done in the
388    respective form page.
389    """
390
391
392    email = schema.ASCIILine(
393        title = _(u'Email Address'),
394        required = True,
395        constraint=validate_email,
396        )
397    date_of_birth = FormattedDate(
398        title = _(u'Date of Birth'),
399        required = True,
400        show_year = True,
401        )
402    jamb_reg_number = schema.TextLine(
403        title = _(u'JAMB Registration Number'),
404        required = True,
405        )
406    course1 = schema.Choice(
407        title = _(u'1st Choice Course of Study'),
408        source = AppCatCertificateSource(),
409        required = True,
410        )
411
412ICustomUGApplicantEdit[
413    'date_of_birth'].order =  ICustomUGApplicant['date_of_birth'].order
414ICustomUGApplicantEdit[
415    'email'].order =  ICustomUGApplicant['email'].order
416ICustomUGApplicantEdit[
417    'jamb_reg_number'].order =  ICustomUGApplicant['jamb_reg_number'].order
418ICustomUGApplicantEdit[
419    'course1'].order =  ICustomUGApplicant['course1'].order
420
421class ICustomPGApplicantEdit(ICustomPGApplicant):
422    """A postgraduate applicant interface for editing.
423
424    Here we can repeat the fields from base data and set the
425    `required` and `readonly` attributes to True to further restrict
426    the data access. Or we can allow only certain certificates to be
427    selected by choosing the appropriate source.
428
429    We cannot omit fields here. This has to be done in the
430    respective form page.
431    """
432
433    email = schema.ASCIILine(
434        title = _(u'Email Address'),
435        required = True,
436        constraint=validate_email,
437        )
438    date_of_birth = FormattedDate(
439        title = _(u'Date of Birth'),
440        required = True,
441        show_year = True,
442        )
443
444ICustomPGApplicantEdit[
445    'date_of_birth'].order =  ICustomPGApplicant['date_of_birth'].order
446ICustomPGApplicantEdit[
447    'email'].order =  ICustomPGApplicant['email'].order
448
449
450class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment):
451    """An applicant payment via payment gateways.
452
453    """
454
455class IPUTMEApplicantEdit(IPUTMEApplicantEdit):
456    """An undergraduate applicant interface for editing.
457
458    Here we can repeat the fields from base data and set the
459    `required` and `readonly` attributes to True to further restrict
460    the data access. Or we can allow only certain certificates to be
461    selected by choosing the appropriate source.
462
463    We cannot omit fields here. This has to be done in the
464    respective form page.
465    """
466
467class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo):
468    """Representation of an applicant.
469
470    Skip regular reg_number validation if reg_number is used for finding
471    the applicant object.
472    """
473
Note: See TracBrowser for help on using the repository browser.