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

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

Fix typo.

  • Property svn:keywords set to Id
File size: 15.7 KB
Line 
1## $Id: interfaces.py 16063 2020-04-21 07:30:27Z 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
403class ICustomPGApplicantEdit(ICustomPGApplicant):
404    """A postgraduate applicant interface for editing.
405
406    Here we can repeat the fields from base data and set the
407    `required` and `readonly` attributes to True to further restrict
408    the data access. Or we can allow only certain certificates to be
409    selected by choosing the appropriate source.
410
411    We cannot omit fields here. This has to be done in the
412    respective form page.
413    """
414
415class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment):
416    """An applicant payment via payment gateways.
417
418    """
419
420class IPUTMEApplicantEdit(IPUTMEApplicantEdit):
421    """An undergraduate applicant interface for editing.
422
423    Here we can repeat the fields from base data and set the
424    `required` and `readonly` attributes to True to further restrict
425    the data access. Or we can allow only certain certificates to be
426    selected by choosing the appropriate source.
427
428    We cannot omit fields here. This has to be done in the
429    respective form page.
430    """
431
432class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo):
433    """Representation of an applicant.
434
435    Skip regular reg_number validation if reg_number is used for finding
436    the applicant object.
437    """
438
439class ICustomApplicantRefereeReport(IApplicantRefereeReport):
440    """A referee report.
441    """
442
443    duration = schema.Text(
444        title = _(u'How long and in what capacity have you known the candidate?'),
445        required = False,
446        )
447
448    itellectual = schema.Choice(
449        title = _(u'Intellectual Capacity'),
450        required = False,
451        readonly = False,
452        vocabulary = rating_vocab,
453        )
454
455    persistent = schema.Choice(
456        title = _(u'Capacity for Persistent and Independent Academic Study'),
457        required = False,
458        readonly = False,
459        vocabulary = rating_vocab,
460        )
461
462    imaginative = schema.Choice(
463        title = _(u'Ability for Imaginative Thought'),
464        required = False,
465        readonly = False,
466        vocabulary = rating_vocab,
467        )
468
469    productive = schema.Choice(
470        title = _(u'Promise of Productive Scholarship'),
471        required = False,
472        readonly = False,
473        vocabulary = rating_vocab,
474        )
475
476    previous = schema.Choice(
477        title = _(u'Quality of Previous Work'),
478        required = False,
479        readonly = False,
480        vocabulary = rating_vocab,
481        )
482
483    expression = schema.Choice(
484        title = _(u'Oral and Written Expression in English'),
485        required = False,
486        readonly = False,
487        vocabulary = rating_vocab,
488        )
489
490    personality = schema.Text(
491        title = _(u'Please comment on the candidate\'s personality '
492            'with particular reference to his/her moral character, emotional '
493            'and physical stabilty'),
494        required = False,
495        )
496
497    promise = schema.Choice(
498        title = _(u'Candidate\'s overall promise'),
499        required = False,
500        readonly = False,
501        vocabulary = overallpromise_vocab,
502        )
503
504    report = schema.Text(
505        title = _(u'Any other relevant information which would help '
506            'in determining the candidate\'s suitability?'),
507        required = False,
508        )
509
510    objection = schema.Text(
511        title = _(u'Have you any objection to the contents of this '
512            'evaluation being disclosed to any award-given body if '
513            'the need arises?'),
514        required = False,
515        )
Note: See TracBrowser for help on using the repository browser.