source: main/waeup.futminna/trunk/src/waeup/futminna/applicants/interfaces.py @ 15220

Last change on this file since 15220 was 10853, checked in by Henrik Bettermann, 11 years ago

Revert reversion. Omitting special_application is necessary.

  • Property svn:keywords set to Id
File size: 10.5 KB
Line 
1## $Id: interfaces.py 10853 2013-12-15 07:32:25Z 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
21from zope import schema
22from zope.interface import Attribute, invariant, Invalid
23from waeup.kofa.applicants.interfaces import (
24    IApplicantBaseData,
25    AppCatCertificateSource, CertificateSource)
26from waeup.kofa.students.vocabularies import nats_vocab
27from kofacustom.nigeria.applicants.interfaces import (
28    LGASource,
29    high_qual, high_grade, exam_types,
30    INigeriaUGApplicant,
31    INigeriaApplicantOnlinePayment,
32    INigeriaUGApplicantEdit, INigeriaPGApplicantEdit,
33    INigeriaApplicantUpdateByRegNo,
34    IPUTMEApplicantEdit,
35    OMIT_DISPLAY_FIELDS,
36    UG_OMIT_DISPLAY_FIELDS,
37    UG_OMIT_PDF_FIELDS,
38    UG_OMIT_MANAGE_FIELDS,
39    UG_OMIT_EDIT_FIELDS,
40    PUTME_OMIT_EDIT_FIELDS,
41    PUTME_OMIT_DISPLAY_FIELDS,
42    PUTME_OMIT_PDF_FIELDS,
43    PUTME_OMIT_MANAGE_FIELDS,
44    PUTME_OMIT_FIELDS,
45    #PUTME_OMIT_EDIT_FIELDS,
46    )
47
48PUTME_OMIT_EDIT_FIELDS = UG_OMIT_EDIT_FIELDS + PUTME_OMIT_FIELDS + (
49    'firstname', 'middlename', 'lastname', 'sex',
50    'lga')
51
52PG_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS + ('course2',)
53PG_OMIT_PDF_FIELDS = PG_OMIT_DISPLAY_FIELDS + ('phone',)
54PG_OMIT_MANAGE_FIELDS = ('special_application', 'course2',)
55PG_OMIT_EDIT_FIELDS = PG_OMIT_MANAGE_FIELDS + PG_OMIT_DISPLAY_FIELDS + (
56    'student_id', 'notice',
57    'screening_score', 'screening_venue',
58    'screening_date',)
59
60from waeup.futminna.interfaces import MessageFactory as _
61
62class ICustomUGApplicant(IApplicantBaseData):
63    """An undergraduate applicant.
64
65    This interface defines the least common multiple of all fields
66    in ug application forms. In customized forms, fields can be excluded by
67    adding them to the UG_OMIT* tuples.
68    """
69
70    nationality = schema.Choice(
71        source = nats_vocab,
72        title = _(u'Nationality'),
73        required = True,
74        )
75    lga = schema.Choice(
76        source = LGASource(),
77        title = _(u'State/LGA (Nigerians only)'),
78        required = False,
79        )
80    perm_address = schema.Text(
81        title = _(u'Permanent Address'),
82        required = False,
83        )
84    course1 = schema.Choice(
85        title = _(u'1st Choice Course of Study'),
86        source = AppCatCertificateSource(),
87        required = True,
88        )
89    course2 = schema.Choice(
90        title = _(u'Change of Course'),
91        source = AppCatCertificateSource(),
92        required = False,
93        )
94    hq_type = schema.Choice(
95        title = _(u'Qualification Obtained'),
96        required = False,
97        readonly = False,
98        vocabulary = high_qual,
99        )
100    hq_matric_no = schema.TextLine(
101        title = _(u'Former Matric Number'),
102        required = False,
103        readonly = False,
104        )
105    hq_degree = schema.Choice(
106        title = _(u'Class of Degree'),
107        required = False,
108        readonly = False,
109        vocabulary = high_grade,
110        )
111    hq_school = schema.TextLine(
112        title = _(u'Institution Attended'),
113        required = False,
114        readonly = False,
115        )
116    hq_session = schema.TextLine(
117        title = _(u'Years Attended'),
118        required = False,
119        readonly = False,
120        )
121    hq_disc = schema.TextLine(
122        title = _(u'Discipline'),
123        required = False,
124        readonly = False,
125        )
126    jamb_subjects = schema.Text(
127        title = _(u'Subjects and Scores'),
128        required = False,
129        )
130    jamb_score = schema.Int(
131        title = _(u'Total JAMB Score'),
132        required = False,
133        )
134    notice = schema.Text(
135        title = _(u'Notice'),
136        required = False,
137        )
138    screening_venue = schema.TextLine(
139        title = _(u'Screening Venue'),
140        required = False,
141        )
142    screening_date = schema.TextLine(
143        title = _(u'Screening Date'),
144        required = False,
145        )
146    screening_score = schema.Int(
147        title = _(u'Screening Score (%)'),
148        required = False,
149        )
150    aggregate = schema.Int(
151        title = _(u'Aggregate Score (%)'),
152        description = _(u'(average of relative JAMB and PUTME scores)'),
153        required = False,
154        )
155    result_uploaded = schema.Bool(
156        title = _(u'Result uploaded'),
157        default = False,
158        )
159    student_id = schema.TextLine(
160        title = _(u'Student Id'),
161        required = False,
162        readonly = False,
163        )
164    course_admitted = schema.Choice(
165        title = _(u'Admitted Course of Study'),
166        source = CertificateSource(),
167        required = False,
168        )
169    locked = schema.Bool(
170        title = _(u'Form locked'),
171        default = False,
172        )
173
174    @invariant
175    def second_choice(applicant):
176        if applicant.course1 == applicant.course2:
177            raise Invalid(_("2nd choice course must differ from 1st choice course."))
178
179class ICustomPGApplicant(IApplicantBaseData):
180    """A postgraduate applicant.
181
182    This interface defines the least common multiple of all fields
183    in pg application forms. In customized forms, fields can be excluded by
184    adding them to the PG_OMIT* tuples.
185    """
186
187    nationality = schema.Choice(
188        source = nats_vocab,
189        title = _(u'Nationality'),
190        required = True,
191        )
192    lga = schema.Choice(
193        source = LGASource(),
194        title = _(u'State/LGA (Nigerians only)'),
195        required = False,
196        )
197    perm_address = schema.Text(
198        title = _(u'Permanent Address'),
199        required = False,
200        )
201    hq_type = schema.Choice(
202        title = _(u'Qualification Obtained'),
203        required = False,
204        readonly = False,
205        vocabulary = high_qual,
206        )
207    hq_matric_no = schema.TextLine(
208        title = _(u'Former Matric Number'),
209        required = False,
210        readonly = False,
211        )
212    hq_degree = schema.Choice(
213        title = _(u'Class of Degree'),
214        required = False,
215        readonly = False,
216        vocabulary = high_grade,
217        )
218    hq_school = schema.TextLine(
219        title = _(u'Institution Attended'),
220        required = False,
221        readonly = False,
222        )
223    hq_session = schema.TextLine(
224        title = _(u'Years Attended'),
225        required = False,
226        readonly = False,
227        )
228    hq_disc = schema.TextLine(
229        title = _(u'Discipline'),
230        required = False,
231        readonly = False,
232        )
233    pp_school = schema.Choice(
234        title = _(u'Qualification Obtained'),
235        required = False,
236        readonly = False,
237        vocabulary = exam_types,
238        )
239    course1 = schema.Choice(
240        title = _(u'Programme desired'),
241        source = AppCatCertificateSource(),
242        required = True,
243        )
244    notice = schema.Text(
245        title = _(u'Notice'),
246        required = False,
247        readonly = False,
248        )
249    #screening_venue = schema.TextLine(
250    #    title = _(u'Screening Venue'),
251    #    required = False,
252    #    )
253    #screening_date = schema.TextLine(
254    #    title = _(u'Screening Date'),
255    #    required = False,
256    #    )
257    #screening_score = schema.Int(
258    #    title = _(u'Screening Score (%)'),
259    #    required = False,
260    #    )
261    student_id = schema.TextLine(
262        title = _(u'Student Id'),
263        required = False,
264        readonly = False,
265        )
266    course_admitted = schema.Choice(
267        title = _(u'Admitted Course of Study'),
268        source = CertificateSource(),
269        required = False,
270        readonly = False,
271        )
272    locked = schema.Bool(
273        title = _(u'Form locked'),
274        default = False,
275        )
276
277class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant):
278    """An interface for both types of applicants.
279
280    Attention: The ICustomPGApplicant field seetings will be overwritten
281    by ICustomPGApplicant field settings. If a field is defined
282    in both interfaces zope.schema validates only against the
283    constraints in ICustomUGApplicant. This does not affect the forms
284    since they are build on either ICustomUGApplicant or ICustomPGApplicant.
285    """
286
287    def writeLogMessage(view, comment):
288        """Adds an INFO message to the log file
289        """
290
291    def createStudent():
292        """Create a student object from applicatnt data
293        and copy applicant object.
294        """
295
296class ICustomUGApplicantEdit(ICustomUGApplicant):
297    """An undergraduate applicant interface for edit forms.
298
299    Here we can repeat the fields from base data and set the
300    `required` and `readonly` attributes to True to further restrict
301    the data access. Or we can allow only certain certificates to be
302    selected by choosing the appropriate source.
303
304    We cannot omit fields here. This has to be done in the
305    respective form page.
306    """
307
308    course1 = schema.Choice(
309        title = _(u'1st Choice Course of Study'),
310        source = AppCatCertificateSource(),
311        required = True,
312        readonly = True,
313        )
314
315    course2 = schema.Choice(
316        title = _(u'Change of Course'),
317        description = _(
318            u'Your JAMB score is lower than the requirement for your '
319            '1st choice course of study, chose another course here.'),
320        source = AppCatCertificateSource(),
321        required = True,
322        )
323
324class ICustomPGApplicantEdit(ICustomPGApplicant):
325    """A postgraduate applicant interface for editing.
326
327    Here we can repeat the fields from base data and set the
328    `required` and `readonly` attributes to True to further restrict
329    the data access. Or we can allow only certain certificates to be
330    selected by choosing the appropriate source.
331
332    We cannot omit fields here. This has to be done in the
333    respective form page.
334    """
335
336
337class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment):
338    """An applicant payment via payment gateways.
339
340    """
341
342class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo):
343    """Representation of an applicant.
344
345    Skip regular reg_number validation if reg_number is used for finding
346    the applicant object.
347    """
348
Note: See TracBrowser for help on using the repository browser.