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

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

Change label.

  • Property svn:keywords set to Id
File size: 18.6 KB
RevLine 
[7853]1## $Id: interfaces.py 14028 2016-07-13 04:36:56Z 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(),
101        required = True,
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
494    firstname = schema.TextLine(
495        title = _(u'First Name'),
496        required = True,
497        )
498
499    middlename = schema.TextLine(
500        title = _(u'Middle Name'),
501        required = False,
502        )
503
504    lastname = schema.TextLine(
505        title = _(u'Last Name (Surname)'),
506        required = True,
507        )
508
509    matric_number = schema.TextLine(
510        title = _(u'Matriculation Number'),
511        readonly = False,
[13549]512        required = False,
[13544]513        )
514
515    date_of_birth = FormattedDate(
516        title = _(u'Date of Birth'),
517        required = False,
518        #date_format = u'%d/%m/%Y', # Use grok-instance-wide default
519        show_year = True,
520        )
521
522    place_of_birth = schema.TextLine(
523        title = _(u'Place of Birth'),
524        readonly = False,
525        required = False,
526        )
527
528    nationality = schema.Choice(
529        vocabulary = nats_vocab,
530        title = _(u'Nationality'),
531        required = False,
532        )
533
534    email = schema.ASCIILine(
535        title = _(u'Email Address'),
536        required = True,
537        constraint=validate_email,
538        )
539
540    phone = PhoneNumber(
541        title = _(u'Phone'),
542        description = u'',
543        required = False,
544        )
545
546    perm_address = schema.Text(
547        title = _(u'Current Local Address'),
548        required = False,
549        readonly = False,
550        )
551
552    dispatch_address = schema.Text(
553        title = _(u'Dispatch Address'),
554        description = u'Address to which transcript should be posted.',
555        required = False,
556        readonly = False,
557        )
558
559    entry_mode = schema.Choice(
560        title = _(u'Entry Mode'),
561        source = StudyModeSource(),
562        required = False,
563        readonly = False,
564        )
565
566    entry_session = schema.Choice(
567        title = _(u'Entry Session'),
568        source = academic_sessions_vocab,
569        required = False,
570        readonly = False,
571        )
572
573    end_session = schema.Choice(
574        title = _(u'End Session'),
575        source = academic_sessions_vocab,
576        required = False,
577        readonly = False,
578        )
579
580    course_studied = schema.Choice(
581        title = _(u'Course of Study / Degree'),
582        source = CertificateSource(),
583        required = False,
584        readonly = False,
585        )
586
587    purpose = schema.TextLine(
588        title = _(u'Purpose of this Application'),
589        readonly = False,
590        required = False,
591        )
592
593    course_changed = schema.Choice(
594        title = _(u'Change of Study Course'),
595        description = u'If yes, select previous course of study.',
596        source = CertificateSource(),
597        readonly = False,
598        required = False,
599        )
600
601    change_level = schema.Choice(
602        title = _(u'Change Level'),
603        description = u'If yes, select level at which you changed course of study.',
604        source = StudyLevelSource(),
605        required = False,
606        readonly = False,
607        )
608
609
610class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant,
[13545]611                       ITranscriptApplicant):
[13544]612    """An interface for all three types of applicants.
613
[8931]614    Attention: The ICustomPGApplicant field seetings will be overwritten
615    by ICustomPGApplicant field settings. If a field is defined
[8728]616    in both interfaces zope.schema validates only against the
[8931]617    constraints in ICustomUGApplicant. This does not affect the forms
618    since they are build on either ICustomUGApplicant or ICustomPGApplicant.
[8012]619    """
620
[8746]621    def writeLogMessage(view, comment):
[8053]622        """Adds an INFO message to the log file
623        """
624
625    def createStudent():
626        """Create a student object from applicatnt data
627        and copy applicant object.
628        """
629
[10298]630class ICustomUGApplicantEdit(ICustomUGApplicant):
[8728]631    """An undergraduate applicant interface for edit forms.
[8012]632
633    Here we can repeat the fields from base data and set the
634    `required` and `readonly` attributes to True to further restrict
635    the data access. Or we can allow only certain certificates to be
636    selected by choosing the appropriate source.
637
638    We cannot omit fields here. This has to be done in the
639    respective form page.
640    """
641
[13977]642    #programme_type = schema.Choice(
643    #    title = _(u'Programme Type'),
644    #    vocabulary = programme_types_vocab,
645    #    required = True,
646    #    )
[13548]647
[10924]648    date_of_birth = FormattedDate(
649        title = _(u'Date of Birth'),
650        required = True,
651        show_year = True,
652        )
653
[13977]654#ICustomUGApplicantEdit['programme_type'].order = ICustomUGApplicant[
655#    'programme_type'].order
[10924]656ICustomUGApplicantEdit['date_of_birth'].order = ICustomUGApplicant[
657    'date_of_birth'].order
658
[8980]659class ICustomPGApplicantEdit(INigeriaPGApplicantEdit):
[7866]660    """A postgraduate applicant interface for editing.
661
662    Here we can repeat the fields from base data and set the
663    `required` and `readonly` attributes to True to further restrict
664    the data access. Or we can allow only certain certificates to be
665    selected by choosing the appropriate source.
666
667    We cannot omit fields here. This has to be done in the
668    respective form page.
[8017]669    """
[8455]670
[8931]671class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment):
[8247]672    """An applicant payment via payment gateways.
673
674    """
[8532]675
[8980]676class IPUTMEApplicantEdit(IPUTMEApplicantEdit):
[8532]677    """An undergraduate applicant interface for editing.
678
679    Here we can repeat the fields from base data and set the
680    `required` and `readonly` attributes to True to further restrict
681    the data access. Or we can allow only certain certificates to be
682    selected by choosing the appropriate source.
683
684    We cannot omit fields here. This has to be done in the
685    respective form page.
686    """
687
[8980]688class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo):
[8583]689    """Representation of an applicant.
690
691    Skip regular reg_number validation if reg_number is used for finding
692    the applicant object.
693    """
[8980]694
[13544]695
696
Note: See TracBrowser for help on using the repository browser.