1 | ## $Id: interfaces.py 8196 2012-04-17 12:14:03Z 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 | |
---|
21 | from zope import schema |
---|
22 | from waeup.kofa.applicants.interfaces import ( |
---|
23 | IApplicantBaseData, |
---|
24 | AppCatCertificateSource, CertificateSource) |
---|
25 | from waeup.kofa.schoolgrades import ResultEntryField |
---|
26 | from waeup.kofa.interfaces import SimpleKofaVocabulary |
---|
27 | from waeup.kofa.schema import FormattedDate |
---|
28 | from waeup.kofa.students.vocabularies import nats_vocab |
---|
29 | from waeup.uniben.interfaces import ( |
---|
30 | lgas_vocab, high_qual, high_grade, exam_types) |
---|
31 | from waeup.uniben.interfaces import MessageFactory as _ |
---|
32 | |
---|
33 | |
---|
34 | class IUGApplicant(IApplicantBaseData): |
---|
35 | """An undergraduate applicant. |
---|
36 | |
---|
37 | """ |
---|
38 | |
---|
39 | nationality = schema.Choice( |
---|
40 | source = nats_vocab, |
---|
41 | title = _(u'Nationality'), |
---|
42 | required = False, |
---|
43 | ) |
---|
44 | lga = schema.Choice( |
---|
45 | source = lgas_vocab, |
---|
46 | title = _(u'State/LGA (Nigerians only)'), |
---|
47 | required = False, |
---|
48 | ) |
---|
49 | |
---|
50 | # This ordering doesn't work properly. |
---|
51 | IUGApplicant[ |
---|
52 | 'nationality'].order = IApplicantBaseData['sex'].order |
---|
53 | IUGApplicant[ |
---|
54 | 'lga'].order = IUGApplicant['nationality'].order |
---|
55 | |
---|
56 | |
---|
57 | class IPGApplicant(IApplicantBaseData): |
---|
58 | """A postgraduate applicant. |
---|
59 | |
---|
60 | """ |
---|
61 | |
---|
62 | nationality = schema.Choice( |
---|
63 | source = nats_vocab, |
---|
64 | title = _(u'Nationality'), |
---|
65 | required = False, |
---|
66 | ) |
---|
67 | lga = schema.Choice( |
---|
68 | source = lgas_vocab, |
---|
69 | title = _(u'State/LGA (Nigerians only)'), |
---|
70 | required = False, |
---|
71 | ) |
---|
72 | perm_address = schema.Text( |
---|
73 | title = _(u'Permanent Address'), |
---|
74 | required = False, |
---|
75 | ) |
---|
76 | course1 = schema.Choice( |
---|
77 | title = _(u'1st Choice Course of Study'), |
---|
78 | source = AppCatCertificateSource(), |
---|
79 | required = True, |
---|
80 | ) |
---|
81 | course2 = schema.Choice( |
---|
82 | title = _(u'2nd Choice Course of Study'), |
---|
83 | source = AppCatCertificateSource(), |
---|
84 | required = False, |
---|
85 | ) |
---|
86 | hq_type = schema.Choice( |
---|
87 | title = _(u'Qualification Obtained'), |
---|
88 | required = False, |
---|
89 | readonly = False, |
---|
90 | vocabulary = high_qual, |
---|
91 | ) |
---|
92 | hq_matric_no = schema.TextLine( |
---|
93 | title = _(u'Former Matric Number'), |
---|
94 | required = False, |
---|
95 | readonly = False, |
---|
96 | ) |
---|
97 | hq_degree = schema.Choice( |
---|
98 | title = _(u'Class of Degree'), |
---|
99 | required = False, |
---|
100 | readonly = False, |
---|
101 | vocabulary = high_grade, |
---|
102 | ) |
---|
103 | hq_school = schema.TextLine( |
---|
104 | title = _(u'Institution Attended'), |
---|
105 | required = False, |
---|
106 | readonly = False, |
---|
107 | ) |
---|
108 | hq_session = schema.TextLine( |
---|
109 | title = _(u'Years Attended'), |
---|
110 | required = False, |
---|
111 | readonly = False, |
---|
112 | ) |
---|
113 | hq_disc = schema.TextLine( |
---|
114 | title = _(u'Discipline'), |
---|
115 | required = False, |
---|
116 | readonly = False, |
---|
117 | ) |
---|
118 | pp_school = schema.Choice( |
---|
119 | title = _(u'Qualification Obtained'), |
---|
120 | required = False, |
---|
121 | readonly = False, |
---|
122 | vocabulary = exam_types, |
---|
123 | ) |
---|
124 | #presently = schema.Bool( |
---|
125 | # title = _(u'Attending'), |
---|
126 | # required = False, |
---|
127 | # readonly = False, |
---|
128 | # ) |
---|
129 | presently_inst = schema.TextLine( |
---|
130 | title = _(u'If yes, name of institution'), |
---|
131 | required = False, |
---|
132 | readonly = False, |
---|
133 | ) |
---|
134 | nysc_year = schema.Int( |
---|
135 | title = _(u'Nysc Year'), |
---|
136 | required = False, |
---|
137 | readonly = False, |
---|
138 | ) |
---|
139 | nysc_lga = schema.Choice( |
---|
140 | source = lgas_vocab, |
---|
141 | title = _(u'Nysc Location'), |
---|
142 | required = False, |
---|
143 | ) |
---|
144 | employer = schema.TextLine( |
---|
145 | title = _(u'Employer'), |
---|
146 | required = False, |
---|
147 | readonly = False, |
---|
148 | ) |
---|
149 | emp_position = schema.TextLine( |
---|
150 | title = _(u'Employer Position'), |
---|
151 | required = False, |
---|
152 | readonly = False, |
---|
153 | ) |
---|
154 | emp_start = FormattedDate( |
---|
155 | title = _(u'Start Date'), |
---|
156 | required = False, |
---|
157 | readonly = False, |
---|
158 | ) |
---|
159 | emp_end = FormattedDate( |
---|
160 | title = _(u'End Date'), |
---|
161 | required = False, |
---|
162 | readonly = False, |
---|
163 | ) |
---|
164 | emp_reason = schema.TextLine( |
---|
165 | title = _(u'Reason for Leaving'), |
---|
166 | required = False, |
---|
167 | readonly = False, |
---|
168 | ) |
---|
169 | employer2 = schema.TextLine( |
---|
170 | title = _(u'2nd Employer'), |
---|
171 | required = False, |
---|
172 | readonly = False, |
---|
173 | ) |
---|
174 | emp2_position = schema.TextLine( |
---|
175 | title = _(u'2nd Employer Position'), |
---|
176 | required = False, |
---|
177 | readonly = False, |
---|
178 | ) |
---|
179 | emp2_start = FormattedDate( |
---|
180 | title = _(u'Start Date'), |
---|
181 | required = False, |
---|
182 | readonly = False, |
---|
183 | ) |
---|
184 | emp2_end = FormattedDate( |
---|
185 | title = _(u'End Date'), |
---|
186 | required = False, |
---|
187 | readonly = False, |
---|
188 | ) |
---|
189 | emp2_reason = schema.TextLine( |
---|
190 | title = _(u'Reason for Leaving'), |
---|
191 | required = False, |
---|
192 | readonly = False, |
---|
193 | ) |
---|
194 | notice = schema.Text( |
---|
195 | title = _(u'Notice'), |
---|
196 | required = False, |
---|
197 | readonly = False, |
---|
198 | ) |
---|
199 | screening_venue = schema.TextLine( |
---|
200 | title = _(u'Screening Venue'), |
---|
201 | required = False, |
---|
202 | readonly = False, |
---|
203 | ) |
---|
204 | screening_score = schema.Int( |
---|
205 | title = _(u'Screening Score'), |
---|
206 | required = False, |
---|
207 | readonly = False, |
---|
208 | ) |
---|
209 | course_admitted = schema.Choice( |
---|
210 | title = _(u'Admitted Course of Study'), |
---|
211 | source = CertificateSource(), |
---|
212 | required = False, |
---|
213 | readonly = False, |
---|
214 | ) |
---|
215 | |
---|
216 | |
---|
217 | # This ordering doesn't work properly. |
---|
218 | IPGApplicant[ |
---|
219 | 'nationality'].order = IApplicantBaseData['sex'].order |
---|
220 | IPGApplicant[ |
---|
221 | 'lga'].order = IPGApplicant['nationality'].order |
---|
222 | IPGApplicant[ |
---|
223 | 'student_id'].order = IPGApplicant['notice'].order |
---|
224 | |
---|
225 | |
---|
226 | class ICustomApplicant(IUGApplicant,IPGApplicant): |
---|
227 | """An interface for both types of applicants. |
---|
228 | |
---|
229 | """ |
---|
230 | |
---|
231 | def loggerInfo(ob_class, comment): |
---|
232 | """Adds an INFO message to the log file |
---|
233 | """ |
---|
234 | |
---|
235 | def createStudent(): |
---|
236 | """Create a student object from applicatnt data |
---|
237 | and copy applicant object. |
---|
238 | """ |
---|
239 | |
---|
240 | class IUGApplicantEdit(IUGApplicant): |
---|
241 | """An undergraduate applicant interface for editing. |
---|
242 | |
---|
243 | Here we can repeat the fields from base data and set the |
---|
244 | `required` and `readonly` attributes to True to further restrict |
---|
245 | the data access. Or we can allow only certain certificates to be |
---|
246 | selected by choosing the appropriate source. |
---|
247 | |
---|
248 | We cannot omit fields here. This has to be done in the |
---|
249 | respective form page. |
---|
250 | """ |
---|
251 | |
---|
252 | class IPGApplicantEdit(IPGApplicant): |
---|
253 | """A postgraduate applicant interface for editing. |
---|
254 | |
---|
255 | Here we can repeat the fields from base data and set the |
---|
256 | `required` and `readonly` attributes to True to further restrict |
---|
257 | the data access. Or we can allow only certain certificates to be |
---|
258 | selected by choosing the appropriate source. |
---|
259 | |
---|
260 | We cannot omit fields here. This has to be done in the |
---|
261 | respective form page. |
---|
262 | """ |
---|