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

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

Change application form.

  • Property svn:keywords set to Id
File size: 12.6 KB
Line 
1## $Id: interfaces.py 15863 2019-12-02 18:20:57Z 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)
32from kofacustom.nigeria.applicants.interfaces import (
33    LGASource, high_qual, high_grade, exam_types, DisabilitiesSource,
34    programme_types_vocab, jambsubjects, validate_jamb_reg_number,
35    INigeriaUGApplicant, INigeriaPGApplicant,
36    INigeriaApplicantOnlinePayment,
37    INigeriaUGApplicantEdit, INigeriaPGApplicantEdit,
38    INigeriaApplicantUpdateByRegNo,
39    IPUTMEApplicantEdit,
40    )
41from kofacustom.iuokada.interfaces import MessageFactory as _
42from kofacustom.iuokada.payments.interfaces import ICustomOnlinePayment
43
44sponsors_vocab = SimpleKofaVocabulary(
45    (_('Bauchi Government'), 'bauchi'),
46    (_('Company'), 'company'),
47    (_('Federal Government of Nigeria'), 'federalgov'),
48    #(_('Dangote Group'), 'dangote'),
49    (_('Kano Government'), 'kano'),
50    (_('Parent/Guardian'), 'parent'),
51    (_('Rosula Organization'), 'rosula'),
52    (_('Self'), 'self'),
53    #(_('Social Impact Project'), 'social'),
54    )
55
56heard_about_types_vocab = SimpleKofaVocabulary(
57    (_('Facebook/Twitter/Other Social Media'), 'socmedia'),
58    (_('From a Friend'), 'friend'),
59    (_('Newspaper Advertisement'), 'newspaper'),
60    (_('Radio Advertisement'), 'radio'),
61    (_('Television Advertisement'), 'television'),
62    (_('SMS'), 'sms'),
63    )
64
65subtype_vocab = SimpleKofaVocabulary(
66    (_('UTME'), 'utme'),
67    (_('Direct Entry'), 'de'),
68    (_('Inter Uni Transfer'), 'transfer'),
69    )
70
71class ICustomUGApplicant(IApplicantBaseData):
72    """An undergraduate applicant.
73
74    This interface defines the least common multiple of all fields
75    in ug application forms. In customized forms, fields can be excluded by
76    adding them to the UG_OMIT* tuples.
77    """
78
79    subtype = schema.Choice(
80        title = _(u'Application Subtype'),
81        vocabulary = subtype_vocab,
82        required = False,
83        )
84    disabilities = schema.Choice(
85        title = _(u'Disability'),
86        source = DisabilitiesSource(),
87        required = False,
88        )
89    nationality = schema.Choice(
90        source = nats_vocab,
91        title = _(u'Nationality'),
92        required = False,
93        )
94    lga = schema.Choice(
95        source = LGASource(),
96        title = _(u'State/LGA (Nigerians only)'),
97        required = False,
98        )
99    sponsor = schema.Choice(
100        title = _(u'Sponsor'),
101        vocabulary = sponsors_vocab,
102        required = False,
103        )
104    heard_about = schema.Choice(
105        title = _(u'How did you hear about IUO?'),
106        vocabulary = heard_about_types_vocab,
107        required = False,
108        )
109    #perm_address = schema.Text(
110    #    title = _(u'Permanent Address'),
111    #    required = False,
112    #    )
113    parents_name = schema.TextLine(
114        title = _(u'Full Name'),
115        required = False,
116        readonly = False,
117        )
118    parents_email = schema.ASCIILine(
119        title = _(u'Email Address'),
120        required = False,
121        constraint=validate_email,
122        )
123    parents_phone = PhoneNumber(
124        title = _(u'Phone'),
125        required = False,
126        )
127    course1 = schema.Choice(
128        title = _(u'1st Choice Course of Study'),
129        source = AppCatCertificateSource(),
130        required = True,
131        )
132    course2 = schema.Choice(
133        title = _(u'2nd Choice Course of Study'),
134        source = AppCatCertificateSource(),
135        required = False,
136        )
137    programme_type = schema.Choice(
138        title = _(u'Programme Type'),
139        vocabulary = programme_types_vocab,
140        required = False,
141        )
142    fst_sit_fname = schema.TextLine(
143        title = _(u'Full Name'),
144        required = False,
145        readonly = False,
146        )
147    fst_sit_no = schema.TextLine(
148        title = _(u'Exam Number'),
149        required = False,
150        readonly = False,
151        )
152    fst_sit_date = FormattedDate(
153        title = _(u'Exam Date'),
154        required = False,
155        readonly = False,
156        show_year = True,
157        )
158    fst_sit_type = schema.Choice(
159        title = _(u'Exam Type'),
160        required = False,
161        readonly = False,
162        vocabulary = exam_types,
163        )
164    fst_sit_results = schema.List(
165        title = _(u'Exam Results'),
166        value_type = ResultEntryField(),
167        required = False,
168        readonly = False,
169        defaultFactory=list,
170        )
171    scd_sit_fname = schema.TextLine(
172        title = _(u'Full Name'),
173        required = False,
174        readonly = False,
175        )
176    scd_sit_no = schema.TextLine(
177        title = _(u'Exam Number'),
178        required = False,
179        readonly = False,
180        )
181    scd_sit_date = FormattedDate(
182        title = _(u'Exam Date'),
183        required = False,
184        readonly = False,
185        show_year = True,
186        )
187    scd_sit_type = schema.Choice(
188        title = _(u'Exam Type'),
189        required = False,
190        readonly = False,
191        vocabulary = exam_types,
192        )
193    scd_sit_results = schema.List(
194        title = _(u'Exam Results'),
195        value_type = ResultEntryField(),
196        required = False,
197        readonly = False,
198        defaultFactory=list,
199        )
200    hq_type = schema.Choice(
201        title = _(u'Qualification Obtained'),
202        required = False,
203        readonly = False,
204        vocabulary = high_qual,
205        )
206    hq_matric_no = schema.TextLine(
207        title = _(u'Former Matric Number'),
208        required = False,
209        readonly = False,
210        )
211    hq_degree = schema.Choice(
212        title = _(u'Class of Degree'),
213        required = False,
214        readonly = False,
215        vocabulary = high_grade,
216        )
217    hq_school = schema.TextLine(
218        title = _(u'Institution Attended'),
219        required = False,
220        readonly = False,
221        )
222    hq_session = schema.TextLine(
223        title = _(u'Years Attended'),
224        required = False,
225        readonly = False,
226        )
227    hq_disc = schema.TextLine(
228        title = _(u'Discipline'),
229        required = False,
230        readonly = False,
231        )
232    jamb_subjects = schema.Text(
233        title = _(u'Subjects and Scores'),
234        required = False,
235        )
236    jamb_subjects = schema.Text(
237        title = _(u'Subjects and Scores'),
238        required = False,
239        )
240    jamb_subjects_list = schema.List(
241        title = _(u'JAMB Subjects'),
242        required = False,
243        defaultFactory=list,
244        value_type = schema.Choice(
245            vocabulary = jambsubjects
246            #source = JAMBSubjectSource(),
247            ),
248        )
249    jamb_score = schema.Int(
250        title = _(u'Total JAMB Score'),
251        required = False,
252        )
253    #jamb_age = schema.Int(
254    #    title = _(u'Age (provided by JAMB)'),
255    #    required = False,
256    #    )
257    jamb_reg_number = schema.TextLine(
258        title = _(u'JAMB Registration Number'),
259        required = False,
260        constraint=validate_jamb_reg_number,
261        )
262    notice = schema.Text(
263        title = _(u'Notice'),
264        required = False,
265        )
266    screening_venue = schema.TextLine(
267        title = _(u'Screening Venue'),
268        required = False,
269        )
270    screening_date = schema.TextLine(
271        title = _(u'Screening Date'),
272        required = False,
273        )
274    screening_score = schema.Int(
275        title = _(u'Screening Score (%)'),
276        required = False,
277        )
278    aggregate = schema.Int(
279        title = _(u'Aggregate Score (%)'),
280        description = _(u'(average of relative JAMB and PUTME scores)'),
281        required = False,
282        )
283    result_uploaded = schema.Bool(
284        title = _(u'Result uploaded'),
285        default = False,
286        required = 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        )
298    locked = schema.Bool(
299        title = _(u'Form locked'),
300        default = False,
301        required = False,
302        )
303
304ICustomUGApplicant[
305    'subtype'].order =  ICustomUGApplicant['lga'].order
306ICustomUGApplicant[
307    'locked'].order =  ICustomUGApplicant['suspended'].order
308ICustomUGApplicant[
309    'result_uploaded'].order =  ICustomUGApplicant['suspended'].order
310
311class ICustomPGApplicant(INigeriaPGApplicant):
312    """A postgraduate applicant.
313
314    This interface defines the least common multiple of all fields
315    in pg application forms. In customized forms, fields can be excluded by
316    adding them to the PG_OMIT* tuples.
317    """
318
319    sponsor = schema.Choice(
320        title = _(u'Sponsor'),
321        vocabulary = sponsors_vocab,
322        required = False,
323        )
324
325    heard_about = schema.Choice(
326        title = _(u'How did you hear about IU?'),
327        vocabulary = heard_about_types_vocab,
328        required = False,
329        )
330
331ICustomPGApplicant[
332    'sponsor'].order =  ICustomPGApplicant['lga'].order
333ICustomPGApplicant[
334    'heard_about'].order =  ICustomPGApplicant['lga'].order
335ICustomPGApplicant[
336    'sponsor'].order =  ICustomPGApplicant['lga'].order
337ICustomPGApplicant[
338    'lga'].order =  ICustomPGApplicant['nationality'].order
339
340class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant):
341    """An interface for both types of applicants.
342
343    Attention: The ICustomPGApplicant field seetings will be overwritten
344    by ICustomPGApplicant field settings. If a field is defined
345    in both interfaces zope.schema validates only against the
346    constraints in ICustomUGApplicant. This does not affect the forms
347    since they are build on either ICustomUGApplicant or ICustomPGApplicant.
348    """
349
350    def writeLogMessage(view, comment):
351        """Adds an INFO message to the log file
352        """
353
354    def createStudent():
355        """Create a student object from applicant data
356        and copy applicant object.
357        """
358
359class ICustomUGApplicantEdit(ICustomUGApplicant):
360    """An undergraduate applicant interface for edit forms.
361
362    Here we can repeat the fields from base data and set the
363    `required` and `readonly` attributes to True to further restrict
364    the data access. Or we can allow only certain certificates to be
365    selected by choosing the appropriate source.
366
367    We cannot omit fields here. This has to be done in the
368    respective form page.
369    """
370
371class ICustomPGApplicantEdit(ICustomPGApplicant):
372    """A postgraduate applicant interface for editing.
373
374    Here we can repeat the fields from base data and set the
375    `required` and `readonly` attributes to True to further restrict
376    the data access. Or we can allow only certain certificates to be
377    selected by choosing the appropriate source.
378
379    We cannot omit fields here. This has to be done in the
380    respective form page.
381    """
382
383class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment):
384    """An applicant payment via payment gateways.
385
386    """
387
388class IPUTMEApplicantEdit(IPUTMEApplicantEdit):
389    """An undergraduate applicant interface for editing.
390
391    Here we can repeat the fields from base data and set the
392    `required` and `readonly` attributes to True to further restrict
393    the data access. Or we can allow only certain certificates to be
394    selected by choosing the appropriate source.
395
396    We cannot omit fields here. This has to be done in the
397    respective form page.
398    """
399
400class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo):
401    """Representation of an applicant.
402
403    Skip regular reg_number validation if reg_number is used for finding
404    the applicant object.
405    """
Note: See TracBrowser for help on using the repository browser.