source: main/waeup.aaue/trunk/src/waeup/aaue/applicants/interfaces.py @ 13621

Last change on this file since 13621 was 13549, checked in by Henrik Bettermann, 9 years ago

matric_number must not be required in case of import.

  • Property svn:keywords set to Id
File size: 16.4 KB
Line 
1## $Id: interfaces.py 13549 2015-12-17 06:26:17Z 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 zope.interface import Attribute, invariant, Invalid
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)
29from waeup.kofa.schema import FormattedDate, TextLineChoice, PhoneNumber
30from waeup.kofa.interfaces import IKofaObject
31from waeup.kofa.students.vocabularies import (
32    nats_vocab, GenderSource, StudyLevelSource)
33from waeup.kofa.applicants.interfaces import (
34    contextual_reg_num_source,
35    IApplicantBaseData)
36from waeup.kofa.university.vocabularies import StudyModeSource
37from kofacustom.nigeria.applicants.interfaces import (
38    LGASource, high_qual, high_grade, exam_types,
39    INigeriaUGApplicant, INigeriaPGApplicant,
40    INigeriaApplicantOnlinePayment,
41    INigeriaUGApplicantEdit, INigeriaPGApplicantEdit,
42    INigeriaApplicantUpdateByRegNo,
43    IPUTMEApplicantEdit,
44    )
45from waeup.aaue.interfaces import MessageFactory as _
46from waeup.aaue.payments.interfaces import ICustomOnlinePayment
47
48programme_types_vocab = SimpleKofaVocabulary(
49    (_('Undergraduate Programme (100 level)'), 'regular'),
50    (_('Direct Entry (200 level)'), 'direct'),
51    (_('not applicable'), 'na'),
52    )
53
54class ICustomUGApplicant(IApplicantBaseData):
55    """An undergraduate applicant.
56
57    This interface defines the least common multiple of all fields
58    in ug application forms. In customized forms, fields can be excluded by
59    adding them to the UG_OMIT* tuples.
60    """
61
62    programme_type = schema.Choice(
63        title = _(u'Programme Type'),
64        vocabulary = programme_types_vocab,
65        required = False,
66        )
67
68    nationality = schema.Choice(
69        source = nats_vocab,
70        title = _(u'Nationality'),
71        required = True,
72        )
73    lga = schema.Choice(
74        source = LGASource(),
75        title = _(u'State/LGA (Nigerians only)'),
76        required = False,
77        )
78    perm_address = schema.Text(
79        title = _(u'Permanent Address'),
80        required = False,
81        )
82    home_town = schema.TextLine(
83        title = _(u'Home Town'),
84        required = False,
85        )
86    jamb_reg_number = schema.TextLine(
87        title = _(u'JAMB Registration Number'),
88        required = False,
89        )
90    jamb_score = schema.Int(
91        title = _(u'Total JAMB Score'),
92        required = False,
93        )
94    course1 = schema.Choice(
95        title = _(u'1st Choice Course of Study'),
96        source = AppCatCertificateSource(),
97        required = True,
98        )
99    course2 = schema.Choice(
100        title = _(u'2nd Choice Course of Study'),
101        source = AppCatCertificateSource(),
102        required = False,
103        )
104    fst_sit_fname = schema.TextLine(
105        title = _(u'Full Name'),
106        required = False,
107        readonly = False,
108        )
109    fst_sit_no = schema.TextLine(
110        title = _(u'Exam Number'),
111        required = False,
112        readonly = False,
113        )
114    fst_sit_date = FormattedDate(
115        title = _(u'Exam Date'),
116        required = False,
117        readonly = False,
118        show_year = True,
119        )
120    fst_sit_type = schema.Choice(
121        title = _(u'Exam Type'),
122        required = False,
123        readonly = False,
124        vocabulary = exam_types,
125        )
126    fst_sit_results = schema.List(
127        title = _(u'Exam Results'),
128        value_type = ResultEntryField(),
129        required = False,
130        readonly = False,
131        default = [],
132        )
133    scd_sit_fname = schema.TextLine(
134        title = _(u'Full Name'),
135        required = False,
136        readonly = False,
137        )
138    scd_sit_no = schema.TextLine(
139        title = _(u'Exam Number'),
140        required = False,
141        readonly = False,
142        )
143    scd_sit_date = FormattedDate(
144        title = _(u'Exam Date'),
145        required = False,
146        readonly = False,
147        show_year = True,
148        )
149    scd_sit_type = schema.Choice(
150        title = _(u'Exam Type'),
151        required = False,
152        readonly = False,
153        vocabulary = exam_types,
154        )
155    scd_sit_results = schema.List(
156        title = _(u'Exam Results'),
157        value_type = ResultEntryField(),
158        required = False,
159        readonly = False,
160        default = [],
161        )
162    alr_fname = schema.TextLine(
163        title = _(u'Full Name'),
164        required = False,
165        readonly = False,
166        )
167    alr_no = schema.TextLine(
168        title = _(u'Exam Number'),
169        required = False,
170        readonly = False,
171        )
172    alr_date = FormattedDate(
173        title = _(u'Exam Date'),
174        required = False,
175        readonly = False,
176        show_year = True,
177        )
178    alr_results = schema.List(
179        title = _(u'Exam Results'),
180        value_type = ResultEntryField(),
181        required = False,
182        readonly = False,
183        default = [],
184        )
185    hq_type = schema.Choice(
186        title = _(u'Qualification Obtained'),
187        required = False,
188        readonly = False,
189        vocabulary = high_qual,
190        )
191
192    hq_fname = schema.TextLine(
193        title = _(u'Full Name'),
194        required = False,
195        readonly = False,
196        )
197
198    hq_matric_no = schema.TextLine(
199        title = _(u'Former Matric Number'),
200        required = False,
201        readonly = False,
202        )
203
204    hq_degree = schema.Choice(
205        title = _(u'Class of Degree'),
206        required = False,
207        readonly = False,
208        vocabulary = high_grade,
209        )
210
211    hq_school = schema.TextLine(
212        title = _(u'Institution Attended'),
213        required = False,
214        readonly = False,
215        )
216
217    hq_session = schema.TextLine(
218        title = _(u'Years Attended'),
219        required = False,
220        readonly = False,
221        )
222
223    hq_disc = schema.TextLine(
224        title = _(u'Discipline'),
225        required = False,
226        readonly = False,
227        )
228
229    hq_type2 = schema.Choice(
230        title = _(u'Qualification Obtained'),
231        required = False,
232        readonly = False,
233        vocabulary = high_qual,
234        )
235
236    hq_fname2 = schema.TextLine(
237        title = _(u'Full Name'),
238        required = False,
239        readonly = False,
240        )
241
242    hq_matric_no2 = schema.TextLine(
243        title = _(u'Former Matric Number'),
244        required = False,
245        readonly = False,
246        )
247
248    hq_degree2 = schema.Choice(
249        title = _(u'Class of Degree'),
250        required = False,
251        readonly = False,
252        vocabulary = high_grade,
253        )
254
255    hq_school2 = schema.TextLine(
256        title = _(u'Institution Attended'),
257        required = False,
258        readonly = False,
259        )
260
261    hq_session2 = schema.TextLine(
262        title = _(u'Years Attended'),
263        required = False,
264        readonly = False,
265        )
266
267    hq_disc2 = schema.TextLine(
268        title = _(u'Discipline'),
269        required = False,
270        readonly = False,
271        )
272
273    hq_type3 = schema.Choice(
274        title = _(u'Qualification Obtained'),
275        required = False,
276        readonly = False,
277        vocabulary = high_qual,
278        )
279
280    hq_fname3 = schema.TextLine(
281        title = _(u'Full Name'),
282        required = False,
283        readonly = False,
284        )
285
286    hq_matric_no3 = schema.TextLine(
287        title = _(u'Former Matric Number'),
288        required = False,
289        readonly = False,
290        )
291
292    hq_degree3 = schema.Choice(
293        title = _(u'Class of Degree'),
294        required = False,
295        readonly = False,
296        vocabulary = high_grade,
297        )
298
299    hq_school3 = schema.TextLine(
300        title = _(u'Institution Attended'),
301        required = False,
302        readonly = False,
303        )
304
305    hq_session3 = schema.TextLine(
306        title = _(u'Years Attended'),
307        required = False,
308        readonly = False,
309        )
310
311    hq_disc3 = schema.TextLine(
312        title = _(u'Discipline'),
313        required = False,
314        readonly = False,
315        )
316    notice = schema.Text(
317        title = _(u'Notice'),
318        required = False,
319        )
320    #screening_venue = schema.TextLine(
321    #    title = _(u'Screening Venue'),
322    #    required = False,
323    #    )
324    #screening_date = schema.TextLine(
325    #    title = _(u'Screening Date'),
326    #    required = False,
327    #    )
328    #screening_score = schema.Int(
329    #    title = _(u'Screening Score (%)'),
330    #    required = False,
331    #    )
332    #aggregate = schema.Int(
333    #    title = _(u'Aggregate Score (%)'),
334    #    description = _(u'(average of relative JAMB and PUTME scores)'),
335    #    required = False,
336    #    )
337    result_uploaded = schema.Bool(
338        title = _(u'Result uploaded'),
339        default = False,
340        )
341    student_id = schema.TextLine(
342        title = _(u'Student Id'),
343        required = False,
344        readonly = False,
345        )
346    course_admitted = schema.Choice(
347        title = _(u'Admitted Course of Study'),
348        source = CertificateSource(),
349        required = False,
350        )
351    locked = schema.Bool(
352        title = _(u'Form locked'),
353        default = False,
354        )
355
356    @invariant
357    def second_choice(applicant):
358        if applicant.course1 == applicant.course2:
359            raise Invalid(_("2nd choice course must differ from 1st choice course."))
360
361ICustomUGApplicant['programme_type'].order = IApplicantBaseData[
362    'reg_number'].order
363
364class ICustomPGApplicant(INigeriaPGApplicant):
365    """A postgraduate applicant.
366
367    This interface defines the least common multiple of all fields
368    in pg application forms. In customized forms, fields can be excluded by
369    adding them to the PG_OMIT* tuples.
370    """
371
372class ITranscriptApplicant(IKofaObject):
373    """A transcript applicant.
374    """
375
376    suspended = schema.Bool(
377        title = _(u'Account suspended'),
378        default = False,
379        required = False,
380        )
381
382    locked = schema.Bool(
383        title = _(u'Form locked'),
384        default = False,
385        required = False,
386        )
387
388    applicant_id = schema.TextLine(
389        title = _(u'Applicant Id'),
390        required = False,
391        readonly = False,
392        )
393
394    firstname = schema.TextLine(
395        title = _(u'First Name'),
396        required = True,
397        )
398
399    middlename = schema.TextLine(
400        title = _(u'Middle Name'),
401        required = False,
402        )
403
404    lastname = schema.TextLine(
405        title = _(u'Last Name (Surname)'),
406        required = True,
407        )
408
409    matric_number = schema.TextLine(
410        title = _(u'Matriculation Number'),
411        readonly = False,
412        required = False,
413        )
414
415    date_of_birth = FormattedDate(
416        title = _(u'Date of Birth'),
417        required = False,
418        #date_format = u'%d/%m/%Y', # Use grok-instance-wide default
419        show_year = True,
420        )
421
422    place_of_birth = schema.TextLine(
423        title = _(u'Place of Birth'),
424        readonly = False,
425        required = False,
426        )
427
428    nationality = schema.Choice(
429        vocabulary = nats_vocab,
430        title = _(u'Nationality'),
431        required = False,
432        )
433
434    email = schema.ASCIILine(
435        title = _(u'Email Address'),
436        required = True,
437        constraint=validate_email,
438        )
439
440    phone = PhoneNumber(
441        title = _(u'Phone'),
442        description = u'',
443        required = False,
444        )
445
446    perm_address = schema.Text(
447        title = _(u'Current Local Address'),
448        required = False,
449        readonly = False,
450        )
451
452    dispatch_address = schema.Text(
453        title = _(u'Dispatch Address'),
454        description = u'Address to which transcript should be posted.',
455        required = False,
456        readonly = False,
457        )
458
459    entry_mode = schema.Choice(
460        title = _(u'Entry Mode'),
461        source = StudyModeSource(),
462        required = False,
463        readonly = False,
464        )
465
466    entry_session = schema.Choice(
467        title = _(u'Entry Session'),
468        source = academic_sessions_vocab,
469        required = False,
470        readonly = False,
471        )
472
473    end_session = schema.Choice(
474        title = _(u'End Session'),
475        source = academic_sessions_vocab,
476        required = False,
477        readonly = False,
478        )
479
480    course_studied = schema.Choice(
481        title = _(u'Course of Study / Degree'),
482        source = CertificateSource(),
483        required = False,
484        readonly = False,
485        )
486
487    purpose = schema.TextLine(
488        title = _(u'Purpose of this Application'),
489        readonly = False,
490        required = False,
491        )
492
493    course_changed = schema.Choice(
494        title = _(u'Change of Study Course'),
495        description = u'If yes, select previous course of study.',
496        source = CertificateSource(),
497        readonly = False,
498        required = False,
499        )
500
501    change_level = schema.Choice(
502        title = _(u'Change Level'),
503        description = u'If yes, select level at which you changed course of study.',
504        source = StudyLevelSource(),
505        required = False,
506        readonly = False,
507        )
508
509
510class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant,
511                       ITranscriptApplicant):
512    """An interface for all three types of applicants.
513
514    Attention: The ICustomPGApplicant field seetings will be overwritten
515    by ICustomPGApplicant field settings. If a field is defined
516    in both interfaces zope.schema validates only against the
517    constraints in ICustomUGApplicant. This does not affect the forms
518    since they are build on either ICustomUGApplicant or ICustomPGApplicant.
519    """
520
521    def writeLogMessage(view, comment):
522        """Adds an INFO message to the log file
523        """
524
525    def createStudent():
526        """Create a student object from applicatnt data
527        and copy applicant object.
528        """
529
530class ICustomUGApplicantEdit(ICustomUGApplicant):
531    """An undergraduate applicant interface for edit forms.
532
533    Here we can repeat the fields from base data and set the
534    `required` and `readonly` attributes to True to further restrict
535    the data access. Or we can allow only certain certificates to be
536    selected by choosing the appropriate source.
537
538    We cannot omit fields here. This has to be done in the
539    respective form page.
540    """
541
542    programme_type = schema.Choice(
543        title = _(u'Programme Type'),
544        vocabulary = programme_types_vocab,
545        required = True,
546        )
547
548    date_of_birth = FormattedDate(
549        title = _(u'Date of Birth'),
550        required = True,
551        show_year = True,
552        )
553
554ICustomUGApplicantEdit['programme_type'].order = ICustomUGApplicant[
555    'programme_type'].order
556ICustomUGApplicantEdit['date_of_birth'].order = ICustomUGApplicant[
557    'date_of_birth'].order
558
559class ICustomPGApplicantEdit(INigeriaPGApplicantEdit):
560    """A postgraduate applicant interface for editing.
561
562    Here we can repeat the fields from base data and set the
563    `required` and `readonly` attributes to True to further restrict
564    the data access. Or we can allow only certain certificates to be
565    selected by choosing the appropriate source.
566
567    We cannot omit fields here. This has to be done in the
568    respective form page.
569    """
570
571class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment):
572    """An applicant payment via payment gateways.
573
574    """
575
576class IPUTMEApplicantEdit(IPUTMEApplicantEdit):
577    """An undergraduate applicant interface for editing.
578
579    Here we can repeat the fields from base data and set the
580    `required` and `readonly` attributes to True to further restrict
581    the data access. Or we can allow only certain certificates to be
582    selected by choosing the appropriate source.
583
584    We cannot omit fields here. This has to be done in the
585    respective form page.
586    """
587
588class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo):
589    """Representation of an applicant.
590
591    Skip regular reg_number validation if reg_number is used for finding
592    the applicant object.
593    """
594
595
596
Note: See TracBrowser for help on using the repository browser.