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

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

Make JAMB fileds editable.

  • Property svn:keywords set to Id
File size: 12.5 KB
Line 
1## $Id: interfaces.py 15884 2019-12-12 06:17:45Z 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_list = schema.List(
237        title = _(u'JAMB Subjects'),
238        required = False,
239        defaultFactory=list,
240        value_type = schema.Choice(
241            vocabulary = jambsubjects
242            #source = JAMBSubjectSource(),
243            ),
244        )
245    jamb_score = schema.Int(
246        title = _(u'Total JAMB Score'),
247        required = False,
248        )
249    #jamb_age = schema.Int(
250    #    title = _(u'Age (provided by JAMB)'),
251    #    required = False,
252    #    )
253    jamb_reg_number = schema.TextLine(
254        title = _(u'JAMB Registration Number'),
255        required = False,
256        constraint=validate_jamb_reg_number,
257        )
258    notice = schema.Text(
259        title = _(u'Notice'),
260        required = False,
261        )
262    screening_venue = schema.TextLine(
263        title = _(u'Screening Venue'),
264        required = False,
265        )
266    screening_date = schema.TextLine(
267        title = _(u'Screening Date'),
268        required = False,
269        )
270    screening_score = schema.Int(
271        title = _(u'Screening Score (%)'),
272        required = False,
273        )
274    aggregate = schema.Int(
275        title = _(u'Aggregate Score (%)'),
276        description = _(u'(average of relative JAMB and PUTME scores)'),
277        required = False,
278        )
279    result_uploaded = schema.Bool(
280        title = _(u'Result uploaded'),
281        default = False,
282        required = False,
283        )
284    student_id = schema.TextLine(
285        title = _(u'Student Id'),
286        required = False,
287        readonly = False,
288        )
289    course_admitted = schema.Choice(
290        title = _(u'Admitted Course of Study'),
291        source = CertificateSource(),
292        required = False,
293        )
294    locked = schema.Bool(
295        title = _(u'Form locked'),
296        default = False,
297        required = False,
298        )
299
300ICustomUGApplicant[
301    'subtype'].order =  ICustomUGApplicant['lga'].order
302ICustomUGApplicant[
303    'locked'].order =  ICustomUGApplicant['suspended'].order
304ICustomUGApplicant[
305    'result_uploaded'].order =  ICustomUGApplicant['suspended'].order
306
307class ICustomPGApplicant(INigeriaPGApplicant):
308    """A postgraduate applicant.
309
310    This interface defines the least common multiple of all fields
311    in pg application forms. In customized forms, fields can be excluded by
312    adding them to the PG_OMIT* tuples.
313    """
314
315    sponsor = schema.Choice(
316        title = _(u'Sponsor'),
317        vocabulary = sponsors_vocab,
318        required = False,
319        )
320
321    heard_about = schema.Choice(
322        title = _(u'How did you hear about IU?'),
323        vocabulary = heard_about_types_vocab,
324        required = False,
325        )
326
327ICustomPGApplicant[
328    'sponsor'].order =  ICustomPGApplicant['lga'].order
329ICustomPGApplicant[
330    'heard_about'].order =  ICustomPGApplicant['lga'].order
331ICustomPGApplicant[
332    'sponsor'].order =  ICustomPGApplicant['lga'].order
333ICustomPGApplicant[
334    'lga'].order =  ICustomPGApplicant['nationality'].order
335
336class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant):
337    """An interface for both types of applicants.
338
339    Attention: The ICustomPGApplicant field seetings will be overwritten
340    by ICustomPGApplicant field settings. If a field is defined
341    in both interfaces zope.schema validates only against the
342    constraints in ICustomUGApplicant. This does not affect the forms
343    since they are build on either ICustomUGApplicant or ICustomPGApplicant.
344    """
345
346    def writeLogMessage(view, comment):
347        """Adds an INFO message to the log file
348        """
349
350    def createStudent():
351        """Create a student object from applicant data
352        and copy applicant object.
353        """
354
355class ICustomUGApplicantEdit(ICustomUGApplicant):
356    """An undergraduate applicant interface for edit forms.
357
358    Here we can repeat the fields from base data and set the
359    `required` and `readonly` attributes to True to further restrict
360    the data access. Or we can allow only certain certificates to be
361    selected by choosing the appropriate source.
362
363    We cannot omit fields here. This has to be done in the
364    respective form page.
365    """
366
367class ICustomPGApplicantEdit(ICustomPGApplicant):
368    """A postgraduate applicant interface for editing.
369
370    Here we can repeat the fields from base data and set the
371    `required` and `readonly` attributes to True to further restrict
372    the data access. Or we can allow only certain certificates to be
373    selected by choosing the appropriate source.
374
375    We cannot omit fields here. This has to be done in the
376    respective form page.
377    """
378
379class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment):
380    """An applicant payment via payment gateways.
381
382    """
383
384class IPUTMEApplicantEdit(IPUTMEApplicantEdit):
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
396class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo):
397    """Representation of an applicant.
398
399    Skip regular reg_number validation if reg_number is used for finding
400    the applicant object.
401    """
Note: See TracBrowser for help on using the repository browser.