1 | ## |
---|
2 | ## interfaces.py |
---|
3 | from zope.interface import Attribute, invariant |
---|
4 | from zope.interface.exceptions import Invalid |
---|
5 | from zope import schema |
---|
6 | from waeup.sirp.interfaces import IWAeUPObject |
---|
7 | from waeup.sirp.schema import TextLineChoice |
---|
8 | from waeup.sirp.university.vocabularies import CourseSource, study_modes |
---|
9 | from waeup.sirp.students.vocabularies import ( |
---|
10 | CertificateSource, academic_sessions_vocab, verdicts, StudyLevelSource, |
---|
11 | contextual_reg_num_source, contextual_mat_num_source, |
---|
12 | ) |
---|
13 | from waeup.sirp.payments.interfaces import IPaymentsContainer, IOnlinePayment |
---|
14 | |
---|
15 | class IStudentsContainer(IWAeUPObject): |
---|
16 | """An students container contains university students. |
---|
17 | |
---|
18 | """ |
---|
19 | |
---|
20 | def addStudent(student): |
---|
21 | """Add an IStudent object and subcontainers. |
---|
22 | |
---|
23 | """ |
---|
24 | |
---|
25 | def archive(id=None): |
---|
26 | """Create on-dist archive of students. |
---|
27 | |
---|
28 | If id is `None`, all students are archived. |
---|
29 | |
---|
30 | If id contains a single id string, only the respective |
---|
31 | students are archived. |
---|
32 | |
---|
33 | If id contains a list of id strings all of the respective |
---|
34 | students types are saved to disk. |
---|
35 | """ |
---|
36 | |
---|
37 | def clear(id=None, archive=True): |
---|
38 | """Remove students of type given by 'id'. |
---|
39 | |
---|
40 | Optionally archive the students. |
---|
41 | |
---|
42 | If id is `None`, all students are archived. |
---|
43 | |
---|
44 | If id contains a single id string, only the respective |
---|
45 | students are archived. |
---|
46 | |
---|
47 | If id contains a list of id strings all of the respective |
---|
48 | student types are saved to disk. |
---|
49 | |
---|
50 | If `archive` is ``False`` none of the archive-handling is done |
---|
51 | and respective students are simply removed from the |
---|
52 | database. |
---|
53 | """ |
---|
54 | |
---|
55 | class IStudentNavigation(IWAeUPObject): |
---|
56 | """Interface needed for student navigation. |
---|
57 | """ |
---|
58 | |
---|
59 | def getStudent(): |
---|
60 | """Return student object. |
---|
61 | """ |
---|
62 | |
---|
63 | class IStudentPasswordSetting(IWAeUPObject): |
---|
64 | """Data needed for password setting. |
---|
65 | """ |
---|
66 | name = schema.TextLine( |
---|
67 | title = u'Full Name', |
---|
68 | default = u'Nobody', |
---|
69 | required = True, |
---|
70 | readonly = True |
---|
71 | ) |
---|
72 | |
---|
73 | password = schema.Password( |
---|
74 | title = u'New password', |
---|
75 | required = False, |
---|
76 | ) |
---|
77 | |
---|
78 | password_repeat = schema.Password( |
---|
79 | title = u'Retype new password', |
---|
80 | required = False, |
---|
81 | ) |
---|
82 | |
---|
83 | @invariant |
---|
84 | def passwords_match(obj): |
---|
85 | if obj.password == obj.password_repeat: |
---|
86 | return |
---|
87 | raise Invalid('passwords do not match') |
---|
88 | |
---|
89 | class IStudentBase(IWAeUPObject): |
---|
90 | """Representation of student base data. |
---|
91 | """ |
---|
92 | history = Attribute('Object history, a list of messages.') |
---|
93 | state = Attribute('Returns the registration state of a student') |
---|
94 | password = Attribute('Encrypted password of a student') |
---|
95 | certificate = Attribute('The certificate of any chosen study course') |
---|
96 | |
---|
97 | def loggerInfo(ob_class, comment): |
---|
98 | """Adds an INFO message to the log file |
---|
99 | """ |
---|
100 | |
---|
101 | student_id = schema.TextLine( |
---|
102 | title = u'Student ID', |
---|
103 | required = False, |
---|
104 | ) |
---|
105 | |
---|
106 | fullname = schema.TextLine( |
---|
107 | title = u'Full Name', |
---|
108 | default = None, |
---|
109 | required = True, |
---|
110 | ) |
---|
111 | |
---|
112 | reg_number = TextLineChoice( |
---|
113 | title = u'Registration Number', |
---|
114 | default = None, |
---|
115 | required = True, |
---|
116 | readonly = False, |
---|
117 | source = contextual_reg_num_source, |
---|
118 | ) |
---|
119 | |
---|
120 | matric_number = TextLineChoice( |
---|
121 | title = u'Matriculation Number', |
---|
122 | #default = u'', |
---|
123 | required = False, |
---|
124 | readonly = False, |
---|
125 | source = contextual_mat_num_source, |
---|
126 | ) |
---|
127 | |
---|
128 | adm_code = schema.TextLine( |
---|
129 | title = u'PWD Access Code', |
---|
130 | default = u'', |
---|
131 | required = False, |
---|
132 | readonly = True, |
---|
133 | ) |
---|
134 | |
---|
135 | entry_mode = schema.Choice( |
---|
136 | title = u'Study Mode', |
---|
137 | vocabulary = study_modes, |
---|
138 | default = u'ug_ft', |
---|
139 | required = True, |
---|
140 | readonly = False, |
---|
141 | ) |
---|
142 | |
---|
143 | class IStudentClearance(IWAeUPObject): |
---|
144 | """Representation of student clearance data. |
---|
145 | """ |
---|
146 | |
---|
147 | date_of_birth = schema.Date( |
---|
148 | title = u'Date of Birth', |
---|
149 | required = True, |
---|
150 | ) |
---|
151 | |
---|
152 | clearance_locked = schema.Bool( |
---|
153 | title = u'Clearance form locked', |
---|
154 | default = False, |
---|
155 | ) |
---|
156 | |
---|
157 | clr_code = schema.TextLine( |
---|
158 | title = u'CLR Access Code', |
---|
159 | default = u'', |
---|
160 | required = False, |
---|
161 | readonly = True, |
---|
162 | ) |
---|
163 | |
---|
164 | class IStudentPersonal(IWAeUPObject): |
---|
165 | """Representation of student personal data. |
---|
166 | """ |
---|
167 | |
---|
168 | perm_address = schema.Text( |
---|
169 | title = u'Permanent Address', |
---|
170 | required = False, |
---|
171 | ) |
---|
172 | |
---|
173 | class IStudent(IStudentBase,IStudentClearance,IStudentPersonal): |
---|
174 | """Representation of a student. |
---|
175 | """ |
---|
176 | |
---|
177 | class IStudentUpdateByRegNo(IStudent): |
---|
178 | """Representation of a student. Skip regular reg_number validation. |
---|
179 | """ |
---|
180 | |
---|
181 | reg_number = schema.TextLine( |
---|
182 | title = u'Registration Number', |
---|
183 | default = None, |
---|
184 | required = False, |
---|
185 | ) |
---|
186 | |
---|
187 | class IStudentUpdateByMatricNo(IStudent): |
---|
188 | """Representation of a student. Skip regular matric_number validation. |
---|
189 | """ |
---|
190 | |
---|
191 | matric_number = schema.TextLine( |
---|
192 | title = u'Matriculation Number', |
---|
193 | default = None, |
---|
194 | required = False, |
---|
195 | ) |
---|
196 | |
---|
197 | class IStudentStudyCourse(IWAeUPObject): |
---|
198 | """A container for student study levels. |
---|
199 | |
---|
200 | """ |
---|
201 | |
---|
202 | certificate = schema.Choice( |
---|
203 | title = u'Certificate', |
---|
204 | source = CertificateSource(), |
---|
205 | default = None, |
---|
206 | required = True, |
---|
207 | ) |
---|
208 | |
---|
209 | current_session = schema.Choice( |
---|
210 | title = u'Current Session', |
---|
211 | source = academic_sessions_vocab, |
---|
212 | default = None, |
---|
213 | required = True, |
---|
214 | ) |
---|
215 | |
---|
216 | current_level = schema.Choice( |
---|
217 | title = u'Current Level', |
---|
218 | source = StudyLevelSource(), |
---|
219 | default = None, |
---|
220 | required = False, |
---|
221 | ) |
---|
222 | |
---|
223 | current_verdict = schema.Choice( |
---|
224 | title = u'Current Verdict', |
---|
225 | source = verdicts, |
---|
226 | default = '0', |
---|
227 | required = False, |
---|
228 | ) |
---|
229 | |
---|
230 | previous_verdict = schema.Choice( |
---|
231 | title = u'Previous Verdict', |
---|
232 | source = verdicts, |
---|
233 | default = '0', |
---|
234 | required = False, |
---|
235 | ) |
---|
236 | |
---|
237 | class IStudentStudyCourseImport(IStudentStudyCourse): |
---|
238 | """A container for student study levels. |
---|
239 | |
---|
240 | """ |
---|
241 | |
---|
242 | current_level = schema.Int( |
---|
243 | title = u'Current Level', |
---|
244 | default = None, |
---|
245 | ) |
---|
246 | |
---|
247 | class IStudentStudyLevel(IWAeUPObject): |
---|
248 | """A container for course tickets. |
---|
249 | |
---|
250 | """ |
---|
251 | level = Attribute('The level code') |
---|
252 | validation_date = Attribute('The date of validation') |
---|
253 | validated_by = Attribute('User Id of course adviser') |
---|
254 | |
---|
255 | level_session = schema.Choice( |
---|
256 | title = u'Session', |
---|
257 | source = academic_sessions_vocab, |
---|
258 | default = None, |
---|
259 | required = True, |
---|
260 | ) |
---|
261 | |
---|
262 | level_verdict = schema.Choice( |
---|
263 | title = u'Verdict', |
---|
264 | source = verdicts, |
---|
265 | default = '0', |
---|
266 | required = False, |
---|
267 | ) |
---|
268 | |
---|
269 | class ICourseTicket(IWAeUPObject): |
---|
270 | """A course ticket. |
---|
271 | |
---|
272 | """ |
---|
273 | code = Attribute('code of the original course') |
---|
274 | title = Attribute('title of the original course') |
---|
275 | credits = Attribute('credits of the original course') |
---|
276 | passmark = Attribute('passmark of the original course') |
---|
277 | semester = Attribute('semester of the original course') |
---|
278 | faculty = Attribute('faculty of the original course') |
---|
279 | department = Attribute('department of the original course') |
---|
280 | |
---|
281 | core_or_elective = schema.Bool( |
---|
282 | title = u'Mandatory', |
---|
283 | default = False, |
---|
284 | required = False, |
---|
285 | readonly = False, |
---|
286 | ) |
---|
287 | |
---|
288 | score = schema.Int( |
---|
289 | title = u'Score', |
---|
290 | default = 0, |
---|
291 | required = False, |
---|
292 | readonly = False, |
---|
293 | ) |
---|
294 | |
---|
295 | automatic = schema.Bool( |
---|
296 | title = u'Automatical Creation', |
---|
297 | default = False, |
---|
298 | required = False, |
---|
299 | readonly = True, |
---|
300 | ) |
---|
301 | |
---|
302 | class ICourseTicketAdd(ICourseTicket): |
---|
303 | """An interface for adding course tickets |
---|
304 | |
---|
305 | """ |
---|
306 | course = schema.Choice( |
---|
307 | title = u'Course', |
---|
308 | source = CourseSource(), |
---|
309 | readonly = False, |
---|
310 | ) |
---|
311 | |
---|
312 | class IStudentAccommodation(IWAeUPObject): |
---|
313 | """A container for student accommodation objects. |
---|
314 | |
---|
315 | """ |
---|
316 | |
---|
317 | class IStudentPaymentsContainer(IPaymentsContainer): |
---|
318 | """A container for student payment objects. |
---|
319 | |
---|
320 | """ |
---|
321 | |
---|
322 | class IStudentOnlinePayment(IOnlinePayment): |
---|
323 | """A student payment via payment gateways. |
---|
324 | |
---|
325 | """ |
---|
326 | |
---|
327 | p_session = schema.Choice( |
---|
328 | title = u'Payment Session', |
---|
329 | source = academic_sessions_vocab, |
---|
330 | required = False, |
---|
331 | ) |
---|
332 | |
---|
333 | IStudentOnlinePayment['p_session'].order = IStudentOnlinePayment[ |
---|
334 | 'p_item'].order |
---|
335 | |
---|
336 | # Interfaces for students only |
---|
337 | |
---|
338 | class IStudentClearanceEdit(IStudentClearance): |
---|
339 | """Interface needed for restricted editing of student clearance data. |
---|
340 | """ |
---|
341 | |
---|
342 | class IStudentPersonalEdit(IStudentPersonal): |
---|
343 | """Interface needed for restricted editing of student personal data. |
---|
344 | """ |
---|