source: main/waeup.aaue/trunk/src/waeup/aaue/applicants/interfaces.py @ 10300

Last change on this file since 10300 was 10298, checked in by Henrik Bettermann, 12 years ago

Start customization of application forms.

  • Property svn:keywords set to Id
File size: 9.0 KB
Line 
1## $Id: interfaces.py 10298 2013-06-16 08:39:43Z 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.schoolgrades import ResultEntryField
27from waeup.kofa.interfaces import (
28    SimpleKofaVocabulary, academic_sessions_vocab, validate_email)
29from waeup.kofa.schema import FormattedDate, TextLineChoice
30from waeup.kofa.students.vocabularies import nats_vocab, GenderSource
31from waeup.kofa.applicants.interfaces import (
32    contextual_reg_num_source,
33    IApplicantBaseData)
34from kofacustom.nigeria.applicants.interfaces import (
35    LGASource, high_qual, high_grade, exam_types,
36    INigeriaUGApplicant, INigeriaPGApplicant,
37    INigeriaApplicantOnlinePayment,
38    INigeriaUGApplicantEdit, INigeriaPGApplicantEdit,
39    INigeriaApplicantUpdateByRegNo,
40    IPUTMEApplicantEdit,
41    )
42from waeup.aaue.interfaces import MessageFactory as _
43from waeup.aaue.payments.interfaces import ICustomOnlinePayment
44
45class ICustomUGApplicant(IApplicantBaseData):
46    """An undergraduate applicant.
47
48    This interface defines the least common multiple of all fields
49    in ug application forms. In customized forms, fields can be excluded by
50    adding them to the UG_OMIT* tuples.
51    """
52
53    nationality = schema.Choice(
54        source = nats_vocab,
55        title = _(u'Nationality'),
56        required = True,
57        )
58    lga = schema.Choice(
59        source = LGASource(),
60        title = _(u'State/LGA (Nigerians only)'),
61        required = False,
62        )
63    perm_address = schema.Text(
64        title = _(u'Permanent Address'),
65        required = False,
66        )
67    course1 = schema.Choice(
68        title = _(u'1st Choice Course of Study'),
69        source = AppCatCertificateSource(),
70        required = True,
71        )
72    course2 = schema.Choice(
73        title = _(u'2nd Choice Course of Study'),
74        source = AppCatCertificateSource(),
75        required = False,
76        )
77    fst_sit_fname = schema.TextLine(
78        title = _(u'Full Name'),
79        required = False,
80        readonly = False,
81        )
82    fst_sit_no = schema.TextLine(
83        title = _(u'Exam Number'),
84        required = False,
85        readonly = False,
86        )
87    fst_sit_date = FormattedDate(
88        title = _(u'Exam Date'),
89        required = False,
90        readonly = False,
91        show_year = True,
92        )
93    fst_sit_type = schema.Choice(
94        title = _(u'Exam Type'),
95        required = False,
96        readonly = False,
97        vocabulary = exam_types,
98        )
99    fst_sit_results = schema.List(
100        title = _(u'Exam Results'),
101        value_type = ResultEntryField(),
102        required = False,
103        readonly = False,
104        default = [],
105        )
106    scd_sit_fname = schema.TextLine(
107        title = _(u'Full Name'),
108        required = False,
109        readonly = False,
110        )
111    scd_sit_no = schema.TextLine(
112        title = _(u'Exam Number'),
113        required = False,
114        readonly = False,
115        )
116    scd_sit_date = FormattedDate(
117        title = _(u'Exam Date'),
118        required = False,
119        readonly = False,
120        show_year = True,
121        )
122    scd_sit_type = schema.Choice(
123        title = _(u'Exam Type'),
124        required = False,
125        readonly = False,
126        vocabulary = exam_types,
127        )
128    scd_sit_results = schema.List(
129        title = _(u'Exam Results'),
130        value_type = ResultEntryField(),
131        required = False,
132        readonly = False,
133        default = [],
134        )
135    alr_fname = schema.TextLine(
136        title = _(u'Full Name'),
137        required = False,
138        readonly = False,
139        )
140    alr_no = schema.TextLine(
141        title = _(u'Exam Number'),
142        required = False,
143        readonly = False,
144        )
145    alr_date = FormattedDate(
146        title = _(u'Exam Date'),
147        required = False,
148        readonly = False,
149        show_year = True,
150        )
151    alr_results = schema.List(
152        title = _(u'Exam Results'),
153        value_type = ResultEntryField(),
154        required = False,
155        readonly = False,
156        default = [],
157        )
158    jamb_subjects = schema.Text(
159        title = _(u'Subjects and Scores'),
160        required = False,
161        )
162    jamb_score = schema.Int(
163        title = _(u'Total JAMB Score'),
164        required = False,
165        )
166    notice = schema.Text(
167        title = _(u'Notice'),
168        required = False,
169        )
170    screening_venue = schema.TextLine(
171        title = _(u'Screening Venue'),
172        required = False,
173        )
174    screening_date = schema.TextLine(
175        title = _(u'Screening Date'),
176        required = False,
177        )
178    screening_score = schema.Int(
179        title = _(u'Screening Score (%)'),
180        required = False,
181        )
182    aggregate = schema.Int(
183        title = _(u'Aggregate Score (%)'),
184        description = _(u'(average of relative JAMB and PUTME scores)'),
185        required = False,
186        )
187    result_uploaded = schema.Bool(
188        title = _(u'Result uploaded'),
189        default = False,
190        )
191    student_id = schema.TextLine(
192        title = _(u'Student Id'),
193        required = False,
194        readonly = False,
195        )
196    course_admitted = schema.Choice(
197        title = _(u'Admitted Course of Study'),
198        source = CertificateSource(),
199        required = False,
200        )
201    locked = schema.Bool(
202        title = _(u'Form locked'),
203        default = False,
204        )
205
206    @invariant
207    def second_choice(applicant):
208        if applicant.course1 == applicant.course2:
209            raise Invalid(_("2nd choice course must differ from 1st choice course."))
210
211class ICustomPGApplicant(INigeriaPGApplicant):
212    """A postgraduate applicant.
213
214    This interface defines the least common multiple of all fields
215    in pg application forms. In customized forms, fields can be excluded by
216    adding them to the PG_OMIT* tuples.
217    """
218
219class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant):
220    """An interface for both types of applicants.
221
222    Attention: The ICustomPGApplicant field seetings will be overwritten
223    by ICustomPGApplicant field settings. If a field is defined
224    in both interfaces zope.schema validates only against the
225    constraints in ICustomUGApplicant. This does not affect the forms
226    since they are build on either ICustomUGApplicant or ICustomPGApplicant.
227    """
228
229    def writeLogMessage(view, comment):
230        """Adds an INFO message to the log file
231        """
232
233    def createStudent():
234        """Create a student object from applicatnt data
235        and copy applicant object.
236        """
237
238class ICustomUGApplicantEdit(ICustomUGApplicant):
239    """An undergraduate applicant interface for edit forms.
240
241    Here we can repeat the fields from base data and set the
242    `required` and `readonly` attributes to True to further restrict
243    the data access. Or we can allow only certain certificates to be
244    selected by choosing the appropriate source.
245
246    We cannot omit fields here. This has to be done in the
247    respective form page.
248    """
249
250class ICustomPGApplicantEdit(INigeriaPGApplicantEdit):
251    """A postgraduate applicant interface for editing.
252
253    Here we can repeat the fields from base data and set the
254    `required` and `readonly` attributes to True to further restrict
255    the data access. Or we can allow only certain certificates to be
256    selected by choosing the appropriate source.
257
258    We cannot omit fields here. This has to be done in the
259    respective form page.
260    """
261
262class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment):
263    """An applicant payment via payment gateways.
264
265    """
266
267class IPUTMEApplicantEdit(IPUTMEApplicantEdit):
268    """An undergraduate applicant interface for editing.
269
270    Here we can repeat the fields from base data and set the
271    `required` and `readonly` attributes to True to further restrict
272    the data access. Or we can allow only certain certificates to be
273    selected by choosing the appropriate source.
274
275    We cannot omit fields here. This has to be done in the
276    respective form page.
277    """
278
279class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo):
280    """Representation of an applicant.
281
282    Skip regular reg_number validation if reg_number is used for finding
283    the applicant object.
284    """
285
Note: See TracBrowser for help on using the repository browser.