source: main/waeup.uniben/trunk/src/waeup/uniben/applicants/interfaces.py @ 18020

Last change on this file since 18020 was 18019, checked in by Henrik Bettermann, 7 days ago

Do not allow to select deprecated fees.

  • Property svn:keywords set to Id
File size: 29.2 KB
Line 
1# -*- coding: utf-8 -*-
2## $Id: interfaces.py 18019 2025-02-12 17:50:45Z henrik $
3##
4## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann
5## This program is free software; you can redistribute it and/or modify
6## it under the terms of the GNU General Public License as published by
7## the Free Software Foundation; either version 2 of the License, or
8## (at your option) any later version.
9##
10## This program is distributed in the hope that it will be useful,
11## but WITHOUT ANY WARRANTY; without even the implied warranty of
12## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13## GNU General Public License for more details.
14##
15## You should have received a copy of the GNU General Public License
16## along with this program; if not, write to the Free Software
17## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18##
19"""Customized interfaces of the university application package.
20"""
21
22#from grok import getSite
23import re
24from zope import schema
25from zope.interface import invariant, Invalid
26from zope.component import getUtility
27from zope.catalog.interfaces import ICatalog
28from zc.sourcefactory.basic import BasicSourceFactory
29from waeup.kofa.applicants.interfaces import (
30    IApplicantBaseData,
31    AppCatCertificateSource, CertificateSource)
32from waeup.kofa.university.vocabularies import StudyModeSource
33from waeup.kofa.students.vocabularies import (
34    nats_vocab, GenderSource, StudyLevelSource)
35from waeup.kofa.schoolgrades import ResultEntryField
36from waeup.kofa.interfaces import (
37    SimpleKofaVocabulary, academic_sessions_vocab, validate_email,
38    IKofaObject, ContextualDictSourceFactoryBase)
39from waeup.kofa.schema import FormattedDate, TextLineChoice, PhoneNumber
40from waeup.kofa.students.vocabularies import (
41    nats_vocab, GenderSource)
42from waeup.kofa.refereeentries import RefereeEntryField
43from waeup.kofa.applicants.interfaces import contextual_reg_num_source
44from kofacustom.nigeria.interfaces import DisabilitiesSource
45from kofacustom.nigeria.applicants.interfaces import (
46    LGASource, high_qual, high_grade, exam_types,
47    programme_types_vocab, jambsubjects,
48    INigeriaUGApplicant, INigeriaPGApplicant,
49    INigeriaApplicantOnlinePayment,
50    INigeriaUGApplicantEdit, INigeriaPGApplicantEdit,
51    INigeriaApplicantUpdateByRegNo,
52    IPUTMEApplicantEdit,
53    IBankAccount,
54    )
55from waeup.uniben.interfaces import MessageFactory as _
56from waeup.uniben.payments.interfaces import ICustomOnlinePayment
57
58
59# Define a validation method for JAMB reg numbers
60class NotMatricRegNumber(schema.ValidationError):
61    __doc__ = u"Invalid matriculation number"
62
63#: Regular expression to check matric_number formats.
64check_matric_number = re.compile(r"^[^0-9\s][^\s]*$").match
65
66def validate_matric_number(value):
67    if not check_matric_number(value):
68        raise NotMatricRegNumber(value)
69    return True
70
71class TranscriptCertificateSource(CertificateSource):
72    """Include Department and Faculty in Title.
73    """
74    def getValues(self, context):
75        catalog = getUtility(ICatalog, name='certificates_catalog')
76        resultset = catalog.searchResults(code=(None, None))
77        resultlist = sorted(resultset, key=lambda
78            value: value.__parent__.__parent__.__parent__.code +
79            value.__parent__.__parent__.code +
80            value.code)
81        return resultlist
82
83    def getTitle(self, context, value):
84        """
85        """
86        try: title = "%s / %s / %s (%s)" % (
87            value.__parent__.__parent__.__parent__.title,
88            value.__parent__.__parent__.title,
89            value.title, value.code)
90        except AttributeError:
91            title = "NA / %s (%s)" % (value.title, value.code)
92        return title
93
94REGISTRATION_CATS = {
95    'corporate': ('Corporate Registration', 250000, 1),
96    'group': ('Group Registration', 200000, 2),
97    'individual': ('Individual Registration', 45000, 3),
98    'student': ('Student Registration', 5000, 4),
99    'fullpage': ('Full Page Advert', 250000, 5),
100    'halfpage': ('Half Page Advert', 150000, 6),
101    'quarterpage': ('Quarter Page Advert', 100000, 7),
102    }
103
104class RegTypesSource(BasicSourceFactory):
105    """A source that delivers all kinds of registrations.
106    """
107    def getValues(self):
108        sorted_items = sorted(REGISTRATION_CATS.items(),
109                              key=lambda element: element[1][2])
110        return [item[0] for item in sorted_items]
111
112    def getTitle(self, value):
113        return u"%s @ ₦ %s" % (
114            REGISTRATION_CATS[value][0],
115            REGISTRATION_CATS[value][1])
116
117DESTINATION_COST = {
118    #'none': ('To the moon', 1000000000.0, 1),
119    'local': ('Within Nigeria', 27500.0, 1),
120    'inter2': ('International', 37500.0, 2),
121    'nigeria': ('Within Nigeria (deprecated)', 20000.0, 3),
122    'africa': ('Within Africa (deprecated)', 30000.0, 4),
123    'inter': ('International (deprecated)', 35000.0, 5),
124    'cert_nigeria': ('Certified Copy - Within Nigeria (deprecated)', 13000.0, 6),
125    'cert_africa': ('Certified Copy - Within Africa (deprecated)', 23000.0, 7),
126    'cert_inter': ('Certified Copy - International (deprecated)', 28000.0, 8),
127    }
128
129class DestinationCostSource(BasicSourceFactory):
130    """A source that delivers continents and shipment costs.
131    """
132    def getValues(self):
133        sorted_items = sorted(DESTINATION_COST.items(),
134                              key=lambda element: element[1][2])
135        return [item[0] for item in sorted_items]
136
137    def getToken(self, value):
138        return value
139
140    def getTitle(self, value):
141        return u"%s (₦ %s)" % (
142            DESTINATION_COST[value][0],
143            DESTINATION_COST[value][1])
144
145class OrderSource(BasicSourceFactory):
146    """
147    """
148    def getValues(self):
149        return ['o', 'c']
150
151    def getToken(self, value):
152        return value
153
154    def getTitle(self, value):
155        if value == 'o':
156            return _('Original')
157        if value == 'c':
158            return _('Certified True Copy')
159
160class ProficiencySource(BasicSourceFactory):
161    """
162    """
163    def getValues(self):
164        return ['n', 'c', 'p']
165
166    def getToken(self, value):
167        return value
168
169    def getTitle(self, value):
170        if value == 'n':
171            return _('none')
172        if value == 'c':
173            return _('conversational')
174        if value == 'p':
175            return _('professional')
176
177class PreferredSessionSource(BasicSourceFactory):
178    """
179    """
180    def getValues(self):
181        return ['m', 'e', 'w']
182
183    def getToken(self, value):
184        return value
185
186    def getTitle(self, value):
187        if value == 'm':
188            return _('morning')
189        if value == 'e':
190            return _('evening')
191        if value == 'w':
192            return _('weekend')
193
194class IUnibenRegistration(IKofaObject):
195    """A Uniben registrant.
196    """
197
198    suspended = schema.Bool(
199        title = _(u'Account suspended'),
200        default = False,
201        required = False,
202        )
203
204    locked = schema.Bool(
205        title = _(u'Form locked'),
206        default = False,
207        required = False,
208        )
209
210    applicant_id = schema.TextLine(
211        title = _(u'Registrant Id'),
212        required = False,
213        readonly = False,
214        )
215
216    firstname = schema.TextLine(
217        title = _(u'First Name'),
218        required = True,
219        )
220
221    middlename = schema.TextLine(
222        title = _(u'Middle Name'),
223        required = False,
224        )
225
226    lastname = schema.TextLine(
227        title = _(u'Last Name (Surname)'),
228        required = True,
229        )
230
231    sex = schema.Choice(
232        title = _(u'Sex'),
233        source = GenderSource(),
234        required = True,
235        )
236
237    nationality = schema.Choice(
238        vocabulary = nats_vocab,
239        title = _(u'Nationality'),
240        required = False,
241        )
242
243    email = schema.ASCIILine(
244        title = _(u'Email Address'),
245        required = True,
246        constraint=validate_email,
247        )
248
249    phone = PhoneNumber(
250        title = _(u'Phone'),
251        description = u'',
252        required = False,
253        )
254
255    #perm_address = schema.Text(
256    #    title = _(u'Current Local Address'),
257    #    required = False,
258    #    readonly = False,
259    #    )
260
261    institution = schema.TextLine(
262        title = _(u'Institution/Organisation'),
263        required = False,
264        readonly = False,
265        )
266
267    city = schema.TextLine(
268        title = _(u'City'),
269        required = False,
270        readonly = False,
271        )
272
273    lga = schema.Choice(
274        source = LGASource(),
275        title = _(u'State/LGA'),
276        required = False,
277        )
278
279    matric_number = schema.TextLine(
280        title = _(u'Uniben Matriculation Number'),
281        required = False,
282        readonly = False,
283        )
284
285    registration_cats = schema.List(
286        title = _(u'Registration Categories'),
287        value_type = schema.Choice(source=RegTypesSource()),
288        required = True,
289        defaultFactory=list,
290        )
291
292#    @invariant
293#    def matric_number_exists(applicant):
294#        if applicant.matric_number:
295#            catalog = getUtility(ICatalog, name='students_catalog')
296#            accommodation_session = getSite()['hostels'].accommodation_session
297#            student = catalog.searchResults(matric_number=(
298#                applicant.matric_number, applicant.matric_number))
299#            if len(student) != 1:
300#                raise Invalid(_("Matriculation number not found."))
301
302class ITranscriptApplicant(IKofaObject):
303    """A transcript applicant.
304    """
305
306    suspended = schema.Bool(
307        title = _(u'Account suspended'),
308        default = False,
309        required = False,
310        )
311
312    locked = schema.Bool(
313        title = _(u'Form locked'),
314        default = False,
315        required = False,
316        )
317
318    applicant_id = schema.TextLine(
319        title = _(u'Transcript Application Id'),
320        required = False,
321        readonly = False,
322        )
323
324    student_id = schema.TextLine(
325        title = _(u'Kofa Student Id'),
326        required = False,
327        readonly = False,
328        )
329
330    matric_number = schema.TextLine(
331        title = _(u'Matriculation Number'),
332        readonly = False,
333        required = True,
334        constraint = validate_matric_number,
335        )
336
337    firstname = schema.TextLine(
338        title = _(u'First Name in School'),
339        required = True,
340        )
341
342    middlename = schema.TextLine(
343        title = _(u'Middle Name in School'),
344        required = False,
345        )
346
347    lastname = schema.TextLine(
348        title = _(u'Surname in School'),
349        required = True,
350        )
351
352    date_of_birth = FormattedDate(
353        title = _(u'Date of Birth'),
354        required = False,
355        #date_format = u'%d/%m/%Y', # Use grok-instance-wide default
356        show_year = True,
357        )
358
359    sex = schema.Choice(
360        title = _(u'Gender'),
361        source = GenderSource(),
362        required = True,
363        )
364
365    #nationality = schema.Choice(
366    #    vocabulary = nats_vocab,
367    #    title = _(u'Nationality'),
368    #    required = False,
369    #    )
370
371    email = schema.ASCIILine(
372        title = _(u'Email Address'),
373        required = True,
374        constraint=validate_email,
375        )
376
377    phone = PhoneNumber(
378        title = _(u'Phone'),
379        description = u'',
380        required = False,
381        )
382
383    #perm_address = schema.Text(
384    #    title = _(u'Current Local Address'),
385    #    required = False,
386    #    readonly = False,
387    #    )
388
389    collected = schema.Bool(
390        title = _(u'Have you collected transcript before?'),
391        default = False,
392        required = False,
393        )
394
395    entry_session = schema.Choice(
396        title = _(u'Academic Session of Entry'),
397        source = academic_sessions_vocab,
398        required = False,
399        readonly = False,
400        )
401
402    end_session = schema.Choice(
403        title = _(u'Academic Session of Graduation'),
404        source = academic_sessions_vocab,
405        required = False,
406        readonly = False,
407        )
408
409    entry_mode = schema.Choice(
410        title = _(u'Mode of Entry'),
411        source = StudyModeSource(),
412        required = False,
413        readonly = False,
414        )
415
416    course_studied = schema.Choice(
417        title = _(u'Course of Study'),
418        source = TranscriptCertificateSource(),
419        description = u'Faculty / Department / Course',
420        required = True,
421        readonly = False,
422        )
423
424    course_changed = schema.Choice(
425        title = _(u'Change of Study Course / Transfer'),
426        description = u'If yes, select previous course of study.',
427        source = TranscriptCertificateSource(),
428        readonly = False,
429        required = False,
430        )
431
432    spillover_level = schema.Choice(
433        title = _(u'Spill-over'),
434        description = u'Any spill-over? If yes, select session of spill-over.',
435        source = academic_sessions_vocab,
436        required = False,
437        readonly = False,
438        )
439
440    purpose = schema.TextLine(
441        title = _(u'Transcript Purpose'),
442        required = False,
443        )
444
445    order = schema.Choice(
446        source = OrderSource(),
447        title = _(u'Type of Order'),
448        required = False,
449        )
450
451    dispatch_address = schema.Text(
452        title = _(u'Recipient Body'),
453        description = u'Addresses to which transcripts should be posted. '
454                       'All addresses must involve same courier charges.',
455        required = True,
456        readonly = False,
457        )
458
459    dispatch_email = schema.ASCIILine(
460        title = _(u'Recipient Email Address'),
461        required = False,
462        constraint=validate_email,
463        )
464
465    dispatch_phone = PhoneNumber(
466        title = _(u'Recipient Phone'),
467        description = u'',
468        required = False,
469        )
470
471    charge = schema.Choice(
472        title = _(u'Transcript Charge'),
473        source = DestinationCostSource(),
474        required = False,
475        readonly = False,
476        )
477
478    no_copies = schema.Choice(
479        title = _(u'Number of Copies'),
480        description = u'Must correspond with the number of dispatch addresses above.',
481        values=[1, 2, 3, 4],
482        required = False,
483        readonly = False,
484        default = 1,
485        )
486
487    courier_tno = schema.TextLine(
488        title = _(u'Courier Tracking Number'),
489        required = False,
490        )
491
492    proc_date = FormattedDate(
493        title = _(u'Processing Date'),
494        required = False,
495        #date_format = u'%d/%m/%Y', # Use grok-instance-wide default
496        show_year = True,
497        )
498
499    @invariant
500    def type_of_order(applicant):
501        if not applicant.collected and applicant.order != 'o':
502            raise Invalid(_("If you haven't collected transcript before, type of order must be 'original'."))
503        if applicant.order == 'o' and applicant.charge.startswith('cert_'):
504            raise Invalid(_("You've selected the wrong transcript charge."))
505        if applicant.order == 'c' and not applicant.charge.startswith('cert_'):
506            raise Invalid(_("You've selected the wrong transcript charge."))
507        if applicant.charge not in ('inter2', 'local'):
508            raise Invalid(_("This fee is deprecated. Please select a current transcript charge."))
509
510class IFrenchApplicant(IKofaObject):
511    """A transcript applicant.
512    """
513
514    suspended = schema.Bool(
515        title = _(u'Account suspended'),
516        default = False,
517        required = False,
518        )
519
520    locked = schema.Bool(
521        title = _(u'Form locked'),
522        default = False,
523        required = False,
524        )
525
526    applicant_id = schema.TextLine(
527        title = _(u'Applicant Id'),
528        required = False,
529        readonly = False,
530        )
531
532    firstname = schema.TextLine(
533        title = _(u'First Name'),
534        required = True,
535        )
536
537    middlename = schema.TextLine(
538        title = _(u'Middle Name'),
539        required = False,
540        )
541
542    lastname = schema.TextLine(
543        title = _(u'Surname'),
544        required = True,
545        )
546
547    date_of_birth = FormattedDate(
548        title = _(u'Date of Birth'),
549        required = False,
550        #date_format = u'%d/%m/%Y', # Use grok-instance-wide default
551        show_year = True,
552        )
553
554    sex = schema.Choice(
555        title = _(u'Gender'),
556        source = GenderSource(),
557        required = True,
558        )
559
560    nationality = schema.Choice(
561        vocabulary = nats_vocab,
562        title = _(u'Nationality'),
563        required = False,
564        )
565
566    email = schema.ASCIILine(
567        title = _(u'Email Address'),
568        required = True,
569        constraint=validate_email,
570        )
571
572    phone = PhoneNumber(
573        title = _(u'Phone'),
574        description = u'',
575        required = False,
576        )
577
578    work = schema.TextLine(
579        title = _(u'Place of Work'),
580        required = False,
581        )
582
583    hq_obtained = schema.Choice(
584        title = _(u'Highest Qualification Obtained'),
585        required = False,
586        readonly = False,
587        vocabulary = high_qual,
588        )
589
590    hq_date = FormattedDate(
591        title = _(u'Highest Qualification Date'),
592        required = False,
593        readonly = False,
594        show_year = True,
595        )
596
597    pref_session = schema.Choice(
598        source = PreferredSessionSource(),
599        title = _(u'Preferred Session'),
600        required = False,
601        )
602
603    proficiency = schema.Choice(
604        source = ProficiencySource(),
605        title = _(u'Level of Proficiency'),
606        required = False,
607        )
608
609    guarantor = schema.TextLine(
610        title = _(u'Name of Guarantor'),
611        required = False,
612        )
613
614    course_admitted = schema.Choice(
615        title = _(u'Admitted Course of Study'),
616        source = CertificateSource(),
617        required = False,
618        )
619
620class IAfrimalApplicant(IKofaObject):
621    """An AFRIMAL applicant.
622    """
623
624    suspended = schema.Bool(
625        title = _(u'Account suspended'),
626        default = False,
627        required = False,
628        )
629
630    locked = schema.Bool(
631        title = _(u'Form locked'),
632        default = False,
633        required = False,
634        )
635
636    applicant_id = schema.TextLine(
637        title = _(u'Applicant Id'),
638        required = False,
639        readonly = False,
640        )
641
642    firstname = schema.TextLine(
643        title = _(u'First Name'),
644        required = True,
645        )
646
647    middlename = schema.TextLine(
648        title = _(u'Middle Name'),
649        required = False,
650        )
651
652    lastname = schema.TextLine(
653        title = _(u'Surname'),
654        required = True,
655        )
656
657    date_of_birth = FormattedDate(
658        title = _(u'Date of Birth'),
659        required = False,
660        #date_format = u'%d/%m/%Y', # Use grok-instance-wide default
661        show_year = True,
662        )
663
664    sex = schema.Choice(
665        title = _(u'Gender'),
666        source = GenderSource(),
667        required = True,
668        )
669
670    nationality = schema.Choice(
671        vocabulary = nats_vocab,
672        title = _(u'Nationality'),
673        required = False,
674        )
675
676    email = schema.ASCIILine(
677        title = _(u'Email Address'),
678        required = True,
679        constraint=validate_email,
680        )
681
682    phone = PhoneNumber(
683        title = _(u'Phone'),
684        description = u'',
685        required = False,
686        )
687
688    hq_obtained = schema.Choice(
689        title = _(u'Highest Qualification Obtained'),
690        required = False,
691        readonly = False,
692        vocabulary = high_qual,
693        )
694
695    current_employer = schema.TextLine(
696        title = _(u'Current Employer'),
697        required = False,
698        )
699
700    course1 = schema.Choice(
701        title = _(u'Course of Study'),
702        source = AppCatCertificateSource(),
703        required = True,
704        )
705
706    course_admitted = schema.Choice(
707        title = _(u'Admitted Course of Study'),
708        source = CertificateSource(),
709        required = False,
710        )
711
712class ICustomUGApplicant(IApplicantBaseData, IBankAccount):
713    """An undergraduate applicant.
714
715    This interface defines the least common multiple of all fields
716    in ug application forms. In customized forms, fields can be excluded by
717    adding them to the UG_OMIT* tuples.
718    """
719
720    disabilities = schema.Choice(
721        title = _(u'Disabilities'),
722        source = DisabilitiesSource(),
723        required = False,
724        )
725    nationality = schema.Choice(
726        source = nats_vocab,
727        title = _(u'Nationality'),
728        required = False,
729        )
730    lga = schema.Choice(
731        source = LGASource(),
732        title = _(u'State/LGA (Nigerians only)'),
733        required = False,
734        )
735    #perm_address = schema.Text(
736    #    title = _(u'Permanent Address'),
737    #    required = False,
738    #    )
739    course1 = schema.Choice(
740        title = _(u'1st Choice Course of Study'),
741        source = AppCatCertificateSource(),
742        required = True,
743        )
744    course2 = schema.Choice(
745        title = _(u'2nd Choice Course of Study'),
746        source = AppCatCertificateSource(),
747        required = False,
748        )
749
750    programme_type = schema.Choice(
751        title = _(u'Programme Type'),
752        vocabulary = programme_types_vocab,
753        required = False,
754        )
755
756    hq_type = schema.Choice(
757        title = _(u'Qualification Obtained'),
758        required = False,
759        readonly = False,
760        vocabulary = high_qual,
761        )
762    hq_matric_no = schema.TextLine(
763        title = _(u'Former Matric Number'),
764        required = False,
765        readonly = False,
766        )
767    hq_degree = schema.Choice(
768        title = _(u'Class of Degree'),
769        required = False,
770        readonly = False,
771        vocabulary = high_grade,
772        )
773    hq_school = schema.TextLine(
774        title = _(u'Institution Attended'),
775        required = False,
776        readonly = False,
777        )
778    hq_session = schema.TextLine(
779        title = _(u'Years Attended'),
780        required = False,
781        readonly = False,
782        )
783    hq_disc = schema.TextLine(
784        title = _(u'Discipline'),
785        required = False,
786        readonly = False,
787        )
788    fst_sit_fname = schema.TextLine(
789        title = _(u'Full Name'),
790        required = False,
791        readonly = False,
792        )
793    fst_sit_no = schema.TextLine(
794        title = _(u'Exam Number'),
795        required = False,
796        readonly = False,
797        )
798    fst_sit_date = FormattedDate(
799        title = _(u'Exam Date'),
800        required = False,
801        readonly = False,
802        show_year = True,
803        )
804    fst_sit_type = schema.Choice(
805        title = _(u'Exam Type'),
806        required = False,
807        readonly = False,
808        vocabulary = exam_types,
809        )
810    fst_sit_results = schema.List(
811        title = _(u'Exam Results'),
812        value_type = ResultEntryField(),
813        required = False,
814        readonly = False,
815        defaultFactory=list,
816        )
817    scd_sit_fname = schema.TextLine(
818        title = _(u'Full Name'),
819        required = False,
820        readonly = False,
821        )
822    scd_sit_no = schema.TextLine(
823        title = _(u'Exam Number'),
824        required = False,
825        readonly = False,
826        )
827    scd_sit_date = FormattedDate(
828        title = _(u'Exam Date'),
829        required = False,
830        readonly = False,
831        show_year = True,
832        )
833    scd_sit_type = schema.Choice(
834        title = _(u'Exam Type'),
835        required = False,
836        readonly = False,
837        vocabulary = exam_types,
838        )
839    scd_sit_results = schema.List(
840        title = _(u'Exam Results'),
841        value_type = ResultEntryField(),
842        required = False,
843        readonly = False,
844        defaultFactory=list,
845        )
846    jamb_reg_number = schema.TextLine(
847        title = _(u'JAMB Registration Number'),
848        required = False,
849        )
850    jamb_subjects = schema.Text(
851        title = _(u'Subjects and Scores'),
852        required = False,
853        )
854    jamb_subjects_list = schema.List(
855        title = _(u'JAMB Subjects'),
856        required = False,
857        defaultFactory=list,
858        value_type = schema.Choice(
859            vocabulary = jambsubjects
860            #source = JAMBSubjectSource(),
861            ),
862        )
863    jamb_score = schema.Float(
864        title = _(u'Total JAMB Score'),
865        required = False,
866        )
867    #jamb_age = schema.Int(
868    #    title = _(u'Age (provided by JAMB)'),
869    #    required = False,
870    #    )
871    course_admitted = schema.Choice(
872        title = _(u'Admitted Course of Study'),
873        source = CertificateSource(),
874        required = False,
875        )
876    notice = schema.Text(
877        title = _(u'Notice'),
878        required = False,
879        )
880    screening_venue = schema.TextLine(
881        title = _(u'Screening Venue'),
882        required = False,
883        )
884    screening_date = schema.TextLine(
885        title = _(u'Screening Date'),
886        required = False,
887        )
888    screening_score = schema.Float(
889        title = _(u'Screening Score (%)'),
890        required = False,
891        )
892    aggregate = schema.Float(
893        title = _(u'Aggregate Score (%)'),
894        description = _(u'(average of relative JAMB and PUTME scores)'),
895        required = False,
896        )
897    result_uploaded = schema.Bool(
898        title = _(u'Result uploaded'),
899        default = False,
900        required = False,
901        )
902    student_id = schema.TextLine(
903        title = _(u'Student Id'),
904        required = False,
905        readonly = False,
906        )
907    locked = schema.Bool(
908        title = _(u'Form locked'),
909        default = False,
910        required = False,
911        )
912
913ICustomUGApplicant[
914    'locked'].order =  IApplicantBaseData['suspended'].order
915ICustomUGApplicant[
916    'result_uploaded'].order =  ICustomUGApplicant['suspended'].order
917
918class ICustomPGApplicant(INigeriaPGApplicant):
919    """A postgraduate applicant.
920
921    This interface defines the least common multiple of all fields
922    in pg application forms. In customized forms, fields can be excluded by
923    adding them to the PG_OMIT* tuples.
924    """
925
926    referees = schema.List(
927        title = _(u'Referees'),
928        value_type = RefereeEntryField(),
929        required = False,
930        defaultFactory=list,
931        )
932
933ICustomPGApplicant[
934    'referees'].order =  INigeriaPGApplicant['emp2_reason'].order
935
936class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant,
937    IUnibenRegistration, ITranscriptApplicant, IFrenchApplicant,
938    IAfrimalApplicant):
939    """An interface for both types of applicants.
940
941    Attention: The ICustomPGApplicant field seetings will be overwritten
942    by ICustomPGApplicant field settings. If a field is defined
943    in both interfaces zope.schema validates only against the
944    constraints in ICustomUGApplicant. This does not affect the forms
945    since they are build on either ICustomUGApplicant or ICustomPGApplicant.
946    """
947
948    def writeLogMessage(view, comment):
949        """Adds an INFO message to the log file
950        """
951
952    def createStudent():
953        """Create a student object from applicant data
954        and copy applicant object.
955        """
956
957class ICustomUGApplicantEdit(ICustomUGApplicant):
958    """An undergraduate applicant interface for edit forms.
959
960    Here we can repeat the fields from base data and set the
961    `required` and `readonly` attributes to True to further restrict
962    the data access. Or we can allow only certain certificates to be
963    selected by choosing the appropriate source.
964
965    We cannot omit fields here. This has to be done in the
966    respective form page.
967    """
968
969    email = schema.ASCIILine(
970        title = _(u'Email Address'),
971        required = True,
972        constraint=validate_email,
973        )
974    date_of_birth = FormattedDate(
975        title = _(u'Date of Birth'),
976        required = True,
977        show_year = True,
978        )
979
980ICustomUGApplicantEdit[
981    'date_of_birth'].order = ICustomUGApplicant['date_of_birth'].order
982ICustomUGApplicantEdit[
983    'email'].order = ICustomUGApplicant['email'].order
984
985class ICustomPGApplicantEdit(INigeriaPGApplicantEdit):
986    """A postgraduate applicant interface for editing.
987
988    Here we can repeat the fields from base data and set the
989    `required` and `readonly` attributes to True to further restrict
990    the data access. Or we can allow only certain certificates to be
991    selected by choosing the appropriate source.
992
993    We cannot omit fields here. This has to be done in the
994    respective form page.
995    """
996
997    referees = schema.List(
998        title = _(u'Referees'),
999        value_type = RefereeEntryField(),
1000        required = False,
1001        defaultFactory=list,
1002        )
1003
1004ICustomPGApplicantEdit[
1005    'referees'].order =  INigeriaPGApplicantEdit['emp2_reason'].order
1006
1007class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment):
1008    """An applicant payment via payment gateways.
1009
1010    """
1011
1012class IPUTMEApplicantEdit(ICustomUGApplicant):
1013    """An undergraduate applicant interface for editing.
1014
1015    Here we can repeat the fields from base data and set the
1016    `required` and `readonly` attributes to True to further restrict
1017    the data access. Or we can allow only certain certificates to be
1018    selected by choosing the appropriate source.
1019
1020    We cannot omit fields here. This has to be done in the
1021    respective form page.
1022    """
1023
1024    email = schema.ASCIILine(
1025        title = _(u'Email Address'),
1026        required = True,
1027        constraint=validate_email,
1028        )
1029    date_of_birth = FormattedDate(
1030        title = _(u'Date of Birth'),
1031        required = True,
1032        show_year = True,
1033        )
1034    nationality = schema.Choice(
1035        source = nats_vocab,
1036        title = _(u'Nationality'),
1037        required = True,
1038        )
1039
1040IPUTMEApplicantEdit[
1041    'date_of_birth'].order =  ICustomUGApplicant['date_of_birth'].order
1042IPUTMEApplicantEdit[
1043    'email'].order =  ICustomUGApplicant['email'].order
1044IPUTMEApplicantEdit[
1045    'nationality'].order =  ICustomUGApplicant['nationality'].order
1046
1047class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo):
1048    """Representation of an applicant.
1049
1050    Skip regular reg_number validation if reg_number is used for finding
1051    the applicant object.
1052    """
Note: See TracBrowser for help on using the repository browser.