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

Last change on this file since 14472 was 14472, checked in by Henrik Bettermann, 8 years ago

Do not allow to edit the registration number.

Add matric_number field.

  • Property svn:keywords set to Id
File size: 22.1 KB
RevLine 
[7853]1## $Id: interfaces.py 14472 2017-01-27 15:50:38Z 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
[8012]21from zope import schema
[10298]22from zope.interface import Attribute, invariant, Invalid
[8051]23from waeup.kofa.applicants.interfaces import (
[8053]24    IApplicantBaseData,
[8051]25    AppCatCertificateSource, CertificateSource)
26from waeup.kofa.schoolgrades import ResultEntryField
[8532]27from waeup.kofa.interfaces import (
28    SimpleKofaVocabulary, academic_sessions_vocab, validate_email)
[13544]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)
[10298]33from waeup.kofa.applicants.interfaces import (
34    contextual_reg_num_source,
35    IApplicantBaseData)
[13544]36from waeup.kofa.university.vocabularies import StudyModeSource
[8931]37from kofacustom.nigeria.applicants.interfaces import (
38    LGASource, high_qual, high_grade, exam_types,
39    INigeriaUGApplicant, INigeriaPGApplicant,
40    INigeriaApplicantOnlinePayment,
[8980]41    INigeriaUGApplicantEdit, INigeriaPGApplicantEdit,
42    INigeriaApplicantUpdateByRegNo,
43    IPUTMEApplicantEdit,
[8931]44    )
[8444]45from waeup.aaue.interfaces import MessageFactory as _
46from waeup.aaue.payments.interfaces import ICustomOnlinePayment
[7853]47
[10924]48programme_types_vocab = SimpleKofaVocabulary(
[11542]49    (_('Undergraduate Programme (100 level)'), 'regular'),
50    (_('Direct Entry (200 level)'), 'direct'),
[10924]51    (_('not applicable'), 'na'),
52    )
53
[10298]54class ICustomUGApplicant(IApplicantBaseData):
[8012]55    """An undergraduate applicant.
56
[8521]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.
[8012]60    """
61
[13977]62    #programme_type = schema.Choice(
63    #    title = _(u'Programme Type'),
64    #    vocabulary = programme_types_vocab,
65    #    required = False,
66    #    )
[10924]67
[10298]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        )
[10308]82    home_town = schema.TextLine(
[10306]83        title = _(u'Home Town'),
84        required = False,
85        )
[13977]86    #jamb_reg_number = schema.TextLine(
87    #    title = _(u'JAMB Registration Number'),
88    #    required = False,
89    #    )
[10311]90    jamb_score = schema.Int(
91        title = _(u'Total JAMB Score'),
92        required = False,
93        )
[13977]94    jamb_subjects = schema.Text(
95        title = _(u'JAMB Subjects and Scores'),
96        required = False,
97        )
[10298]98    course1 = schema.Choice(
99        title = _(u'1st Choice Course of Study'),
100        source = AppCatCertificateSource(),
[14468]101        required = False,
[10298]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,
[14017]135        defaultFactory=list,
[10298]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,
[14017]164        defaultFactory=list,
[10298]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,
[14017]187        defaultFactory=list,
[10298]188        )
[10998]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        )
[13545]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        )
[13679]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
[10298]408    notice = schema.Text(
409        title = _(u'Notice'),
410        required = False,
411        )
[13977]412
413
414    master_sheet_number = schema.TextLine(
415        title = _(u'Master Sheet Number'),
416        required = False,
417        readonly = False,
418        )
419
[13996]420    screening_venue = schema.TextLine(
421        title = _(u'Screening Venue'),
422        required = False,
423        )
424    screening_date = schema.TextLine(
425        title = _(u'Screening Date'),
426        required = False,
427        )
428    screening_score = schema.Int(
[14028]429        title = _(u'Screening Points'),
[13996]430        required = False,
431        )
[10309]432    #aggregate = schema.Int(
433    #    title = _(u'Aggregate Score (%)'),
434    #    description = _(u'(average of relative JAMB and PUTME scores)'),
435    #    required = False,
436    #    )
[10298]437    result_uploaded = schema.Bool(
438        title = _(u'Result uploaded'),
439        default = False,
440        )
441    student_id = schema.TextLine(
442        title = _(u'Student Id'),
443        required = False,
444        readonly = False,
445        )
446    course_admitted = schema.Choice(
447        title = _(u'Admitted Course of Study'),
448        source = CertificateSource(),
449        required = False,
450        )
451    locked = schema.Bool(
452        title = _(u'Form locked'),
453        default = False,
454        )
455
456    @invariant
457    def second_choice(applicant):
458        if applicant.course1 == applicant.course2:
459            raise Invalid(_("2nd choice course must differ from 1st choice course."))
460
[13977]461#ICustomUGApplicant['programme_type'].order = IApplicantBaseData[
462#    'reg_number'].order
[10924]463
[8931]464class ICustomPGApplicant(INigeriaPGApplicant):
[7853]465    """A postgraduate applicant.
466
[8521]467    This interface defines the least common multiple of all fields
468    in pg application forms. In customized forms, fields can be excluded by
469    adding them to the PG_OMIT* tuples.
[7866]470    """
471
[13544]472class ITranscriptApplicant(IKofaObject):
473    """A transcript applicant.
474    """
[8012]475
[13544]476    suspended = schema.Bool(
477        title = _(u'Account suspended'),
478        default = False,
479        required = False,
480        )
481
482    locked = schema.Bool(
483        title = _(u'Form locked'),
484        default = False,
485        required = False,
486        )
487
488    applicant_id = schema.TextLine(
489        title = _(u'Applicant Id'),
490        required = False,
491        readonly = False,
492        )
493
[14472]494    reg_number = TextLineChoice(
495        title = _(u'Registration Number'),
496        readonly = False,
497        required = True,
498        source = contextual_reg_num_source,
499        )
500
[13544]501    firstname = schema.TextLine(
502        title = _(u'First Name'),
503        required = True,
504        )
505
506    middlename = schema.TextLine(
507        title = _(u'Middle Name'),
508        required = False,
509        )
510
511    lastname = schema.TextLine(
512        title = _(u'Last Name (Surname)'),
513        required = True,
514        )
515
[14472]516    matric_number = schema.TextLine(
517        title = _(u'Matriculation Number'),
[13544]518        readonly = False,
[14472]519        required = False,
[13544]520        )
521
522    date_of_birth = FormattedDate(
523        title = _(u'Date of Birth'),
524        required = False,
525        #date_format = u'%d/%m/%Y', # Use grok-instance-wide default
526        show_year = True,
527        )
528
529    place_of_birth = schema.TextLine(
530        title = _(u'Place of Birth'),
531        readonly = False,
532        required = False,
533        )
534
535    nationality = schema.Choice(
536        vocabulary = nats_vocab,
537        title = _(u'Nationality'),
538        required = False,
539        )
540
541    email = schema.ASCIILine(
542        title = _(u'Email Address'),
543        required = True,
544        constraint=validate_email,
545        )
546
547    phone = PhoneNumber(
548        title = _(u'Phone'),
549        description = u'',
550        required = False,
551        )
552
553    perm_address = schema.Text(
554        title = _(u'Current Local Address'),
555        required = False,
556        readonly = False,
557        )
558
559    dispatch_address = schema.Text(
[14306]560        title = _(u'Dispatch Addresses'),
561        description = u'Addresses to which transcript should be posted.',
[13544]562        required = False,
563        readonly = False,
564        )
565
566    entry_mode = schema.Choice(
567        title = _(u'Entry Mode'),
568        source = StudyModeSource(),
569        required = False,
570        readonly = False,
571        )
572
573    entry_session = schema.Choice(
574        title = _(u'Entry Session'),
575        source = academic_sessions_vocab,
576        required = False,
577        readonly = False,
578        )
579
580    end_session = schema.Choice(
581        title = _(u'End Session'),
582        source = academic_sessions_vocab,
583        required = False,
584        readonly = False,
585        )
586
587    course_studied = schema.Choice(
588        title = _(u'Course of Study / Degree'),
589        source = CertificateSource(),
590        required = False,
591        readonly = False,
592        )
593
594    purpose = schema.TextLine(
595        title = _(u'Purpose of this Application'),
596        readonly = False,
597        required = False,
598        )
599
600    course_changed = schema.Choice(
601        title = _(u'Change of Study Course'),
602        description = u'If yes, select previous course of study.',
603        source = CertificateSource(),
604        readonly = False,
605        required = False,
606        )
607
608    change_level = schema.Choice(
609        title = _(u'Change Level'),
610        description = u'If yes, select level at which you changed course of study.',
611        source = StudyLevelSource(),
612        required = False,
613        readonly = False,
614        )
615
[14306]616    no_copies = schema.Choice(
617        title = _(u'Number of Copies'),
618        description = u'Must correspond with the number of dispatch addresses above.',
619        values=[1, 2, 3, 4],
620        required = False,
621        readonly = False,
622        default = 1,
623        )
624
[14304]625class ICertificateRequest(IKofaObject):
626    """A transcript applicant.
627    """
[13544]628
[14304]629    suspended = schema.Bool(
630        title = _(u'Account suspended'),
631        default = False,
632        required = False,
633        )
634
635    locked = schema.Bool(
636        title = _(u'Form locked'),
637        default = False,
638        required = False,
639        )
640
641    applicant_id = schema.TextLine(
642        title = _(u'Applicant Id'),
643        required = False,
644        readonly = False,
645        )
646
[14472]647    reg_number = TextLineChoice(
648        title = _(u'Registration Number'),
649        readonly = False,
650        required = True,
651        source = contextual_reg_num_source,
652        )
653
[14304]654    firstname = schema.TextLine(
655        title = _(u'First Name'),
656        required = True,
657        )
658
659    middlename = schema.TextLine(
660        title = _(u'Middle Name'),
661        required = False,
662        )
663
664    lastname = schema.TextLine(
665        title = _(u'Last Name (Surname)'),
666        required = True,
667        )
668
[14472]669    matric_number = schema.TextLine(
670        title = _(u'Matriculation Number'),
[14304]671        readonly = False,
[14472]672        required = False,
[14304]673        )
674
675    date_of_birth = FormattedDate(
676        title = _(u'Date of Birth'),
677        required = False,
678        #date_format = u'%d/%m/%Y', # Use grok-instance-wide default
679        show_year = True,
680        )
681
682    place_of_birth = schema.TextLine(
683        title = _(u'Place of Birth'),
684        readonly = False,
685        required = False,
686        )
687
688    nationality = schema.Choice(
689        vocabulary = nats_vocab,
690        title = _(u'Nationality'),
691        required = False,
692        )
693
694    email = schema.ASCIILine(
695        title = _(u'Email Address'),
696        required = True,
697        constraint=validate_email,
698        )
699
700    phone = PhoneNumber(
701        title = _(u'Phone'),
702        description = u'',
703        required = False,
704        )
705
706    perm_address = schema.Text(
707        title = _(u'Current Local Address'),
708        required = False,
709        readonly = False,
710        )
711
712    dispatch_address = schema.Text(
[14306]713        title = _(u'Dispatch Addresses'),
714        description = u'Addresses to which certificate should be posted.',
[14304]715        required = False,
716        readonly = False,
717        )
718
719    entry_session = schema.Choice(
720        title = _(u'Entry Session'),
721        source = academic_sessions_vocab,
722        required = False,
723        readonly = False,
724        )
725
726    end_session = schema.Choice(
727        title = _(u'End Session'),
728        source = academic_sessions_vocab,
729        required = False,
730        readonly = False,
731        )
732
733    course_studied = schema.Choice(
734        title = _(u'Course of Study / Degree'),
735        source = CertificateSource(),
736        required = False,
737        readonly = False,
738        )
739
[14306]740    no_copies = schema.Choice(
741        title = _(u'Number of Copies'),
742        description = u'Must correspond with the number of dispatch addresses above.',
743        values=[1, 2, 3, 4],
744        required = False,
745        readonly = False,
746        default = 1,
747        )
748
[13544]749class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant,
[14304]750                       ITranscriptApplicant, ICertificateRequest):
[14471]751    """An interface for all types of applicants.
[13544]752
[8931]753    Attention: The ICustomPGApplicant field seetings will be overwritten
754    by ICustomPGApplicant field settings. If a field is defined
[8728]755    in both interfaces zope.schema validates only against the
[8931]756    constraints in ICustomUGApplicant. This does not affect the forms
757    since they are build on either ICustomUGApplicant or ICustomPGApplicant.
[8012]758    """
759
[8746]760    def writeLogMessage(view, comment):
[8053]761        """Adds an INFO message to the log file
762        """
763
764    def createStudent():
765        """Create a student object from applicatnt data
766        and copy applicant object.
767        """
768
[10298]769class ICustomUGApplicantEdit(ICustomUGApplicant):
[8728]770    """An undergraduate applicant interface for edit forms.
[8012]771
772    Here we can repeat the fields from base data and set the
773    `required` and `readonly` attributes to True to further restrict
774    the data access. Or we can allow only certain certificates to be
775    selected by choosing the appropriate source.
776
777    We cannot omit fields here. This has to be done in the
778    respective form page.
779    """
780
[13977]781    #programme_type = schema.Choice(
782    #    title = _(u'Programme Type'),
783    #    vocabulary = programme_types_vocab,
784    #    required = True,
785    #    )
[13548]786
[10924]787    date_of_birth = FormattedDate(
788        title = _(u'Date of Birth'),
789        required = True,
790        show_year = True,
791        )
792
[13977]793#ICustomUGApplicantEdit['programme_type'].order = ICustomUGApplicant[
794#    'programme_type'].order
[10924]795ICustomUGApplicantEdit['date_of_birth'].order = ICustomUGApplicant[
796    'date_of_birth'].order
797
[8980]798class ICustomPGApplicantEdit(INigeriaPGApplicantEdit):
[7866]799    """A postgraduate applicant interface for editing.
800
801    Here we can repeat the fields from base data and set the
802    `required` and `readonly` attributes to True to further restrict
803    the data access. Or we can allow only certain certificates to be
804    selected by choosing the appropriate source.
805
806    We cannot omit fields here. This has to be done in the
807    respective form page.
[8017]808    """
[8455]809
[8931]810class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment):
[8247]811    """An applicant payment via payment gateways.
812
813    """
[8532]814
[8980]815class IPUTMEApplicantEdit(IPUTMEApplicantEdit):
[8532]816    """An undergraduate applicant interface for editing.
817
818    Here we can repeat the fields from base data and set the
819    `required` and `readonly` attributes to True to further restrict
820    the data access. Or we can allow only certain certificates to be
821    selected by choosing the appropriate source.
822
823    We cannot omit fields here. This has to be done in the
824    respective form page.
825    """
826
[14471]827class ICustomApplicantUpdateByRegNo(ICustomApplicant):
[8583]828    """Representation of an applicant.
829
830    Skip regular reg_number validation if reg_number is used for finding
831    the applicant object.
832    """
[8980]833
[14471]834    reg_number = schema.TextLine(
835        title = u'Registration Number',
836        required = False,
837        )
[13544]838
839
[14471]840
841
Note: See TracBrowser for help on using the repository browser.