source: main/kofacustom.iuokada/trunk/src/kofacustom/iuokada/applicants/interfaces.py @ 16111

Last change on this file since 16111 was 16105, checked in by Henrik Bettermann, 5 years ago

Make phone number a required field.

  • Property svn:keywords set to Id
File size: 16.9 KB
Line 
1## $Id: interfaces.py 16105 2020-06-04 06:28:08Z 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, PhoneNumber
29from waeup.kofa.students.vocabularies import nats_vocab, GenderSource
30from waeup.kofa.applicants.interfaces import (
31    contextual_reg_num_source, IApplicantBaseData, IApplicantRefereeReport)
32from waeup.kofa.refereeentries import RefereeEntryField
33from kofacustom.nigeria.applicants.interfaces import (
34    LGASource, high_qual, high_grade, exam_types, DisabilitiesSource,
35    programme_types_vocab, jambsubjects, validate_jamb_reg_number,
36    INigeriaUGApplicant, INigeriaPGApplicant,
37    INigeriaApplicantOnlinePayment,
38    INigeriaUGApplicantEdit, INigeriaPGApplicantEdit,
39    INigeriaApplicantUpdateByRegNo,
40    IPUTMEApplicantEdit,
41    )
42from kofacustom.iuokada.interfaces import MessageFactory as _
43from kofacustom.iuokada.payments.interfaces import ICustomOnlinePayment
44
45sponsors_vocab = SimpleKofaVocabulary(
46    (_('Bauchi Government'), 'bauchi'),
47    (_('Company'), 'company'),
48    (_('Federal Government of Nigeria'), 'federalgov'),
49    #(_('Dangote Group'), 'dangote'),
50    (_('Kano Government'), 'kano'),
51    (_('Parent/Guardian'), 'parent'),
52    (_('Rosula Organization'), 'rosula'),
53    (_('Self'), 'self'),
54    #(_('Social Impact Project'), 'social'),
55    )
56
57heard_about_types_vocab = SimpleKofaVocabulary(
58    (_('Facebook/Twitter/Other Social Media'), 'socmedia'),
59    (_('From a Friend'), 'friend'),
60    (_('Newspaper Advertisement'), 'newspaper'),
61    (_('Radio Advertisement'), 'radio'),
62    (_('Television Advertisement'), 'television'),
63    (_('SMS'), 'sms'),
64    )
65
66subtype_vocab = SimpleKofaVocabulary(
67    (_('UTME'), 'utme'),
68    (_('Direct Entry'), 'de'),
69    (_('Inter Uni Transfer'), 'transfer'),
70    )
71
72rating_vocab = SimpleKofaVocabulary(
73    (_('Excellent'), 'e'),
74    (_('Very good'), 'vg'),
75    (_('Good'), 'g'),
76    (_('Slightly above average'), 'saa'),
77    (_('Average'), 'a'),
78    (_('Below average'), 'ba'),
79    (_('Unable to assess'), 'unable'),
80    )
81
82
83overallpromise_vocab = SimpleKofaVocabulary(
84    (_('Very good (highest 10%)'), 'vg'),
85    (_('Above average (next 15%)'), 'aa'),
86    (_('Average (middle 20%)'), 'a'),
87    (_('Below average (middle 40%)'), 'ba'),
88    )
89
90class ICustomUGApplicant(IApplicantBaseData):
91    """An undergraduate applicant.
92
93    This interface defines the least common multiple of all fields
94    in ug application forms. In customized forms, fields can be excluded by
95    adding them to the UG_OMIT* tuples.
96    """
97
98    subtype = schema.Choice(
99        title = _(u'Application Subtype'),
100        vocabulary = subtype_vocab,
101        required = False,
102        )
103    disabilities = schema.Choice(
104        title = _(u'Disability'),
105        source = DisabilitiesSource(),
106        required = False,
107        )
108    nationality = schema.Choice(
109        source = nats_vocab,
110        title = _(u'Nationality'),
111        required = False,
112        )
113    lga = schema.Choice(
114        source = LGASource(),
115        title = _(u'State/LGA (Nigerians only)'),
116        required = False,
117        )
118    sponsor = schema.Choice(
119        title = _(u'Sponsor'),
120        vocabulary = sponsors_vocab,
121        required = False,
122        )
123    heard_about = schema.Choice(
124        title = _(u'How did you hear about IUO?'),
125        vocabulary = heard_about_types_vocab,
126        required = False,
127        )
128    #perm_address = schema.Text(
129    #    title = _(u'Permanent Address'),
130    #    required = False,
131    #    )
132    parents_name = schema.TextLine(
133        title = _(u'Full Name'),
134        required = False,
135        readonly = False,
136        )
137    parents_email = schema.ASCIILine(
138        title = _(u'Email Address'),
139        required = False,
140        constraint=validate_email,
141        )
142    parents_phone = PhoneNumber(
143        title = _(u'Phone'),
144        required = False,
145        )
146    course1 = schema.Choice(
147        title = _(u'1st Choice Course of Study'),
148        source = AppCatCertificateSource(),
149        required = True,
150        )
151    course2 = schema.Choice(
152        title = _(u'2nd Choice Course of Study'),
153        source = AppCatCertificateSource(),
154        required = False,
155        )
156    programme_type = schema.Choice(
157        title = _(u'Programme Type'),
158        vocabulary = programme_types_vocab,
159        required = False,
160        )
161    fst_sit_fname = schema.TextLine(
162        title = _(u'Full Name'),
163        required = False,
164        readonly = False,
165        )
166    fst_sit_no = schema.TextLine(
167        title = _(u'Exam Number'),
168        required = False,
169        readonly = False,
170        )
171    fst_sit_date = FormattedDate(
172        title = _(u'Exam Date'),
173        required = False,
174        readonly = False,
175        show_year = True,
176        )
177    fst_sit_type = schema.Choice(
178        title = _(u'Exam Type'),
179        required = False,
180        readonly = False,
181        vocabulary = exam_types,
182        )
183    fst_sit_results = schema.List(
184        title = _(u'Exam Results'),
185        value_type = ResultEntryField(),
186        required = False,
187        readonly = False,
188        defaultFactory=list,
189        )
190    scd_sit_fname = schema.TextLine(
191        title = _(u'Full Name'),
192        required = False,
193        readonly = False,
194        )
195    scd_sit_no = schema.TextLine(
196        title = _(u'Exam Number'),
197        required = False,
198        readonly = False,
199        )
200    scd_sit_date = FormattedDate(
201        title = _(u'Exam Date'),
202        required = False,
203        readonly = False,
204        show_year = True,
205        )
206    scd_sit_type = schema.Choice(
207        title = _(u'Exam Type'),
208        required = False,
209        readonly = False,
210        vocabulary = exam_types,
211        )
212    scd_sit_results = schema.List(
213        title = _(u'Exam Results'),
214        value_type = ResultEntryField(),
215        required = False,
216        readonly = False,
217        defaultFactory=list,
218        )
219    hq_type = schema.Choice(
220        title = _(u'Qualification Obtained'),
221        required = False,
222        readonly = False,
223        vocabulary = high_qual,
224        )
225    hq_matric_no = schema.TextLine(
226        title = _(u'Former Matric Number'),
227        required = False,
228        readonly = False,
229        )
230    hq_degree = schema.Choice(
231        title = _(u'Class of Degree'),
232        required = False,
233        readonly = False,
234        vocabulary = high_grade,
235        )
236    hq_school = schema.TextLine(
237        title = _(u'Institution Attended'),
238        required = False,
239        readonly = False,
240        )
241    hq_session = schema.TextLine(
242        title = _(u'Years Attended'),
243        required = False,
244        readonly = False,
245        )
246    hq_disc = schema.TextLine(
247        title = _(u'Discipline'),
248        required = False,
249        readonly = False,
250        )
251    #jamb_subjects = schema.Text(
252    #    title = _(u'Subjects and Scores'),
253    #    required = False,
254    #    )
255    jamb_subjects_list = schema.List(
256        title = _(u'JAMB Subjects'),
257        required = False,
258        defaultFactory=list,
259        value_type = schema.Choice(
260            vocabulary = jambsubjects
261            #source = JAMBSubjectSource(),
262            ),
263        )
264    jamb_score = schema.Int(
265        title = _(u'Total JAMB Score'),
266        required = False,
267        )
268    #jamb_age = schema.Int(
269    #    title = _(u'Age (provided by JAMB)'),
270    #    required = False,
271    #    )
272    jamb_reg_number = schema.TextLine(
273        title = _(u'JAMB Registration Number'),
274        required = False,
275        constraint=validate_jamb_reg_number,
276        )
277    notice = schema.Text(
278        title = _(u'Notice'),
279        required = False,
280        )
281    screening_venue = schema.TextLine(
282        title = _(u'Screening Venue'),
283        required = False,
284        )
285    screening_date = schema.TextLine(
286        title = _(u'Screening Date'),
287        required = False,
288        )
289    screening_score = schema.Int(
290        title = _(u'Screening Score (%)'),
291        required = False,
292        )
293    aggregate = schema.Int(
294        title = _(u'Aggregate Score (%)'),
295        description = _(u'(average of relative JAMB and PUTME scores)'),
296        required = False,
297        )
298    result_uploaded = schema.Bool(
299        title = _(u'Result uploaded'),
300        default = False,
301        required = False,
302        )
303    student_id = schema.TextLine(
304        title = _(u'Student Id'),
305        required = False,
306        readonly = False,
307        )
308    course_admitted = schema.Choice(
309        title = _(u'Admitted Course of Study'),
310        source = CertificateSource(),
311        required = False,
312        )
313    locked = schema.Bool(
314        title = _(u'Form locked'),
315        default = False,
316        required = False,
317        )
318
319ICustomUGApplicant[
320    'subtype'].order =  ICustomUGApplicant['lga'].order
321ICustomUGApplicant[
322    'locked'].order =  ICustomUGApplicant['suspended'].order
323ICustomUGApplicant[
324    'result_uploaded'].order =  ICustomUGApplicant['suspended'].order
325
326class ICustomPGApplicant(INigeriaPGApplicant):
327    """A postgraduate applicant.
328
329    This interface defines the least common multiple of all fields
330    in pg application forms. In customized forms, fields can be excluded by
331    adding them to the PG_OMIT* tuples.
332    """
333
334    sponsor = schema.Choice(
335        title = _(u'Sponsor'),
336        vocabulary = sponsors_vocab,
337        required = False,
338        )
339
340    heard_about = schema.Choice(
341        title = _(u'How did you hear about IU?'),
342        vocabulary = heard_about_types_vocab,
343        required = False,
344        )
345
346    nysc_number = schema.Int(
347        title = _(u'Nysc Number'),
348        required = False,
349        readonly = False,
350        )
351
352    referees = schema.List(
353        title = _(u'Referees'),
354        value_type = RefereeEntryField(),
355        required = False,
356        defaultFactory=list,
357        )
358
359ICustomPGApplicant[
360    'referees'].order =  INigeriaPGApplicant['emp2_reason'].order
361ICustomPGApplicant[
362    'sponsor'].order =  ICustomPGApplicant['lga'].order
363ICustomPGApplicant[
364    'heard_about'].order =  ICustomPGApplicant['lga'].order
365ICustomPGApplicant[
366    'sponsor'].order =  ICustomPGApplicant['lga'].order
367ICustomPGApplicant[
368    'lga'].order =  ICustomPGApplicant['nationality'].order
369ICustomPGApplicant[
370    'nysc_number'].order =  ICustomPGApplicant['nysc_year'].order
371
372class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant):
373    """An interface for both types of applicants.
374
375    Attention: The ICustomPGApplicant field seetings will be overwritten
376    by ICustomPGApplicant field settings. If a field is defined
377    in both interfaces zope.schema validates only against the
378    constraints in ICustomUGApplicant. This does not affect the forms
379    since they are build on either ICustomUGApplicant or ICustomPGApplicant.
380    """
381
382    def writeLogMessage(view, comment):
383        """Adds an INFO message to the log file
384        """
385
386    def createStudent():
387        """Create a student object from applicant data
388        and copy applicant object.
389        """
390
391class ICustomUGApplicantEdit(ICustomUGApplicant):
392    """An undergraduate applicant interface for edit forms.
393
394    Here we can repeat the fields from base data and set the
395    `required` and `readonly` attributes to True to further restrict
396    the data access. Or we can allow only certain certificates to be
397    selected by choosing the appropriate source.
398
399    We cannot omit fields here. This has to be done in the
400    respective form page.
401    """
402
403    phone = PhoneNumber(
404        title = _(u'Phone'),
405        description = u'',
406        required = True,
407        )
408    email = schema.ASCIILine(
409        title = _(u'Email Address'),
410        required = True,
411        constraint=validate_email,
412        )
413    date_of_birth = FormattedDate(
414        title = _(u'Date of Birth'),
415        required = True,
416        show_year = True,
417        )
418
419ICustomUGApplicantEdit[
420    'date_of_birth'].order = ICustomUGApplicant['date_of_birth'].order
421ICustomUGApplicantEdit[
422    'email'].order = ICustomUGApplicant['email'].order
423ICustomUGApplicantEdit[
424    'phone'].order =  ICustomUGApplicantEdit['email'].order
425
426class ICustomPGApplicantEdit(ICustomPGApplicant):
427    """A postgraduate applicant interface for editing.
428
429    Here we can repeat the fields from base data and set the
430    `required` and `readonly` attributes to True to further restrict
431    the data access. Or we can allow only certain certificates to be
432    selected by choosing the appropriate source.
433
434    We cannot omit fields here. This has to be done in the
435    respective form page.
436    """
437
438    phone = PhoneNumber(
439        title = _(u'Phone'),
440        description = u'',
441        required = True,
442        )
443    email = schema.ASCIILine(
444        title = _(u'Email Address'),
445        required = True,
446        constraint=validate_email,
447        )
448    date_of_birth = FormattedDate(
449        title = _(u'Date of Birth'),
450        required = True,
451        show_year = True,
452        )
453
454ICustomPGApplicantEdit[
455    'date_of_birth'].order = ICustomPGApplicant['date_of_birth'].order
456ICustomPGApplicantEdit[
457    'email'].order = ICustomPGApplicant['email'].order
458ICustomPGApplicantEdit[
459    'phone'].order =  ICustomPGApplicantEdit['email'].order
460
461class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment):
462    """An applicant payment via payment gateways.
463
464    """
465
466class IPUTMEApplicantEdit(IPUTMEApplicantEdit):
467    """An undergraduate applicant interface for editing.
468
469    Here we can repeat the fields from base data and set the
470    `required` and `readonly` attributes to True to further restrict
471    the data access. Or we can allow only certain certificates to be
472    selected by choosing the appropriate source.
473
474    We cannot omit fields here. This has to be done in the
475    respective form page.
476    """
477
478class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo):
479    """Representation of an applicant.
480
481    Skip regular reg_number validation if reg_number is used for finding
482    the applicant object.
483    """
484
485class ICustomApplicantRefereeReport(IApplicantRefereeReport):
486    """A referee report.
487    """
488
489    duration = schema.Text(
490        title = _(u'How long and in what capacity have you known the candidate?'),
491        required = False,
492        )
493
494    itellectual = schema.Choice(
495        title = _(u'Intellectual Capacity'),
496        required = False,
497        readonly = False,
498        vocabulary = rating_vocab,
499        )
500
501    persistent = schema.Choice(
502        title = _(u'Capacity for Persistent and Independent Academic Study'),
503        required = False,
504        readonly = False,
505        vocabulary = rating_vocab,
506        )
507
508    imaginative = schema.Choice(
509        title = _(u'Ability for Imaginative Thought'),
510        required = False,
511        readonly = False,
512        vocabulary = rating_vocab,
513        )
514
515    productive = schema.Choice(
516        title = _(u'Promise of Productive Scholarship'),
517        required = False,
518        readonly = False,
519        vocabulary = rating_vocab,
520        )
521
522    previous = schema.Choice(
523        title = _(u'Quality of Previous Work'),
524        required = False,
525        readonly = False,
526        vocabulary = rating_vocab,
527        )
528
529    expression = schema.Choice(
530        title = _(u'Oral and Written Expression in English'),
531        required = False,
532        readonly = False,
533        vocabulary = rating_vocab,
534        )
535
536    personality = schema.Text(
537        title = _(u'Please comment on the candidate\'s personality '
538            'with particular reference to his/her moral character, emotional '
539            'and physical stabilty'),
540        required = False,
541        )
542
543    promise = schema.Choice(
544        title = _(u'Candidate\'s overall promise'),
545        required = False,
546        readonly = False,
547        vocabulary = overallpromise_vocab,
548        )
549
550    report = schema.Text(
551        title = _(u'Any other relevant information which would help '
552            'in determining the candidate\'s suitability?'),
553        required = False,
554        )
555
556    objection = schema.Text(
557        title = _(u'Have you any objection to the contents of this '
558            'evaluation being disclosed to any award-given body if '
559            'the need arises?'),
560        required = False,
561        )
Note: See TracBrowser for help on using the repository browser.