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

Last change on this file since 14733 was 14666, checked in by Henrik Bettermann, 7 years ago

Remove result_uploaded field.

course_studied must not be required.

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