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

Last change on this file since 15100 was 15099, checked in by Henrik Bettermann, 6 years ago

Remove some fields from certificate application form.

Remove passport picture requirement.

  • Property svn:keywords set to Id
File size: 23.3 KB
Line 
1## $Id: interfaces.py 15099 2018-08-06 06:48:42Z 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
74    lga = schema.Choice(
75        source = LGASource(),
76        title = _(u'State/LGA (Nigerians only)'),
77        required = False,
78        )
79
80    perm_address = schema.Text(
81        title = _(u'Permanent Address'),
82        required = False,
83        )
84
85    home_town = schema.TextLine(
86        title = _(u'Home Town'),
87        required = False,
88        )
89
90    #jamb_reg_number = schema.TextLine(
91    #    title = _(u'JAMB Registration Number'),
92    #    required = False,
93    #    )
94
95    jamb_score = schema.Int(
96        title = _(u'Total JAMB Score'),
97        required = False,
98        )
99
100    jamb_subjects = schema.Text(
101        title = _(u'JAMB Subjects and Scores'),
102        required = False,
103        )
104
105    course1 = schema.Choice(
106        title = _(u'1st Choice Course of Study'),
107        source = AppCatCertificateSource(),
108        required = False,
109        )
110
111    course2 = schema.Choice(
112        title = _(u'2nd Choice Course of Study'),
113        source = AppCatCertificateSource(),
114        required = False,
115        )
116
117    fst_sit_fname = schema.TextLine(
118        title = _(u'Full Name'),
119        required = False,
120        readonly = False,
121        )
122
123    fst_sit_no = schema.TextLine(
124        title = _(u'Exam Number'),
125        required = False,
126        readonly = False,
127        )
128
129    fst_sit_sc_pin = schema.TextLine(
130        title = _(u'Scratch Card Pin'),
131        required = False,
132        readonly = False,
133        )
134
135    fst_sit_sc_serial_number = schema.TextLine(
136        title = _(u'Scratch Card Serial Number'),
137        required = False,
138        readonly = False,
139        )
140
141    fst_sit_date = FormattedDate(
142        title = _(u'Exam Date'),
143        required = False,
144        readonly = False,
145        show_year = True,
146        )
147
148    fst_sit_type = schema.Choice(
149        title = _(u'Exam Type'),
150        required = False,
151        readonly = False,
152        vocabulary = exam_types,
153        )
154
155    fst_sit_results = schema.List(
156        title = _(u'Exam Results'),
157        value_type = ResultEntryField(),
158        required = False,
159        readonly = False,
160        defaultFactory=list,
161        )
162
163    scd_sit_fname = schema.TextLine(
164        title = _(u'Full Name'),
165        required = False,
166        readonly = False,
167        )
168
169    scd_sit_no = schema.TextLine(
170        title = _(u'Exam Number'),
171        required = False,
172        readonly = False,
173        )
174
175    scd_sit_sc_pin = schema.TextLine(
176        title = _(u'Scratch Card Pin'),
177        required = False,
178        readonly = False,
179        )
180
181    scd_sit_sc_serial_number = schema.TextLine(
182        title = _(u'Scratch Card Serial Number'),
183        required = False,
184        readonly = False,
185        )
186
187    scd_sit_date = FormattedDate(
188        title = _(u'Exam Date'),
189        required = False,
190        readonly = False,
191        show_year = True,
192        )
193
194    scd_sit_type = schema.Choice(
195        title = _(u'Exam Type'),
196        required = False,
197        readonly = False,
198        vocabulary = exam_types,
199        )
200
201    scd_sit_results = schema.List(
202        title = _(u'Exam Results'),
203        value_type = ResultEntryField(),
204        required = False,
205        readonly = False,
206        defaultFactory=list,
207        )
208
209    alr_fname = schema.TextLine(
210        title = _(u'Full Name'),
211        required = False,
212        readonly = False,
213        )
214
215    alr_no = schema.TextLine(
216        title = _(u'Exam Number'),
217        required = False,
218        readonly = False,
219        )
220
221    alr_date = FormattedDate(
222        title = _(u'Exam Date'),
223        required = False,
224        readonly = False,
225        show_year = True,
226        )
227
228    alr_results = schema.List(
229        title = _(u'Exam Results'),
230        value_type = ResultEntryField(),
231        required = False,
232        readonly = False,
233        defaultFactory=list,
234        )
235
236    hq_type = schema.Choice(
237        title = _(u'Qualification Obtained'),
238        required = False,
239        readonly = False,
240        vocabulary = high_qual,
241        )
242
243    hq_fname = schema.TextLine(
244        title = _(u'Full Name'),
245        required = False,
246        readonly = False,
247        )
248
249    hq_matric_no = schema.TextLine(
250        title = _(u'Former Matric Number'),
251        required = False,
252        readonly = False,
253        )
254
255    hq_degree = schema.Choice(
256        title = _(u'Class of Degree'),
257        required = False,
258        readonly = False,
259        vocabulary = high_grade,
260        )
261
262    hq_school = schema.TextLine(
263        title = _(u'Institution Attended'),
264        required = False,
265        readonly = False,
266        )
267
268    hq_session = schema.TextLine(
269        title = _(u'Years Attended'),
270        required = False,
271        readonly = False,
272        )
273
274    hq_disc = schema.TextLine(
275        title = _(u'Discipline'),
276        required = False,
277        readonly = False,
278        )
279
280    hq_type2 = schema.Choice(
281        title = _(u'Qualification Obtained'),
282        required = False,
283        readonly = False,
284        vocabulary = high_qual,
285        )
286
287    hq_fname2 = schema.TextLine(
288        title = _(u'Full Name'),
289        required = False,
290        readonly = False,
291        )
292
293    hq_matric_no2 = schema.TextLine(
294        title = _(u'Former Matric Number'),
295        required = False,
296        readonly = False,
297        )
298
299    hq_degree2 = schema.Choice(
300        title = _(u'Class of Degree'),
301        required = False,
302        readonly = False,
303        vocabulary = high_grade,
304        )
305
306    hq_school2 = schema.TextLine(
307        title = _(u'Institution Attended'),
308        required = False,
309        readonly = False,
310        )
311
312    hq_session2 = schema.TextLine(
313        title = _(u'Years Attended'),
314        required = False,
315        readonly = False,
316        )
317
318    hq_disc2 = schema.TextLine(
319        title = _(u'Discipline'),
320        required = False,
321        readonly = False,
322        )
323
324    hq_type3 = schema.Choice(
325        title = _(u'Qualification Obtained'),
326        required = False,
327        readonly = False,
328        vocabulary = high_qual,
329        )
330
331    hq_fname3 = schema.TextLine(
332        title = _(u'Full Name'),
333        required = False,
334        readonly = False,
335        )
336
337    hq_matric_no3 = schema.TextLine(
338        title = _(u'Former Matric Number'),
339        required = False,
340        readonly = False,
341        )
342
343    hq_degree3 = schema.Choice(
344        title = _(u'Class of Degree'),
345        required = False,
346        readonly = False,
347        vocabulary = high_grade,
348        )
349
350    hq_school3 = schema.TextLine(
351        title = _(u'Institution Attended'),
352        required = False,
353        readonly = False,
354        )
355
356    hq_session3 = schema.TextLine(
357        title = _(u'Years Attended'),
358        required = False,
359        readonly = False,
360        )
361
362    hq_disc3 = schema.TextLine(
363        title = _(u'Discipline'),
364        required = False,
365        readonly = False,
366        )
367
368    nysc_year = schema.Int(
369        title = _(u'Nysc Year'),
370        required = False,
371        readonly = False,
372        )
373
374    nysc_location = schema.TextLine(
375        title = _(u'Nysc Location'),
376        required = False,
377        )
378
379    nysc_lga = schema.Choice(
380        source = LGASource(),
381        title = _(u'Nysc LGA'),
382        required = False,
383        )
384
385    employer = schema.TextLine(
386        title = _(u'Employer'),
387        required = False,
388        readonly = False,
389        )
390
391    emp_position = schema.TextLine(
392        title = _(u'Employer Position'),
393        required = False,
394        readonly = False,
395        )
396
397    emp_start = FormattedDate(
398        title = _(u'Start Date'),
399        required = False,
400        readonly = False,
401        show_year = True,
402        )
403
404    emp_end = FormattedDate(
405        title = _(u'End Date'),
406        required = False,
407        readonly = False,
408        show_year = True,
409        )
410
411    emp_reason = schema.TextLine(
412        title = _(u'Reason for Leaving'),
413        required = False,
414        readonly = False,
415        )
416
417    employer2 = schema.TextLine(
418        title = _(u'2nd Employer'),
419        required = False,
420        readonly = False,
421        )
422
423    emp2_position = schema.TextLine(
424        title = _(u'2nd Employer Position'),
425        required = False,
426        readonly = False,
427        )
428
429    emp2_start = FormattedDate(
430        title = _(u'Start Date'),
431        required = False,
432        readonly = False,
433        show_year = True,
434        )
435
436    emp2_end = FormattedDate(
437        title = _(u'End Date'),
438        required = False,
439        readonly = False,
440        show_year = True,
441        )
442
443    emp2_reason = schema.TextLine(
444        title = _(u'Reason for Leaving'),
445        required = False,
446        readonly = False,
447        )
448
449    former_matric = schema.TextLine(
450        title = _(u'If yes, matric number'),
451        required = False,
452        readonly = False,
453        )
454
455    notice = schema.Text(
456        title = _(u'Notice'),
457        required = False,
458        )
459
460
461    master_sheet_number = schema.TextLine(
462        title = _(u'Master Sheet Number'),
463        required = False,
464        readonly = False,
465        )
466
467    screening_venue = schema.TextLine(
468        title = _(u'Screening Venue'),
469        required = False,
470        )
471
472    screening_date = schema.TextLine(
473        title = _(u'Screening Date'),
474        required = False,
475        )
476
477    screening_score = schema.Int(
478        title = _(u'Screening Points'),
479        required = False,
480        )
481
482    student_id = schema.TextLine(
483        title = _(u'Student Id'),
484        required = False,
485        readonly = False,
486        )
487
488    course_admitted = schema.Choice(
489        title = _(u'Admitted Course of Study'),
490        source = CertificateSource(),
491        required = False,
492        )
493
494    locked = schema.Bool(
495        title = _(u'Form locked'),
496        default = False,
497        )
498
499    @invariant
500    def second_choice(applicant):
501        if applicant.course1 == applicant.course2:
502            raise Invalid(_("2nd choice course must differ from 1st choice course."))
503
504#ICustomUGApplicant['programme_type'].order = IApplicantBaseData[
505#    'reg_number'].order
506
507class ICustomPGApplicant(INigeriaPGApplicant):
508    """A postgraduate applicant.
509
510    This interface defines the least common multiple of all fields
511    in pg application forms. In customized forms, fields can be excluded by
512    adding them to the PG_OMIT* tuples.
513    """
514
515class ITranscriptApplicant(IKofaObject):
516    """A transcript applicant.
517    """
518
519    suspended = schema.Bool(
520        title = _(u'Account suspended'),
521        default = False,
522        required = False,
523        )
524
525    locked = schema.Bool(
526        title = _(u'Form locked'),
527        default = False,
528        required = False,
529        )
530
531    applicant_id = schema.TextLine(
532        title = _(u'Applicant Id'),
533        required = False,
534        readonly = False,
535        )
536
537    reg_number = TextLineChoice(
538        title = _(u'Kofa Registration Number'),
539        readonly = False,
540        required = True,
541        source = contextual_reg_num_source,
542        )
543
544    firstname = schema.TextLine(
545        title = _(u'First Name'),
546        required = True,
547        )
548
549    middlename = schema.TextLine(
550        title = _(u'Middle Name'),
551        required = False,
552        )
553
554    lastname = schema.TextLine(
555        title = _(u'Last Name (Surname)'),
556        required = True,
557        )
558
559    matric_number = schema.TextLine(
560        title = _(u'Matriculation Number'),
561        readonly = False,
562        required = True,
563        )
564
565    date_of_birth = FormattedDate(
566        title = _(u'Date of Birth'),
567        required = False,
568        #date_format = u'%d/%m/%Y', # Use grok-instance-wide default
569        show_year = True,
570        )
571
572    place_of_birth = schema.TextLine(
573        title = _(u'Place of Birth'),
574        readonly = False,
575        required = False,
576        )
577
578    nationality = schema.Choice(
579        vocabulary = nats_vocab,
580        title = _(u'Nationality'),
581        required = False,
582        )
583
584    email = schema.ASCIILine(
585        title = _(u'Email Address'),
586        required = True,
587        constraint=validate_email,
588        )
589
590    phone = PhoneNumber(
591        title = _(u'Phone'),
592        description = u'',
593        required = False,
594        )
595
596    perm_address = schema.Text(
597        title = _(u'Current Local Address'),
598        required = False,
599        readonly = False,
600        )
601
602    dispatch_address = schema.Text(
603        title = _(u'Dispatch Addresses'),
604        description = u'Addresses to which transcript should be posted.',
605        required = False,
606        readonly = False,
607        )
608
609    entry_mode = schema.Choice(
610        title = _(u'Entry Mode'),
611        source = StudyModeSource(),
612        required = False,
613        readonly = False,
614        )
615
616    entry_session = schema.Choice(
617        title = _(u'Entry Session'),
618        source = academic_sessions_vocab,
619        required = False,
620        readonly = False,
621        )
622
623    end_session = schema.Choice(
624        title = _(u'End Session'),
625        source = academic_sessions_vocab,
626        required = False,
627        readonly = False,
628        )
629
630    course_studied = schema.Choice(
631        title = _(u'Course of Study / Degree'),
632        source = CertificateSource(),
633        required = False,
634        readonly = False,
635        )
636
637    purpose = schema.TextLine(
638        title = _(u'Purpose of this Application'),
639        readonly = False,
640        required = False,
641        )
642
643    course_changed = schema.Choice(
644        title = _(u'Change of Study Course'),
645        description = u'If yes, select previous course of study.',
646        source = CertificateSource(),
647        readonly = False,
648        required = False,
649        )
650
651    change_level = schema.Choice(
652        title = _(u'Change Level'),
653        description = u'If yes, select level at which you changed course of study.',
654        source = StudyLevelSource(),
655        required = False,
656        readonly = False,
657        )
658
659    no_copies = schema.Choice(
660        title = _(u'Number of Copies'),
661        description = u'Must correspond with the number of dispatch addresses above.',
662        values=[1, 2, 3, 4],
663        required = False,
664        readonly = False,
665        default = 1,
666        )
667
668class ICertificateRequest(IKofaObject):
669    """A transcript applicant.
670    """
671
672    suspended = schema.Bool(
673        title = _(u'Account suspended'),
674        default = False,
675        required = False,
676        )
677
678    locked = schema.Bool(
679        title = _(u'Form locked'),
680        default = False,
681        required = False,
682        )
683
684    applicant_id = schema.TextLine(
685        title = _(u'Applicant Id'),
686        required = False,
687        readonly = False,
688        )
689
690    reg_number = TextLineChoice(
691        title = _(u'Kofa Registration Number'),
692        readonly = False,
693        required = True,
694        source = contextual_reg_num_source,
695        )
696
697    firstname = schema.TextLine(
698        title = _(u'First Name'),
699        required = True,
700        )
701
702    middlename = schema.TextLine(
703        title = _(u'Middle Name'),
704        required = False,
705        )
706
707    lastname = schema.TextLine(
708        title = _(u'Last Name (Surname)'),
709        required = True,
710        )
711
712    matric_number = schema.TextLine(
713        title = _(u'Matriculation Number'),
714        readonly = False,
715        required = True,
716        )
717
718    date_of_birth = FormattedDate(
719        title = _(u'Date of Birth'),
720        required = False,
721        #date_format = u'%d/%m/%Y', # Use grok-instance-wide default
722        show_year = True,
723        )
724
725    place_of_birth = schema.TextLine(
726        title = _(u'Place of Birth'),
727        readonly = False,
728        required = False,
729        )
730
731    nationality = schema.Choice(
732        vocabulary = nats_vocab,
733        title = _(u'Nationality'),
734        required = False,
735        )
736
737    email = schema.ASCIILine(
738        title = _(u'Email Address'),
739        required = True,
740        constraint=validate_email,
741        )
742
743    phone = PhoneNumber(
744        title = _(u'Phone'),
745        description = u'',
746        required = False,
747        )
748
749    entry_session = schema.Choice(
750        title = _(u'Entry Session'),
751        source = academic_sessions_vocab,
752        required = False,
753        readonly = False,
754        )
755
756    end_session = schema.Choice(
757        title = _(u'End Session'),
758        source = academic_sessions_vocab,
759        required = False,
760        readonly = False,
761        )
762
763    course_studied = schema.Choice(
764        title = _(u'Course of Study / Degree'),
765        source = CertificateSource(),
766        required = True,
767        readonly = False,
768        )
769
770
771class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant,
772                       ITranscriptApplicant, ICertificateRequest):
773    """An interface for all types of applicants.
774
775    Attention: The ICustomPGApplicant field seetings will be overwritten
776    by ICustomPGApplicant field settings. If a field is defined
777    in both interfaces zope.schema validates only against the
778    constraints in ICustomUGApplicant. This does not affect the forms
779    since they are build on either ICustomUGApplicant or ICustomPGApplicant.
780    """
781
782    def writeLogMessage(view, comment):
783        """Adds an INFO message to the log file
784        """
785
786    def createStudent():
787        """Create a student object from applicatnt data
788        and copy applicant object.
789        """
790
791class ICustomUGApplicantEdit(ICustomUGApplicant):
792    """An undergraduate applicant interface for edit forms.
793
794    Here we can repeat the fields from base data and set the
795    `required` and `readonly` attributes to True to further restrict
796    the data access. Or we can allow only certain certificates to be
797    selected by choosing the appropriate source.
798
799    We cannot omit fields here. This has to be done in the
800    respective form page.
801    """
802
803    #programme_type = schema.Choice(
804    #    title = _(u'Programme Type'),
805    #    vocabulary = programme_types_vocab,
806    #    required = True,
807    #    )
808
809    date_of_birth = FormattedDate(
810        title = _(u'Date of Birth'),
811        required = True,
812        show_year = True,
813        )
814
815    fst_sit_fname = schema.TextLine(
816        title = _(u'Full Name'),
817        required = True,
818        readonly = False,
819        )
820
821    fst_sit_no = schema.TextLine(
822        title = _(u'Exam Number'),
823        required = True,
824        readonly = False,
825        )
826
827    fst_sit_sc_pin = schema.TextLine(
828        title = _(u'Scratch Card Pin'),
829        required = True,
830        readonly = False,
831        )
832
833    fst_sit_sc_serial_number = schema.TextLine(
834        title = _(u'Scratch Card Serial Number'),
835        required = True,
836        readonly = False,
837        )
838
839    fst_sit_date = FormattedDate(
840        title = _(u'Exam Date'),
841        required = True,
842        readonly = False,
843        show_year = True,
844        )
845
846    fst_sit_type = schema.Choice(
847        title = _(u'Exam Type'),
848        required = True,
849        readonly = False,
850        vocabulary = exam_types,
851        )
852
853#ICustomUGApplicantEdit['programme_type'].order = ICustomUGApplicant[
854#    'programme_type'].order
855ICustomUGApplicantEdit['date_of_birth'].order = ICustomUGApplicant[
856    'date_of_birth'].order
857ICustomUGApplicantEdit['fst_sit_fname'].order = ICustomUGApplicant[
858    'fst_sit_fname'].order
859ICustomUGApplicantEdit['fst_sit_no'].order = ICustomUGApplicant[
860    'fst_sit_no'].order
861ICustomUGApplicantEdit['fst_sit_sc_pin'].order = ICustomUGApplicant[
862    'fst_sit_sc_pin'].order
863ICustomUGApplicantEdit['fst_sit_sc_serial_number'].order = ICustomUGApplicant[
864    'fst_sit_sc_serial_number'].order
865ICustomUGApplicantEdit['fst_sit_date'].order = ICustomUGApplicant[
866    'fst_sit_date'].order
867ICustomUGApplicantEdit['fst_sit_type'].order = ICustomUGApplicant[
868    'fst_sit_type'].order
869
870class ICustomPGApplicantEdit(INigeriaPGApplicantEdit):
871    """A postgraduate applicant interface for editing.
872
873    Here we can repeat the fields from base data and set the
874    `required` and `readonly` attributes to True to further restrict
875    the data access. Or we can allow only certain certificates to be
876    selected by choosing the appropriate source.
877
878    We cannot omit fields here. This has to be done in the
879    respective form page.
880    """
881
882class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment):
883    """An applicant payment via payment gateways.
884
885    """
886
887class IPUTMEApplicantEdit(IPUTMEApplicantEdit):
888    """An undergraduate applicant interface for editing.
889
890    Here we can repeat the fields from base data and set the
891    `required` and `readonly` attributes to True to further restrict
892    the data access. Or we can allow only certain certificates to be
893    selected by choosing the appropriate source.
894
895    We cannot omit fields here. This has to be done in the
896    respective form page.
897    """
898
899class ICustomApplicantUpdateByRegNo(ICustomApplicant):
900    """Representation of an applicant.
901
902    Skip regular reg_number validation if reg_number is used for finding
903    the applicant object.
904    """
905
906    reg_number = schema.TextLine(
907        title = u'Registration Number',
908        required = False,
909        )
910
911
912
913
Note: See TracBrowser for help on using the repository browser.