source: main/waeup.fceokene/trunk/src/waeup/fceokene/applicants/interfaces.py @ 16861

Last change on this file since 16861 was 16854, checked in by Henrik Bettermann, 3 years ago

Implement TPUCertificateSource.

  • Property svn:keywords set to Id
File size: 14.0 KB
RevLine 
[7853]1## $Id: interfaces.py 16854 2022-03-01 17:17:11Z 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
[13877]22from zc.sourcefactory.basic import BasicSourceFactory
[8051]23from waeup.kofa.applicants.interfaces import (
[8053]24    IApplicantBaseData,
[8051]25    AppCatCertificateSource, CertificateSource)
26from waeup.kofa.schoolgrades import ResultEntryField
[8531]27from waeup.kofa.interfaces import (
[13877]28    SimpleKofaVocabulary, academic_sessions_vocab, validate_email,
29    IKofaObject)
30from waeup.kofa.schema import FormattedDate, TextLineChoice, PhoneNumber
[9465]31from waeup.kofa.schoolgrades import ResultEntryField
[8531]32from waeup.kofa.students.vocabularies import nats_vocab, GenderSource
33from waeup.kofa.applicants.interfaces import contextual_reg_num_source
[8933]34from kofacustom.nigeria.applicants.interfaces import (
35    LGASource, high_qual, high_grade, exam_types,
36    INigeriaUGApplicant, INigeriaPGApplicant,
37    INigeriaApplicantOnlinePayment,
[9497]38    INigeriaUGApplicantEdit,
[8979]39    INigeriaApplicantUpdateByRegNo,
40    IPUTMEApplicantEdit,
[9463]41    OMIT_DISPLAY_FIELDS
[8933]42    )
[16414]43from waeup.fceokene.applicants.schools_pandemic import SCHOOLS
[8460]44from waeup.fceokene.interfaces import MessageFactory as _
[7853]45
[9463]46BEC_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS
47BEC_OMIT_PDF_FIELDS = BEC_OMIT_DISPLAY_FIELDS + ('phone',)
[10852]48BEC_OMIT_MANAGE_FIELDS = ('special_application',)
[9463]49BEC_OMIT_EDIT_FIELDS = BEC_OMIT_MANAGE_FIELDS + OMIT_DISPLAY_FIELDS + (
50    'student_id', 'notice',
51    'screening_score',
52    'screening_venue',
53    'screening_date',
54    #'jamb_subjects',
55    #'jamb_score',
56    'aggregate')
57
[16854]58class TPUCertificateSource(AppCatCertificateSource):
59
60    def getValues(self, context):
61        resultlist = super(TPUCertificateSource, self).getValues(context)
62        return [i for i in resultlist if i.title.startswith('NCE')]
63
[13877]64class SchoolSource(BasicSourceFactory):
[14499]65    """A source that delivers all kinds of schools.
[13877]66    """
67    def getValues(self):
[14067]68        sorted_items = sorted(
69            SCHOOLS.items(),
70            key=lambda element: element[1][0] + element[1][1] +element[1][2])
[13877]71        return [item[0] for item in sorted_items]
72
[14499]73    def getToken(self, value):
74        return value
75
[13877]76    def getTitle(self, value):
[15594]77        if not SCHOOLS.get(value, None):
78            return u"none-existent"
[13877]79        return u"%s: %s -- %s" % (
80            SCHOOLS[value][0],
81            SCHOOLS[value][1],
82            SCHOOLS[value][2],)
83
84class ITPURegistration(IKofaObject):
85    """A TPU registrant.
86    """
87
88    suspended = schema.Bool(
89        title = _(u'Account suspended'),
90        default = False,
91        required = False,
92        )
93
94    locked = schema.Bool(
95        title = _(u'Form locked'),
96        default = False,
97        required = False,
98        )
99
100    applicant_id = schema.TextLine(
101        title = _(u'Applicant Id'),
102        required = False,
103        readonly = False,
104        )
105
106    reg_number = schema.TextLine(
107        title = _(u'Registration Number'),
108        required = False,
109        readonly = False,
110        )
111
112    matric_number = schema.TextLine(
113        title = _(u'Matriculation Number'),
114        required = False,
115        readonly = False,
116        )
117
118    firstname = schema.TextLine(
119        title = _(u'First Name'),
120        required = True,
121        )
122
123    middlename = schema.TextLine(
124        title = _(u'Middle Name'),
125        required = False,
126        )
127
128    lastname = schema.TextLine(
129        title = _(u'Last Name (Surname)'),
130        required = True,
131        )
132
133    email = schema.ASCIILine(
134        title = _(u'Email Address'),
135        required = True,
136        constraint=validate_email,
137        )
138
139    phone = PhoneNumber(
140        title = _(u'Phone'),
141        description = u'',
142        required = False,
143        )
144
145    perm_address = schema.Text(
146        title = _(u'Home Address'),
147        required = False,
148        readonly = False,
149        )
150
151    lga = schema.Choice(
152        source = LGASource(),
153        title = _(u'State/LGA'),
154        required = False,
155        )
156
[16844]157    #subj_comb = schema.TextLine(
158    #    title = _(u'Subject Combination'),
159    #    required = False,
160    #    readonly = False,
161    #    )
162
163    subj_comb = schema.Choice(
[13877]164        title = _(u'Subject Combination'),
[16854]165        source = TPUCertificateSource(),
[16848]166        required = True,
[13877]167        )
168
169    school1 = schema.Choice(
170        title = _(u'1st Choice TPZ and School'),
171        source = SchoolSource(),
[15111]172        required = False,
[13877]173        )
174
[8933]175class ICustomUGApplicant(INigeriaUGApplicant):
[8012]176    """An undergraduate applicant.
177
[8520]178    This interface defines the least common multiple of all fields
179    in ug application forms. In customized forms, fields can be excluded by
[9463]180    adding them to the OMIT* tuples.
[8012]181    """
182
[9465]183    nationality = schema.Choice(
184        source = nats_vocab,
185        title = _(u'Nationality'),
186        required = True,
187        )
188    lga = schema.Choice(
189        source = LGASource(),
190        title = _(u'State/LGA (Nigerians only)'),
191        required = False,
192        )
193    #perm_address = schema.Text(
194    #    title = _(u'Permanent Address'),
195    #    required = False,
196    #    )
197    course1 = schema.Choice(
198        title = _(u'1st Choice Course of Study'),
199        source = AppCatCertificateSource(),
[13884]200        required = False,
[9465]201        )
202    course2 = schema.Choice(
203        title = _(u'2nd Choice Course of Study'),
204        source = AppCatCertificateSource(),
205        required = False,
206        )
[9463]207    olevel_type = schema.Choice(
[9500]208        title = _(u'1st Qualification Obtained'),
[9463]209        required = False,
210        readonly = False,
[9465]211        vocabulary = exam_types,
212        )
213    olevel_school = schema.TextLine(
[9500]214        title = _(u'1st Institution Attended'),
[9465]215        required = False,
216        readonly = False,
217        )
218    olevel_exam_number = schema.TextLine(
[9500]219        title = _(u'1st Exam Number'),
[9465]220        required = False,
221        readonly = False,
222        )
223    olevel_exam_date = FormattedDate(
[9500]224        title = _(u'1st Exam Date'),
[9465]225        required = False,
226        readonly = False,
227        show_year = True,
228        )
229    olevel_results = schema.List(
[9500]230        title = _(u'1st Exam Results'),
[9465]231        value_type = ResultEntryField(),
232        required = False,
233        readonly = False,
[14018]234        defaultFactory=list,
[9465]235        )
[9500]236    olevel_type2 = schema.Choice(
237        title = _(u'2nd Qualification Obtained'),
238        required = False,
239        readonly = False,
240        vocabulary = exam_types,
241        )
242    olevel_school2 = schema.TextLine(
243        title = _(u'2nd Institution Attended'),
244        required = False,
245        readonly = False,
246        )
247    olevel_exam_number2 = schema.TextLine(
248        title = _(u'2nd Exam Number'),
249        required = False,
250        readonly = False,
251        )
252    olevel_exam_date2 = FormattedDate(
253        title = _(u'2nd Exam Date'),
254        required = False,
255        readonly = False,
256        show_year = True,
257        )
258    olevel_results2 = schema.List(
259        title = _(u'2nd Exam Results'),
260        value_type = ResultEntryField(),
261        required = False,
262        readonly = False,
[14018]263        defaultFactory=list,
[9500]264        )
[9465]265    hq_type = schema.Choice(
266        title = _(u'Qualification Obtained'),
267        required = False,
268        readonly = False,
[9463]269        vocabulary = high_qual,
270        )
[9465]271    hq_matric_no = schema.TextLine(
[9463]272        title = _(u'Former Matric Number'),
273        required = False,
274        readonly = False,
275        )
[9465]276    hq_degree = schema.Choice(
[9463]277        title = _(u'Class of Degree'),
278        required = False,
279        readonly = False,
280        vocabulary = high_grade,
281        )
[9465]282    hq_school = schema.TextLine(
[9463]283        title = _(u'Institution Attended'),
284        required = False,
285        readonly = False,
286        )
[9465]287    hq_session = schema.TextLine(
[9463]288        title = _(u'Years Attended'),
289        required = False,
290        readonly = False,
291        )
[9465]292    hq_disc = schema.TextLine(
[9463]293        title = _(u'Discipline'),
294        required = False,
295        readonly = False,
296        )
[9465]297    jamb_subjects = schema.Text(
298        title = _(u'Subjects and Scores'),
[10533]299        description = _(u'(one subject with score per line)'),
[9465]300        required = False,
301        )
302    jamb_score = schema.Int(
303        title = _(u'Total JAMB Score'),
304        required = False,
305        )
[10500]306    jamb_reg_number = schema.TextLine(
307        title = _(u'JAMB Registration Number'),
308        required = False,
309        )
[9465]310    notice = schema.Text(
311        title = _(u'Notice'),
312        required = False,
313        )
314    screening_venue = schema.TextLine(
315        title = _(u'Screening Venue'),
316        required = False,
317        )
318    screening_date = schema.TextLine(
319        title = _(u'Screening Date'),
320        required = False,
321        )
322    screening_score = schema.Int(
323        title = _(u'Screening Score (%)'),
324        required = False,
325        )
326    aggregate = schema.Int(
327        title = _(u'Aggregate Score (%)'),
328        description = _(u'(average of relative JAMB and PUTME scores)'),
329        required = False,
330        )
331    result_uploaded = schema.Bool(
332        title = _(u'Result uploaded'),
333        default = False,
[14335]334        required = False,
[9465]335        )
336    student_id = schema.TextLine(
337        title = _(u'Student Id'),
338        required = False,
339        readonly = False,
340        )
341    course_admitted = schema.Choice(
342        title = _(u'Admitted Course of Study'),
343        source = CertificateSource(),
344        required = False,
345        )
346    locked = schema.Bool(
347        title = _(u'Form locked'),
348        default = False,
[14335]349        required = False,
[9465]350        )
[9463]351
352
[8933]353class ICustomPGApplicant(INigeriaPGApplicant):
[7853]354    """A postgraduate applicant.
355
[8520]356    This interface defines the least common multiple of all fields
357    in pg application forms. In customized forms, fields can be excluded by
358    adding them to the PG_OMIT* tuples.
[7866]359    """
360
[13877]361class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant,
362    ITPURegistration):
363    """An interface for all types of applicants.
[8012]364
[8933]365    Attention: The ICustomPGApplicant field seetings will be overwritten
366    by ICustomPGApplicant field settings. If a field is defined
[8729]367    in both interfaces zope.schema validates only against the
[8933]368    constraints in ICustomUGApplicant. This does not affect the forms
369    since they are build on either ICustomUGApplicant or ICustomPGApplicant.
[8012]370    """
371
[8745]372    def writeLogMessage(view, comment):
[8053]373        """Adds an INFO message to the log file
374        """
375
376    def createStudent():
377        """Create a student object from applicatnt data
378        and copy applicant object.
379        """
380
[9497]381class ICustomUGApplicantEdit(ICustomUGApplicant):
[8729]382    """An undergraduate applicant interface for edit forms.
[8012]383
384    Here we can repeat the fields from base data and set the
385    `required` and `readonly` attributes to True to further restrict
386    the data access. Or we can allow only certain certificates to be
387    selected by choosing the appropriate source.
388
389    We cannot omit fields here. This has to be done in the
390    respective form page.
391    """
392
[9497]393
394    email = schema.ASCIILine(
395        title = _(u'Email Address'),
396        required = True,
397        constraint=validate_email,
398        )
399    date_of_birth = FormattedDate(
400        title = _(u'Date of Birth'),
401        required = True,
402        show_year = True,
403        )
[11776]404    jamb_reg_number = schema.TextLine(
405        title = _(u'JAMB Registration Number'),
406        required = True,
407        )
[13884]408    course1 = schema.Choice(
409        title = _(u'1st Choice Course of Study'),
410        source = AppCatCertificateSource(),
411        required = True,
412        )
[9497]413
[10500]414ICustomUGApplicantEdit[
415    'date_of_birth'].order =  ICustomUGApplicant['date_of_birth'].order
416ICustomUGApplicantEdit[
417    'email'].order =  ICustomUGApplicant['email'].order
418ICustomUGApplicantEdit[
[13238]419    'jamb_reg_number'].order =  ICustomUGApplicant['jamb_reg_number'].order
[13884]420ICustomUGApplicantEdit[
421    'course1'].order =  ICustomUGApplicant['course1'].order
[10500]422
[9497]423class ICustomPGApplicantEdit(ICustomPGApplicant):
[7866]424    """A postgraduate applicant interface for editing.
425
426    Here we can repeat the fields from base data and set the
427    `required` and `readonly` attributes to True to further restrict
428    the data access. Or we can allow only certain certificates to be
429    selected by choosing the appropriate source.
430
431    We cannot omit fields here. This has to be done in the
432    respective form page.
[8017]433    """
[8454]434
[9497]435    email = schema.ASCIILine(
436        title = _(u'Email Address'),
437        required = True,
438        constraint=validate_email,
439        )
440    date_of_birth = FormattedDate(
441        title = _(u'Date of Birth'),
442        required = True,
443        show_year = True,
444        )
445
[10500]446ICustomPGApplicantEdit[
447    'date_of_birth'].order =  ICustomPGApplicant['date_of_birth'].order
448ICustomPGApplicantEdit[
449    'email'].order =  ICustomPGApplicant['email'].order
450
451
[8933]452class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment):
[8247]453    """An applicant payment via payment gateways.
454
455    """
[8531]456
[8979]457class IPUTMEApplicantEdit(IPUTMEApplicantEdit):
[8531]458    """An undergraduate applicant interface for editing.
459
460    Here we can repeat the fields from base data and set the
461    `required` and `readonly` attributes to True to further restrict
462    the data access. Or we can allow only certain certificates to be
463    selected by choosing the appropriate source.
464
465    We cannot omit fields here. This has to be done in the
466    respective form page.
467    """
468
[8979]469class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo):
[8584]470    """Representation of an applicant.
471
472    Skip regular reg_number validation if reg_number is used for finding
473    the applicant object.
474    """
[8979]475
Note: See TracBrowser for help on using the repository browser.