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

Last change on this file since 15505 was 15490, checked in by Henrik Bettermann, 5 years ago

Add disabilities field.

  • Property svn:keywords set to Id
File size: 15.5 KB
RevLine 
[13814]1# -*- coding: utf-8 -*-
[7853]2## $Id: interfaces.py 15490 2019-07-09 06:17:19Z 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
[13831]22#from grok import getSite
[8012]23from zope import schema
[13831]24#from zope.interface import invariant, Invalid
25#from zope.component import getUtility
26#from zope.catalog.interfaces import ICatalog
[13814]27from zc.sourcefactory.basic import BasicSourceFactory
[8051]28from waeup.kofa.applicants.interfaces import (
[8053]29    IApplicantBaseData,
[8051]30    AppCatCertificateSource, CertificateSource)
31from waeup.kofa.schoolgrades import ResultEntryField
[8530]32from waeup.kofa.interfaces import (
[13814]33    SimpleKofaVocabulary, academic_sessions_vocab, validate_email,
[15490]34    IKofaObject)
[13814]35from waeup.kofa.schema import FormattedDate, TextLineChoice, PhoneNumber
[15490]36from waeup.kofa.students.vocabularies import (
37    nats_vocab, GenderSource)
[14106]38from waeup.kofa.refereeentries import RefereeEntryField
[8530]39from waeup.kofa.applicants.interfaces import contextual_reg_num_source
[15490]40from kofacustom.nigeria.interfaces import DisabilitiesSource
[8928]41from kofacustom.nigeria.applicants.interfaces import (
42    LGASource, high_qual, high_grade, exam_types,
[14140]43    programme_types_vocab, jambsubjects,
[8928]44    INigeriaUGApplicant, INigeriaPGApplicant,
45    INigeriaApplicantOnlinePayment,
[9006]46    INigeriaUGApplicantEdit, INigeriaPGApplicantEdit,
47    INigeriaApplicantUpdateByRegNo,
48    IPUTMEApplicantEdit,
[14140]49    IBankAccount,
[8928]50    )
[8020]51from waeup.uniben.interfaces import MessageFactory as _
[8247]52from waeup.uniben.payments.interfaces import ICustomOnlinePayment
[7853]53
[13814]54
55REGISTRATION_CATS = {
56    'corporate': ('Corporate Registration', 250000, 1),
57    'group': ('Group Registration', 200000, 2),
58    'individual': ('Individual Registration', 45000, 3),
59    'student': ('Student Registration', 5000, 4),
[13824]60    'fullpage': ('Full Page Advert', 250000, 5),
61    'halfpage': ('Half Page Advert', 150000, 6),
62    'quarterpage': ('Quarter Page Advert', 100000, 7),
[13814]63    }
64
65class RegTypesSource(BasicSourceFactory):
66    """A source that delivers all kinds of registrations.
67    """
68    def getValues(self):
69        sorted_items = sorted(REGISTRATION_CATS.items(),
70                              key=lambda element: element[1][2])
71        return [item[0] for item in sorted_items]
72
73    def getTitle(self, value):
74        return u"%s @ ₦ %s" % (
75            REGISTRATION_CATS[value][0],
76            REGISTRATION_CATS[value][1])
77
78class IUnibenRegistration(IKofaObject):
79    """A Uniben registrant.
80    """
81
82    suspended = schema.Bool(
83        title = _(u'Account suspended'),
84        default = False,
85        required = False,
86        )
87
88    locked = schema.Bool(
89        title = _(u'Form locked'),
90        default = False,
91        required = False,
92        )
93
94    applicant_id = schema.TextLine(
95        title = _(u'Registrant Id'),
96        required = False,
97        readonly = False,
98        )
99
100    firstname = schema.TextLine(
101        title = _(u'First Name'),
102        required = True,
103        )
104
105    middlename = schema.TextLine(
106        title = _(u'Middle Name'),
107        required = False,
108        )
109
110    lastname = schema.TextLine(
111        title = _(u'Last Name (Surname)'),
112        required = True,
113        )
114
[13819]115    sex = schema.Choice(
116        title = _(u'Sex'),
117        source = GenderSource(),
118        required = True,
[13814]119        )
120
121    nationality = schema.Choice(
122        vocabulary = nats_vocab,
123        title = _(u'Nationality'),
124        required = False,
125        )
126
127    email = schema.ASCIILine(
128        title = _(u'Email Address'),
129        required = True,
130        constraint=validate_email,
131        )
132
133    phone = PhoneNumber(
134        title = _(u'Phone'),
135        description = u'',
136        required = False,
137        )
138
[13819]139    #perm_address = schema.Text(
140    #    title = _(u'Current Local Address'),
141    #    required = False,
142    #    readonly = False,
143    #    )
144
145    institution = schema.TextLine(
146        title = _(u'Institution/Organisation'),
[13814]147        required = False,
148        readonly = False,
149        )
150
[13828]151    city = schema.TextLine(
152        title = _(u'City'),
153        required = False,
154        readonly = False,
155        )
156
[13819]157    lga = schema.Choice(
158        source = LGASource(),
159        title = _(u'State/LGA'),
160        required = False,
161        )
162
[13831]163    matric_number = schema.TextLine(
164        title = _(u'Uniben Matriculation Number'),
165        required = False,
166        readonly = False,
167        )
168
[13814]169    registration_cats = schema.List(
170        title = _(u'Registration Categories'),
171        value_type = schema.Choice(source=RegTypesSource()),
172        required = True,
[14020]173        defaultFactory=list,
[13814]174        )
175
[13831]176#    @invariant
177#    def matric_number_exists(applicant):
178#        if applicant.matric_number:
179#            catalog = getUtility(ICatalog, name='students_catalog')
180#            accommodation_session = getSite()['hostels'].accommodation_session
181#            student = catalog.searchResults(matric_number=(
182#                applicant.matric_number, applicant.matric_number))
183#            if len(student) != 1:
184#                raise Invalid(_("Matriculation number not found."))
[13814]185
[14140]186class ICustomUGApplicant(IApplicantBaseData, IBankAccount):
[8012]187    """An undergraduate applicant.
188
[8519]189    This interface defines the least common multiple of all fields
190    in ug application forms. In customized forms, fields can be excluded by
191    adding them to the UG_OMIT* tuples.
[8012]192    """
193
[15490]194    disabilities = schema.Choice(
195        title = _(u'Disabilities'),
196        source = DisabilitiesSource(),
197        required = False,
198        )
[14140]199    nationality = schema.Choice(
200        source = nats_vocab,
201        title = _(u'Nationality'),
202        required = False,
203        )
204    lga = schema.Choice(
205        source = LGASource(),
206        title = _(u'State/LGA (Nigerians only)'),
207        required = False,
208        )
209    #perm_address = schema.Text(
210    #    title = _(u'Permanent Address'),
211    #    required = False,
212    #    )
213    course1 = schema.Choice(
214        title = _(u'1st Choice Course of Study'),
215        source = AppCatCertificateSource(),
216        required = True,
217        )
218    course2 = schema.Choice(
219        title = _(u'2nd Choice Course of Study'),
220        source = AppCatCertificateSource(),
221        required = False,
222        )
223
224    programme_type = schema.Choice(
225        title = _(u'Programme Type'),
226        vocabulary = programme_types_vocab,
227        required = False,
228        )
229
230    hq_type = schema.Choice(
231        title = _(u'Qualification Obtained'),
232        required = False,
233        readonly = False,
234        vocabulary = high_qual,
235        )
236    hq_matric_no = schema.TextLine(
237        title = _(u'Former Matric Number'),
238        required = False,
239        readonly = False,
240        )
241    hq_degree = schema.Choice(
242        title = _(u'Class of Degree'),
243        required = False,
244        readonly = False,
245        vocabulary = high_grade,
246        )
247    hq_school = schema.TextLine(
248        title = _(u'Institution Attended'),
249        required = False,
250        readonly = False,
251        )
252    hq_session = schema.TextLine(
253        title = _(u'Years Attended'),
254        required = False,
255        readonly = False,
256        )
257    hq_disc = schema.TextLine(
258        title = _(u'Discipline'),
259        required = False,
260        readonly = False,
261        )
[14141]262    fst_sit_fname = schema.TextLine(
263        title = _(u'Full Name'),
264        required = False,
265        readonly = False,
266        )
267    fst_sit_no = schema.TextLine(
268        title = _(u'Exam Number'),
269        required = False,
270        readonly = False,
271        )
272    fst_sit_date = FormattedDate(
273        title = _(u'Exam Date'),
274        required = False,
275        readonly = False,
276        show_year = True,
277        )
278    fst_sit_type = schema.Choice(
279        title = _(u'Exam Type'),
280        required = False,
281        readonly = False,
282        vocabulary = exam_types,
283        )
284    fst_sit_results = schema.List(
285        title = _(u'Exam Results'),
286        value_type = ResultEntryField(),
287        required = False,
288        readonly = False,
289        defaultFactory=list,
290        )
291    scd_sit_fname = schema.TextLine(
292        title = _(u'Full Name'),
293        required = False,
294        readonly = False,
295        )
296    scd_sit_no = schema.TextLine(
297        title = _(u'Exam Number'),
298        required = False,
299        readonly = False,
300        )
301    scd_sit_date = FormattedDate(
302        title = _(u'Exam Date'),
303        required = False,
304        readonly = False,
305        show_year = True,
306        )
307    scd_sit_type = schema.Choice(
308        title = _(u'Exam Type'),
309        required = False,
310        readonly = False,
311        vocabulary = exam_types,
312        )
313    scd_sit_results = schema.List(
314        title = _(u'Exam Results'),
315        value_type = ResultEntryField(),
316        required = False,
317        readonly = False,
318        defaultFactory=list,
319        )
[14140]320    jamb_subjects = schema.Text(
321        title = _(u'Subjects and Scores'),
322        required = False,
323        )
324    jamb_subjects_list = schema.List(
325        title = _(u'JAMB Subjects'),
326        required = False,
327        defaultFactory=list,
328        value_type = schema.Choice(
329            vocabulary = jambsubjects
330            #source = JAMBSubjectSource(),
331            ),
332        )
333    jamb_score = schema.Int(
334        title = _(u'Total JAMB Score'),
335        required = False,
336        )
337    #jamb_age = schema.Int(
338    #    title = _(u'Age (provided by JAMB)'),
339    #    required = False,
340    #    )
341    jamb_reg_number = schema.TextLine(
342        title = _(u'JAMB Registration Number'),
343        required = False,
344        )
345    notice = schema.Text(
346        title = _(u'Notice'),
347        required = False,
348        )
349    screening_venue = schema.TextLine(
350        title = _(u'Screening Venue'),
351        required = False,
352        )
353    screening_date = schema.TextLine(
354        title = _(u'Screening Date'),
355        required = False,
356        )
357    screening_score = schema.Int(
358        title = _(u'Screening Score (%)'),
359        required = False,
360        )
361    aggregate = schema.Int(
362        title = _(u'Aggregate Score (%)'),
363        description = _(u'(average of relative JAMB and PUTME scores)'),
364        required = False,
365        )
366    result_uploaded = schema.Bool(
367        title = _(u'Result uploaded'),
368        default = False,
369        required = False,
370        )
371    student_id = schema.TextLine(
372        title = _(u'Student Id'),
373        required = False,
374        readonly = False,
375        )
376    course_admitted = schema.Choice(
377        title = _(u'Admitted Course of Study'),
378        source = CertificateSource(),
379        required = False,
380        )
381    locked = schema.Bool(
382        title = _(u'Form locked'),
383        default = False,
384        required = False,
385        )
386
387ICustomUGApplicant[
388    'locked'].order =  IApplicantBaseData['suspended'].order
389ICustomUGApplicant[
390    'result_uploaded'].order =  ICustomUGApplicant['suspended'].order
391
[8928]392class ICustomPGApplicant(INigeriaPGApplicant):
[7853]393    """A postgraduate applicant.
394
[8519]395    This interface defines the least common multiple of all fields
396    in pg application forms. In customized forms, fields can be excluded by
397    adding them to the PG_OMIT* tuples.
[7866]398    """
399
[14106]400    referees = schema.List(
401        title = _(u'Referees'),
402        value_type = RefereeEntryField(),
403        required = False,
404        defaultFactory=list,
405        )
[8012]406
[14106]407ICustomPGApplicant[
408    'referees'].order =  INigeriaPGApplicant['emp2_reason'].order
409
[13814]410class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant,
411    IUnibenRegistration):
[8012]412    """An interface for both types of applicants.
413
[8928]414    Attention: The ICustomPGApplicant field seetings will be overwritten
415    by ICustomPGApplicant field settings. If a field is defined
[8727]416    in both interfaces zope.schema validates only against the
[8928]417    constraints in ICustomUGApplicant. This does not affect the forms
418    since they are build on either ICustomUGApplicant or ICustomPGApplicant.
[8012]419    """
420
[8743]421    def writeLogMessage(view, comment):
[8053]422        """Adds an INFO message to the log file
423        """
424
425    def createStudent():
[8668]426        """Create a student object from applicant data
[8053]427        and copy applicant object.
428        """
429
[14212]430class ICustomUGApplicantEdit(ICustomUGApplicant):
[8727]431    """An undergraduate applicant interface for edit forms.
[8012]432
433    Here we can repeat the fields from base data and set the
434    `required` and `readonly` attributes to True to further restrict
435    the data access. Or we can allow only certain certificates to be
436    selected by choosing the appropriate source.
437
438    We cannot omit fields here. This has to be done in the
439    respective form page.
440    """
441
[14212]442    email = schema.ASCIILine(
443        title = _(u'Email Address'),
444        required = True,
445        constraint=validate_email,
446        )
447    date_of_birth = FormattedDate(
448        title = _(u'Date of Birth'),
449        required = True,
450        show_year = True,
451        )
452
453ICustomUGApplicantEdit[
454    'date_of_birth'].order = ICustomUGApplicant['date_of_birth'].order
455ICustomUGApplicantEdit[
456    'email'].order = ICustomUGApplicant['email'].order
457
[9056]458class ICustomPGApplicantEdit(INigeriaPGApplicantEdit):
[7866]459    """A postgraduate applicant interface for editing.
460
461    Here we can repeat the fields from base data and set the
462    `required` and `readonly` attributes to True to further restrict
463    the data access. Or we can allow only certain certificates to be
464    selected by choosing the appropriate source.
465
466    We cannot omit fields here. This has to be done in the
467    respective form page.
[8017]468    """
[8454]469
[14106]470    referees = schema.List(
471        title = _(u'Referees'),
472        value_type = RefereeEntryField(),
473        required = False,
474        defaultFactory=list,
475        )
[13814]476
[14106]477ICustomPGApplicantEdit[
478    'referees'].order =  INigeriaPGApplicantEdit['emp2_reason'].order
479
[8928]480class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment):
[8247]481    """An applicant payment via payment gateways.
482
483    """
[8530]484
[14153]485class IPUTMEApplicantEdit(ICustomUGApplicant):
[8530]486    """An undergraduate applicant interface for editing.
487
488    Here we can repeat the fields from base data and set the
489    `required` and `readonly` attributes to True to further restrict
490    the data access. Or we can allow only certain certificates to be
491    selected by choosing the appropriate source.
492
493    We cannot omit fields here. This has to be done in the
494    respective form page.
495    """
496
[14153]497    email = schema.ASCIILine(
498        title = _(u'Email Address'),
499        required = True,
500        constraint=validate_email,
501        )
502    date_of_birth = FormattedDate(
503        title = _(u'Date of Birth'),
504        required = True,
505        show_year = True,
506        )
507    nationality = schema.Choice(
508        source = nats_vocab,
509        title = _(u'Nationality'),
510        required = True,
511        )
512
513IPUTMEApplicantEdit[
514    'date_of_birth'].order =  ICustomUGApplicant['date_of_birth'].order
515IPUTMEApplicantEdit[
516    'email'].order =  ICustomUGApplicant['email'].order
517IPUTMEApplicantEdit[
518    'nationality'].order =  ICustomUGApplicant['nationality'].order
519
[9056]520class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo):
[8582]521    """Representation of an applicant.
522
523    Skip regular reg_number validation if reg_number is used for finding
524    the applicant object.
525    """
Note: See TracBrowser for help on using the repository browser.