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

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

Add emplayment history fields.

Define omit fields for ptee application.

  • Property svn:keywords set to Id
File size: 18.3 KB
Line 
1## $Id: interfaces.py 13679 2016-02-11 13:23:15Z 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
317    nysc_year = schema.Int(
318        title = _(u'Nysc Year'),
319        required = False,
320        readonly = False,
321        )
322
323    nysc_location = schema.TextLine(
324        title = _(u'Nysc Location'),
325        required = False,
326        )
327
328    nysc_lga = schema.Choice(
329        source = LGASource(),
330        title = _(u'Nysc LGA'),
331        required = False,
332        )
333
334    employer = schema.TextLine(
335        title = _(u'Employer'),
336        required = False,
337        readonly = False,
338        )
339
340    emp_position = schema.TextLine(
341        title = _(u'Employer Position'),
342        required = False,
343        readonly = False,
344        )
345
346    emp_start = FormattedDate(
347        title = _(u'Start Date'),
348        required = False,
349        readonly = False,
350        show_year = True,
351        )
352
353    emp_end = FormattedDate(
354        title = _(u'End Date'),
355        required = False,
356        readonly = False,
357        show_year = True,
358        )
359
360    emp_reason = schema.TextLine(
361        title = _(u'Reason for Leaving'),
362        required = False,
363        readonly = False,
364        )
365
366    employer2 = schema.TextLine(
367        title = _(u'2nd Employer'),
368        required = False,
369        readonly = False,
370        )
371
372    emp2_position = schema.TextLine(
373        title = _(u'2nd Employer Position'),
374        required = False,
375        readonly = False,
376        )
377
378    emp2_start = FormattedDate(
379        title = _(u'Start Date'),
380        required = False,
381        readonly = False,
382        show_year = True,
383        )
384
385    emp2_end = FormattedDate(
386        title = _(u'End Date'),
387        required = False,
388        readonly = False,
389        show_year = True,
390        )
391
392    emp2_reason = schema.TextLine(
393        title = _(u'Reason for Leaving'),
394        required = False,
395        readonly = False,
396        )
397
398    former_matric = schema.TextLine(
399        title = _(u'If yes, matric number'),
400        required = False,
401        readonly = False,
402        )
403
404    notice = schema.Text(
405        title = _(u'Notice'),
406        required = False,
407        )
408    #screening_venue = schema.TextLine(
409    #    title = _(u'Screening Venue'),
410    #    required = False,
411    #    )
412    #screening_date = schema.TextLine(
413    #    title = _(u'Screening Date'),
414    #    required = False,
415    #    )
416    #screening_score = schema.Int(
417    #    title = _(u'Screening Score (%)'),
418    #    required = False,
419    #    )
420    #aggregate = schema.Int(
421    #    title = _(u'Aggregate Score (%)'),
422    #    description = _(u'(average of relative JAMB and PUTME scores)'),
423    #    required = False,
424    #    )
425    result_uploaded = schema.Bool(
426        title = _(u'Result uploaded'),
427        default = False,
428        )
429    student_id = schema.TextLine(
430        title = _(u'Student Id'),
431        required = False,
432        readonly = False,
433        )
434    course_admitted = schema.Choice(
435        title = _(u'Admitted Course of Study'),
436        source = CertificateSource(),
437        required = False,
438        )
439    locked = schema.Bool(
440        title = _(u'Form locked'),
441        default = False,
442        )
443
444    @invariant
445    def second_choice(applicant):
446        if applicant.course1 == applicant.course2:
447            raise Invalid(_("2nd choice course must differ from 1st choice course."))
448
449ICustomUGApplicant['programme_type'].order = IApplicantBaseData[
450    'reg_number'].order
451
452class ICustomPGApplicant(INigeriaPGApplicant):
453    """A postgraduate applicant.
454
455    This interface defines the least common multiple of all fields
456    in pg application forms. In customized forms, fields can be excluded by
457    adding them to the PG_OMIT* tuples.
458    """
459
460class ITranscriptApplicant(IKofaObject):
461    """A transcript applicant.
462    """
463
464    suspended = schema.Bool(
465        title = _(u'Account suspended'),
466        default = False,
467        required = False,
468        )
469
470    locked = schema.Bool(
471        title = _(u'Form locked'),
472        default = False,
473        required = False,
474        )
475
476    applicant_id = schema.TextLine(
477        title = _(u'Applicant Id'),
478        required = False,
479        readonly = False,
480        )
481
482    firstname = schema.TextLine(
483        title = _(u'First Name'),
484        required = True,
485        )
486
487    middlename = schema.TextLine(
488        title = _(u'Middle Name'),
489        required = False,
490        )
491
492    lastname = schema.TextLine(
493        title = _(u'Last Name (Surname)'),
494        required = True,
495        )
496
497    matric_number = schema.TextLine(
498        title = _(u'Matriculation Number'),
499        readonly = False,
500        required = False,
501        )
502
503    date_of_birth = FormattedDate(
504        title = _(u'Date of Birth'),
505        required = False,
506        #date_format = u'%d/%m/%Y', # Use grok-instance-wide default
507        show_year = True,
508        )
509
510    place_of_birth = schema.TextLine(
511        title = _(u'Place of Birth'),
512        readonly = False,
513        required = False,
514        )
515
516    nationality = schema.Choice(
517        vocabulary = nats_vocab,
518        title = _(u'Nationality'),
519        required = False,
520        )
521
522    email = schema.ASCIILine(
523        title = _(u'Email Address'),
524        required = True,
525        constraint=validate_email,
526        )
527
528    phone = PhoneNumber(
529        title = _(u'Phone'),
530        description = u'',
531        required = False,
532        )
533
534    perm_address = schema.Text(
535        title = _(u'Current Local Address'),
536        required = False,
537        readonly = False,
538        )
539
540    dispatch_address = schema.Text(
541        title = _(u'Dispatch Address'),
542        description = u'Address to which transcript should be posted.',
543        required = False,
544        readonly = False,
545        )
546
547    entry_mode = schema.Choice(
548        title = _(u'Entry Mode'),
549        source = StudyModeSource(),
550        required = False,
551        readonly = False,
552        )
553
554    entry_session = schema.Choice(
555        title = _(u'Entry Session'),
556        source = academic_sessions_vocab,
557        required = False,
558        readonly = False,
559        )
560
561    end_session = schema.Choice(
562        title = _(u'End Session'),
563        source = academic_sessions_vocab,
564        required = False,
565        readonly = False,
566        )
567
568    course_studied = schema.Choice(
569        title = _(u'Course of Study / Degree'),
570        source = CertificateSource(),
571        required = False,
572        readonly = False,
573        )
574
575    purpose = schema.TextLine(
576        title = _(u'Purpose of this Application'),
577        readonly = False,
578        required = False,
579        )
580
581    course_changed = schema.Choice(
582        title = _(u'Change of Study Course'),
583        description = u'If yes, select previous course of study.',
584        source = CertificateSource(),
585        readonly = False,
586        required = False,
587        )
588
589    change_level = schema.Choice(
590        title = _(u'Change Level'),
591        description = u'If yes, select level at which you changed course of study.',
592        source = StudyLevelSource(),
593        required = False,
594        readonly = False,
595        )
596
597
598class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant,
599                       ITranscriptApplicant):
600    """An interface for all three types of applicants.
601
602    Attention: The ICustomPGApplicant field seetings will be overwritten
603    by ICustomPGApplicant field settings. If a field is defined
604    in both interfaces zope.schema validates only against the
605    constraints in ICustomUGApplicant. This does not affect the forms
606    since they are build on either ICustomUGApplicant or ICustomPGApplicant.
607    """
608
609    def writeLogMessage(view, comment):
610        """Adds an INFO message to the log file
611        """
612
613    def createStudent():
614        """Create a student object from applicatnt data
615        and copy applicant object.
616        """
617
618class ICustomUGApplicantEdit(ICustomUGApplicant):
619    """An undergraduate applicant interface for edit forms.
620
621    Here we can repeat the fields from base data and set the
622    `required` and `readonly` attributes to True to further restrict
623    the data access. Or we can allow only certain certificates to be
624    selected by choosing the appropriate source.
625
626    We cannot omit fields here. This has to be done in the
627    respective form page.
628    """
629
630    programme_type = schema.Choice(
631        title = _(u'Programme Type'),
632        vocabulary = programme_types_vocab,
633        required = True,
634        )
635
636    date_of_birth = FormattedDate(
637        title = _(u'Date of Birth'),
638        required = True,
639        show_year = True,
640        )
641
642ICustomUGApplicantEdit['programme_type'].order = ICustomUGApplicant[
643    'programme_type'].order
644ICustomUGApplicantEdit['date_of_birth'].order = ICustomUGApplicant[
645    'date_of_birth'].order
646
647class ICustomPGApplicantEdit(INigeriaPGApplicantEdit):
648    """A postgraduate applicant interface for editing.
649
650    Here we can repeat the fields from base data and set the
651    `required` and `readonly` attributes to True to further restrict
652    the data access. Or we can allow only certain certificates to be
653    selected by choosing the appropriate source.
654
655    We cannot omit fields here. This has to be done in the
656    respective form page.
657    """
658
659class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment):
660    """An applicant payment via payment gateways.
661
662    """
663
664class IPUTMEApplicantEdit(IPUTMEApplicantEdit):
665    """An undergraduate applicant interface for editing.
666
667    Here we can repeat the fields from base data and set the
668    `required` and `readonly` attributes to True to further restrict
669    the data access. Or we can allow only certain certificates to be
670    selected by choosing the appropriate source.
671
672    We cannot omit fields here. This has to be done in the
673    respective form page.
674    """
675
676class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo):
677    """Representation of an applicant.
678
679    Skip regular reg_number validation if reg_number is used for finding
680    the applicant object.
681    """
682
683
684
Note: See TracBrowser for help on using the repository browser.