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

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

Define invariant condition for managers.

Applicants can also see first choice course in edit form.

  • Property svn:keywords set to Id
File size: 9.4 KB
Line 
1## $Id: interfaces.py 10217 2013-05-24 05:18:59Z 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 = ('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'2nd Choice Course of Study'),
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    course1 = schema.Choice(
202        title = _(u'Programme desired'),
203        source = AppCatCertificateSource(),
204        required = True,
205        )
206    notice = schema.Text(
207        title = _(u'Notice'),
208        required = False,
209        readonly = False,
210        )
211    #screening_venue = schema.TextLine(
212    #    title = _(u'Screening Venue'),
213    #    required = False,
214    #    )
215    #screening_date = schema.TextLine(
216    #    title = _(u'Screening Date'),
217    #    required = False,
218    #    )
219    #screening_score = schema.Int(
220    #    title = _(u'Screening Score (%)'),
221    #    required = False,
222    #    )
223    student_id = schema.TextLine(
224        title = _(u'Student Id'),
225        required = False,
226        readonly = False,
227        )
228    course_admitted = schema.Choice(
229        title = _(u'Admitted Course of Study'),
230        source = CertificateSource(),
231        required = False,
232        readonly = False,
233        )
234    locked = schema.Bool(
235        title = _(u'Form locked'),
236        default = False,
237        )
238
239class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant):
240    """An interface for both types of applicants.
241
242    Attention: The ICustomPGApplicant field seetings will be overwritten
243    by ICustomPGApplicant field settings. If a field is defined
244    in both interfaces zope.schema validates only against the
245    constraints in ICustomUGApplicant. This does not affect the forms
246    since they are build on either ICustomUGApplicant or ICustomPGApplicant.
247    """
248
249    def writeLogMessage(view, comment):
250        """Adds an INFO message to the log file
251        """
252
253    def createStudent():
254        """Create a student object from applicatnt data
255        and copy applicant object.
256        """
257
258class ICustomUGApplicantEdit(ICustomUGApplicant):
259    """An undergraduate applicant interface for edit forms.
260
261    Here we can repeat the fields from base data and set the
262    `required` and `readonly` attributes to True to further restrict
263    the data access. Or we can allow only certain certificates to be
264    selected by choosing the appropriate source.
265
266    We cannot omit fields here. This has to be done in the
267    respective form page.
268    """
269
270    course1 = schema.Choice(
271        title = _(u'1st Choice Course of Study'),
272        source = AppCatCertificateSource(),
273        required = True,
274        readonly = True,
275        )
276
277    course2 = schema.Choice(
278        title = _(u'2nd Choice Course of Study'),
279        description = _(u'Comment which explains why applicant must select a 2nd Choice Course of Study.'),
280        source = AppCatCertificateSource(),
281        required = True,
282        )
283
284class ICustomPGApplicantEdit(ICustomPGApplicant):
285    """A postgraduate applicant interface for editing.
286
287    Here we can repeat the fields from base data and set the
288    `required` and `readonly` attributes to True to further restrict
289    the data access. Or we can allow only certain certificates to be
290    selected by choosing the appropriate source.
291
292    We cannot omit fields here. This has to be done in the
293    respective form page.
294    """
295
296
297class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment):
298    """An applicant payment via payment gateways.
299
300    """
301
302class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo):
303    """Representation of an applicant.
304
305    Skip regular reg_number validation if reg_number is used for finding
306    the applicant object.
307    """
308
Note: See TracBrowser for help on using the repository browser.