1 | ## $Id: interfaces.py 15143 2018-09-18 10:20:39Z 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 | #from datetime import datetime |
---|
19 | from zope.component import getUtility |
---|
20 | from zope.interface import Attribute, Interface |
---|
21 | from zope import schema |
---|
22 | from zc.sourcefactory.contextual import BasicContextualSourceFactory |
---|
23 | from waeup.kofa.browser.interfaces import IStudentNavigationBase |
---|
24 | from waeup.kofa.interfaces import ( |
---|
25 | IKofaObject, academic_sessions_vocab, validate_email, ICSVExporter, |
---|
26 | ContextualDictSourceFactoryBase, IKofaUtils) |
---|
27 | from waeup.kofa.interfaces import MessageFactory as _ |
---|
28 | from waeup.kofa.schema import TextLineChoice, FormattedDate, PhoneNumber |
---|
29 | from waeup.kofa.students.vocabularies import ( |
---|
30 | StudyLevelSource, contextual_reg_num_source, contextual_mat_num_source, |
---|
31 | GenderSource, nats_vocab |
---|
32 | ) |
---|
33 | from waeup.kofa.payments.interfaces import ( |
---|
34 | IPaymentsContainer, IOnlinePayment) |
---|
35 | from waeup.kofa.university.vocabularies import ( |
---|
36 | CourseSource, StudyModeSource, CertificateSource, |
---|
37 | SemesterSource, CourseCategorySource |
---|
38 | ) |
---|
39 | |
---|
40 | class PreviousPaymentCategorySource(ContextualDictSourceFactoryBase): |
---|
41 | """A source that delivers all selectable categories of previous session |
---|
42 | payments. |
---|
43 | """ |
---|
44 | #: name of dict to deliver from kofa utils. |
---|
45 | DICT_NAME = 'PREVIOUS_PAYMENT_CATEGORIES' |
---|
46 | |
---|
47 | class BalancePaymentCategorySource(ContextualDictSourceFactoryBase): |
---|
48 | """A source that delivers all selectable items of balance payments. |
---|
49 | """ |
---|
50 | #: name of dict to deliver from kofa utils. |
---|
51 | DICT_NAME = 'BALANCE_PAYMENT_CATEGORIES' |
---|
52 | |
---|
53 | # VerdictSource can't be placed into the vocabularies module because it |
---|
54 | # requires importing IStudentsUtils which then leads to circular imports. |
---|
55 | class VerdictSource(BasicContextualSourceFactory): |
---|
56 | """A verdicts source delivers all verdicts provided |
---|
57 | in the portal. |
---|
58 | """ |
---|
59 | def getValues(self, context): |
---|
60 | verdicts_dict = getUtility(IKofaUtils).VERDICTS_DICT |
---|
61 | return sorted(verdicts_dict.keys()) |
---|
62 | |
---|
63 | def getToken(self, context, value): |
---|
64 | return value |
---|
65 | |
---|
66 | def getTitle(self, context, value): |
---|
67 | verdicts_dict = getUtility(IKofaUtils).VERDICTS_DICT |
---|
68 | if value != '0': |
---|
69 | return verdicts_dict[value] + ' (%s)' % value |
---|
70 | return verdicts_dict[value] |
---|
71 | |
---|
72 | |
---|
73 | class IStudentsUtils(Interface): |
---|
74 | """A collection of methods which are subject to customization. |
---|
75 | """ |
---|
76 | def setReturningData(student): |
---|
77 | """ This method defines what happens after school fee payment |
---|
78 | depending on the student's senate verdict. |
---|
79 | |
---|
80 | In the base configuration current level is always increased |
---|
81 | by 100 no matter which verdict has been assigned. |
---|
82 | """ |
---|
83 | |
---|
84 | def setPaymentDetails(category, student, previous_session=None, |
---|
85 | previous_level=None,): |
---|
86 | """Create Payment object and set the payment data of a student for |
---|
87 | the payment category specified. |
---|
88 | """ |
---|
89 | |
---|
90 | def increaseMatricInteger(student): |
---|
91 | """Increase counter for matric numbers. |
---|
92 | |
---|
93 | This counter can be a centrally stored attribute or an attribute of |
---|
94 | faculties, departments or certificates. In the base package the counter |
---|
95 | is as an attribute of the site configuration object. |
---|
96 | """ |
---|
97 | |
---|
98 | def constructMatricNumber(student): |
---|
99 | """Fetch the matric number counter which fits the student and |
---|
100 | construct the new matric number of the student. |
---|
101 | |
---|
102 | In the base package the counter is returned which is as an attribute |
---|
103 | of the site configuration object. |
---|
104 | """ |
---|
105 | |
---|
106 | def setMatricNumber(student): |
---|
107 | """Set matriculation number of student. |
---|
108 | |
---|
109 | If the student's matric number is unset a new matric number is |
---|
110 | constructed according to the matriculation number construction rules |
---|
111 | defined in the constructMatricNumber method. The new matric number is |
---|
112 | set, the students catalog updated. The corresponding matric number |
---|
113 | counter is increased by one. |
---|
114 | |
---|
115 | This method is tested but not used in the base package. It can |
---|
116 | be used in custom packages by adding respective views |
---|
117 | and by customizing increaseMatricInteger and constructMatricNumber |
---|
118 | according to the university's matriculation number construction rules. |
---|
119 | |
---|
120 | The method can be disabled by setting the counter to zero. |
---|
121 | """ |
---|
122 | |
---|
123 | def getAccommodation_details(student): |
---|
124 | """Determine the accommodation dates of a student. |
---|
125 | """ |
---|
126 | |
---|
127 | def selectBed(available_beds): |
---|
128 | """Select a bed from a list of available beds. |
---|
129 | In the standard configuration we select the first bed found, |
---|
130 | but can also randomize the selection if we like. |
---|
131 | """ |
---|
132 | |
---|
133 | def getDegreeClassNumber(level_obj): |
---|
134 | """Get degree class number (used for SessionResultsPresentation |
---|
135 | reports). |
---|
136 | """ |
---|
137 | |
---|
138 | def getPDFCreator(context): |
---|
139 | """Get some IPDFCreator instance suitable for use with `context`. |
---|
140 | """ |
---|
141 | |
---|
142 | def renderPDF(view, subject='', filename='slip.pdf',): |
---|
143 | """Render pdf slips for various pages. |
---|
144 | """ |
---|
145 | |
---|
146 | def renderPDFAdmissionLetter(view, student=None, omit_fields=(), |
---|
147 | pre_text=None, post_text=None,): |
---|
148 | """Render pdf admission letter. |
---|
149 | """ |
---|
150 | |
---|
151 | def renderPDFTranscript(view, filename, student, |
---|
152 | studentview, note, signatures, sigs_in_footer, |
---|
153 | show_scans, topMargin, omit_fields, |
---|
154 | tableheader, no_passport): |
---|
155 | """Render pdf slip of a transcripts. |
---|
156 | """ |
---|
157 | |
---|
158 | def renderPDFCourseticketsOverview( |
---|
159 | view, session, data, lecturers, orientation): |
---|
160 | """Render pdf slip of course tickets for a lecturer. |
---|
161 | """ |
---|
162 | |
---|
163 | def warnCreditsOOR(studylevel, course=None): |
---|
164 | """Return message if credits are out of range. In the base |
---|
165 | package only maximum credits is set. |
---|
166 | """ |
---|
167 | |
---|
168 | def getBedCoordinates(bedticket): |
---|
169 | """Return descriptive bed coordinates. |
---|
170 | This method can be used to customize the `display_coordinates` |
---|
171 | property method in order to display a |
---|
172 | customary description of the bed space. |
---|
173 | """ |
---|
174 | |
---|
175 | def clearance_disabled_message(student): |
---|
176 | """Render message if clearance is disabled. |
---|
177 | """ |
---|
178 | |
---|
179 | class IStudentsContainer(IKofaObject): |
---|
180 | """A students container contains university students. |
---|
181 | """ |
---|
182 | def addStudent(student): |
---|
183 | """Add an IStudent object and subcontainers. |
---|
184 | """ |
---|
185 | |
---|
186 | unique_student_id = Attribute('A unique student id') |
---|
187 | |
---|
188 | class IStudentNavigation(IStudentNavigationBase): |
---|
189 | """Interface needed for navigation and logging. This interface is |
---|
190 | implemented by all content classes in the students section. |
---|
191 | """ |
---|
192 | student = Attribute('Student object of context') |
---|
193 | |
---|
194 | def writeLogMessage(view, message): |
---|
195 | """Add an INFO message to students.log. |
---|
196 | """ |
---|
197 | |
---|
198 | class IStudentBase(IKofaObject): |
---|
199 | """Representation of student base data. |
---|
200 | """ |
---|
201 | history = Attribute('Object history, a list of messages') |
---|
202 | state = Attribute('Registration state') |
---|
203 | translated_state = Attribute('Real name of the registration state') |
---|
204 | certcode = Attribute('Certificate code of any chosen study course') |
---|
205 | depcode = Attribute('Department code of any chosen study course') |
---|
206 | faccode = Attribute('Faculty code of any chosen study course') |
---|
207 | entry_session = Attribute('Entry session') |
---|
208 | current_session = Attribute('Current session') |
---|
209 | current_level = Attribute('Current level') |
---|
210 | current_mode = Attribute('Current mode') |
---|
211 | current_verdict = Attribute('Current verdict') |
---|
212 | fullname = Attribute('All name parts separated by hyphens') |
---|
213 | display_fullname = Attribute('Fullname as displayed on pages') |
---|
214 | is_postgrad = Attribute('True if postgraduate student') |
---|
215 | is_special_postgrad = Attribute('True if special postgraduate student') |
---|
216 | is_fresh = Attribute('True if fresh student') |
---|
217 | before_payment = Attribute('True if no previous payment has to be made') |
---|
218 | personal_data_expired = Attribute('True if personal data expired') |
---|
219 | transcript_enabled = Attribute('True if transcript processing is enabled') |
---|
220 | clearance_locked = Attribute('True if clearance form is locked') |
---|
221 | studycourse_locked = Attribute( |
---|
222 | 'True if nobody is allowed to change studycourse, studylecel or ' |
---|
223 | 'course ticket data, neither through the UI nor via import') |
---|
224 | |
---|
225 | password = Attribute('Encrypted password') |
---|
226 | temp_password = Attribute('Dictionary with user name, timestamp and encrypted password') |
---|
227 | |
---|
228 | suspended = schema.Bool( |
---|
229 | title = _(u'Account suspended'), |
---|
230 | default = False, |
---|
231 | required = False, |
---|
232 | ) |
---|
233 | |
---|
234 | suspended_comment = schema.Text( |
---|
235 | title = _(u"Reasons for Deactivation"), |
---|
236 | required = False, |
---|
237 | description = _( |
---|
238 | u'This message will be shown if and only if deactivated ' |
---|
239 | 'students try to login.'), |
---|
240 | ) |
---|
241 | |
---|
242 | flash_notice = schema.TextLine( |
---|
243 | title = _(u'Flash Notice'), |
---|
244 | required = False, |
---|
245 | readonly = False, |
---|
246 | description = _( |
---|
247 | u'This single-line message will be shown in a flash box.'), |
---|
248 | ) |
---|
249 | |
---|
250 | student_id = schema.TextLine( |
---|
251 | title = _(u'Student Id'), |
---|
252 | required = False, |
---|
253 | ) |
---|
254 | |
---|
255 | firstname = schema.TextLine( |
---|
256 | title = _(u'First Name'), |
---|
257 | required = True, |
---|
258 | ) |
---|
259 | |
---|
260 | middlename = schema.TextLine( |
---|
261 | title = _(u'Middle Name'), |
---|
262 | required = False, |
---|
263 | ) |
---|
264 | |
---|
265 | lastname = schema.TextLine( |
---|
266 | title = _(u'Last Name (Surname)'), |
---|
267 | required = True, |
---|
268 | ) |
---|
269 | |
---|
270 | sex = schema.Choice( |
---|
271 | title = _(u'Sex'), |
---|
272 | source = GenderSource(), |
---|
273 | required = True, |
---|
274 | ) |
---|
275 | |
---|
276 | reg_number = TextLineChoice( |
---|
277 | title = _(u'Registration Number'), |
---|
278 | required = True, |
---|
279 | readonly = False, |
---|
280 | source = contextual_reg_num_source, |
---|
281 | ) |
---|
282 | |
---|
283 | matric_number = TextLineChoice( |
---|
284 | title = _(u'Matriculation Number'), |
---|
285 | required = False, |
---|
286 | readonly = False, |
---|
287 | source = contextual_mat_num_source, |
---|
288 | ) |
---|
289 | |
---|
290 | adm_code = schema.TextLine( |
---|
291 | title = _(u'PWD Activation Code'), |
---|
292 | required = False, |
---|
293 | readonly = False, |
---|
294 | ) |
---|
295 | |
---|
296 | email = schema.ASCIILine( |
---|
297 | title = _(u'Email'), |
---|
298 | required = False, |
---|
299 | constraint=validate_email, |
---|
300 | ) |
---|
301 | phone = PhoneNumber( |
---|
302 | title = _(u'Phone'), |
---|
303 | required = False, |
---|
304 | ) |
---|
305 | |
---|
306 | def setTempPassword(user, password): |
---|
307 | """Set a temporary password (LDAP-compatible) SSHA encoded for |
---|
308 | officers. |
---|
309 | """ |
---|
310 | |
---|
311 | def getTempPassword(): |
---|
312 | """Check if a temporary password has been set and if it |
---|
313 | is not expired. Return the temporary password if valid, |
---|
314 | None otherwise. Unset the temporary password if expired. |
---|
315 | """ |
---|
316 | |
---|
317 | def transfer(certificate, current_session, |
---|
318 | current_level, current_verdict): |
---|
319 | """ Creates a new studycourse and backups the old one. |
---|
320 | """ |
---|
321 | |
---|
322 | def revert_transfer(): |
---|
323 | """ Revert previous transfer. |
---|
324 | """ |
---|
325 | |
---|
326 | class IUGStudentClearance(IKofaObject): |
---|
327 | """Representation of undergraduate student clearance data. |
---|
328 | """ |
---|
329 | officer_comment = schema.Text( |
---|
330 | title = _(u"Officer's Comment"), |
---|
331 | required = False, |
---|
332 | ) |
---|
333 | |
---|
334 | clr_code = schema.TextLine( |
---|
335 | title = _(u'CLR Activation Code'), |
---|
336 | required = False, |
---|
337 | readonly = False, |
---|
338 | ) |
---|
339 | |
---|
340 | date_of_birth = FormattedDate( |
---|
341 | title = _(u'Date of Birth'), |
---|
342 | required = True, |
---|
343 | show_year = True, |
---|
344 | ) |
---|
345 | |
---|
346 | nationality = schema.Choice( |
---|
347 | vocabulary = nats_vocab, |
---|
348 | title = _(u'Nationality'), |
---|
349 | required = False, |
---|
350 | ) |
---|
351 | |
---|
352 | class IPGStudentClearance(IUGStudentClearance): |
---|
353 | """Representation of postgraduate student clearance data. |
---|
354 | """ |
---|
355 | employer = schema.TextLine( |
---|
356 | title = _(u'Employer'), |
---|
357 | required = False, |
---|
358 | readonly = False, |
---|
359 | ) |
---|
360 | |
---|
361 | class IStudentPersonal(IKofaObject): |
---|
362 | """Representation of student personal data. |
---|
363 | """ |
---|
364 | personal_updated = schema.Datetime( |
---|
365 | title = _(u'Updated'), |
---|
366 | required = False, |
---|
367 | readonly = False, |
---|
368 | ) |
---|
369 | |
---|
370 | perm_address = schema.Text( |
---|
371 | title = _(u'Permanent Address'), |
---|
372 | required = False, |
---|
373 | ) |
---|
374 | |
---|
375 | class IStudentTranscript(IKofaObject): |
---|
376 | """Representation of student transcript data. |
---|
377 | """ |
---|
378 | |
---|
379 | transcript_comment = schema.Text( |
---|
380 | title = _(u'Comment'), |
---|
381 | required = False, |
---|
382 | ) |
---|
383 | |
---|
384 | transcript_signees = schema.Text( |
---|
385 | title = _(u'Signees'), |
---|
386 | required = False, |
---|
387 | ) |
---|
388 | |
---|
389 | |
---|
390 | class IStudent(IStudentBase,IUGStudentClearance,IPGStudentClearance, |
---|
391 | IStudentPersonal, IStudentTranscript): |
---|
392 | """Representation of a student. |
---|
393 | """ |
---|
394 | |
---|
395 | class IStudentPersonalEdit(IStudentPersonal): |
---|
396 | """Interface for editing personal data by students. |
---|
397 | Here we can repeat the fields from IStudentPersonal and set the |
---|
398 | `required` if necessary. |
---|
399 | """ |
---|
400 | |
---|
401 | perm_address = schema.Text( |
---|
402 | title = _(u'Permanent Address'), |
---|
403 | required = True, |
---|
404 | ) |
---|
405 | |
---|
406 | class IStudentUpdateByRegNo(IStudent): |
---|
407 | """Representation of a student. Skip regular reg_number validation. |
---|
408 | """ |
---|
409 | reg_number = schema.TextLine( |
---|
410 | title = _(u'Registration Number'), |
---|
411 | required = False, |
---|
412 | ) |
---|
413 | |
---|
414 | class IStudentUpdateByMatricNo(IStudent): |
---|
415 | """Representation of a student. Skip regular matric_number validation. |
---|
416 | """ |
---|
417 | matric_number = schema.TextLine( |
---|
418 | title = _(u'Matriculation Number'), |
---|
419 | required = False, |
---|
420 | ) |
---|
421 | |
---|
422 | class IStudentRequestPW(IStudent): |
---|
423 | """Representation of a student for first-time password request. |
---|
424 | This interface is used when students use the requestpw page to |
---|
425 | login for the the first time. |
---|
426 | """ |
---|
427 | number = schema.TextLine( |
---|
428 | title = _(u'Registr. or Matric. Number'), |
---|
429 | required = True, |
---|
430 | ) |
---|
431 | |
---|
432 | firstname = schema.TextLine( |
---|
433 | title = _(u'First Name'), |
---|
434 | required = True, |
---|
435 | ) |
---|
436 | |
---|
437 | email = schema.ASCIILine( |
---|
438 | title = _(u'Email Address'), |
---|
439 | required = True, |
---|
440 | constraint=validate_email, |
---|
441 | ) |
---|
442 | |
---|
443 | class IStudentStudyCourse(IKofaObject): |
---|
444 | """Representation of student study course data. |
---|
445 | """ |
---|
446 | next_session_allowed = Attribute('True if the student can proceed to next session') |
---|
447 | is_postgrad = Attribute('True if student is postgraduate student') |
---|
448 | is_current = Attribute('True if the study course is the current course of studies') |
---|
449 | is_previous = Attribute('True if the study course is the previous course of studies') |
---|
450 | |
---|
451 | certificate = schema.Choice( |
---|
452 | title = _(u'Certificate'), |
---|
453 | source = CertificateSource(), |
---|
454 | required = False, |
---|
455 | ) |
---|
456 | |
---|
457 | entry_mode = schema.Choice( |
---|
458 | title = _(u'Entry Mode'), |
---|
459 | source = StudyModeSource(), |
---|
460 | required = True, |
---|
461 | readonly = False, |
---|
462 | ) |
---|
463 | |
---|
464 | entry_session = schema.Choice( |
---|
465 | title = _(u'Entry Session'), |
---|
466 | source = academic_sessions_vocab, |
---|
467 | #default = datetime.now().year, |
---|
468 | required = True, |
---|
469 | readonly = False, |
---|
470 | ) |
---|
471 | |
---|
472 | current_session = schema.Choice( |
---|
473 | title = _(u'Current Session'), |
---|
474 | source = academic_sessions_vocab, |
---|
475 | required = True, |
---|
476 | readonly = False, |
---|
477 | ) |
---|
478 | |
---|
479 | current_level = schema.Choice( |
---|
480 | title = _(u'Current Level'), |
---|
481 | source = StudyLevelSource(), |
---|
482 | required = False, |
---|
483 | readonly = False, |
---|
484 | ) |
---|
485 | |
---|
486 | current_verdict = schema.Choice( |
---|
487 | title = _(u'Current Verdict'), |
---|
488 | source = VerdictSource(), |
---|
489 | default = '0', |
---|
490 | required = False, |
---|
491 | ) |
---|
492 | |
---|
493 | previous_verdict = schema.Choice( |
---|
494 | title = _(u'Previous Verdict'), |
---|
495 | source = VerdictSource(), |
---|
496 | default = '0', |
---|
497 | required = False, |
---|
498 | ) |
---|
499 | |
---|
500 | def addStudentStudyLevel(cert, studylevel): |
---|
501 | """Add a study level object. |
---|
502 | """ |
---|
503 | |
---|
504 | def getTranscriptData(): |
---|
505 | """Get a sorted list of dicts with level and course ticket data. |
---|
506 | This method is used for transcripts. |
---|
507 | """ |
---|
508 | |
---|
509 | class IStudentStudyCourseTransfer(IStudentStudyCourse): |
---|
510 | """An interface used for student transfers. |
---|
511 | """ |
---|
512 | certificate = schema.Choice( |
---|
513 | title = _(u'Certificate'), |
---|
514 | source = CertificateSource(), |
---|
515 | required = True, |
---|
516 | ) |
---|
517 | |
---|
518 | current_level = schema.Choice( |
---|
519 | title = _(u'Current Level'), |
---|
520 | source = StudyLevelSource(), |
---|
521 | required = True, |
---|
522 | readonly = False, |
---|
523 | ) |
---|
524 | |
---|
525 | entry_session = schema.Choice( |
---|
526 | title = _(u'Entry Session'), |
---|
527 | source = academic_sessions_vocab, |
---|
528 | #default = datetime.now().year, |
---|
529 | required = False, |
---|
530 | readonly = False, |
---|
531 | ) |
---|
532 | |
---|
533 | |
---|
534 | IStudentStudyCourseTransfer['certificate'].order = IStudentStudyCourse[ |
---|
535 | 'certificate'].order |
---|
536 | IStudentStudyCourseTransfer['current_level'].order = IStudentStudyCourse[ |
---|
537 | 'current_level'].order |
---|
538 | |
---|
539 | class IStudentStudyCourseTranscript(IKofaObject): |
---|
540 | """An interface for student transcripts. |
---|
541 | """ |
---|
542 | entry_mode = schema.Choice( |
---|
543 | title = _(u'Entry Mode'), |
---|
544 | source = StudyModeSource(), |
---|
545 | required = True, |
---|
546 | readonly = False, |
---|
547 | ) |
---|
548 | |
---|
549 | entry_session = schema.Choice( |
---|
550 | title = _(u'Entry Session'), |
---|
551 | source = academic_sessions_vocab, |
---|
552 | #default = datetime.now().year, |
---|
553 | required = True, |
---|
554 | readonly = False, |
---|
555 | ) |
---|
556 | |
---|
557 | class IStudentVerdictUpdate(IKofaObject): |
---|
558 | """A interface for verdict imports. |
---|
559 | """ |
---|
560 | current_verdict = schema.Choice( |
---|
561 | title = _(u'Current Verdict'), |
---|
562 | source = VerdictSource(), |
---|
563 | required = True, |
---|
564 | ) |
---|
565 | |
---|
566 | current_session = schema.Choice( |
---|
567 | title = _(u'Current Session'), |
---|
568 | source = academic_sessions_vocab, |
---|
569 | required = True, |
---|
570 | ) |
---|
571 | |
---|
572 | current_level = schema.Choice( |
---|
573 | title = _(u'Current Level'), |
---|
574 | source = StudyLevelSource(), |
---|
575 | required = True, |
---|
576 | ) |
---|
577 | |
---|
578 | bypass_validation = schema.Bool( |
---|
579 | title = _(u'Bypass validation'), |
---|
580 | required = False, |
---|
581 | ) |
---|
582 | |
---|
583 | validated_by = schema.TextLine( |
---|
584 | title = _(u'Validated by'), |
---|
585 | required = False, |
---|
586 | ) |
---|
587 | |
---|
588 | class IStudentStudyLevel(IKofaObject): |
---|
589 | """A representation of student study level data. |
---|
590 | """ |
---|
591 | certcode = Attribute('The certificate code of the study course') |
---|
592 | is_current_level = Attribute('True if level is current level of the student') |
---|
593 | level_title = Attribute('Level title from source') |
---|
594 | getSessionString = Attribute('Session title from source') |
---|
595 | number_of_tickets = Attribute('Number of tickets contained in this level') |
---|
596 | passed_params = Attribute('Information about passed and failed courses') |
---|
597 | gpa_params_rectified = Attribute('Corrected sessional GPA parameters') |
---|
598 | gpa_params = Attribute('GPA parameters for this level.') |
---|
599 | cumulative_params = Attribute( |
---|
600 | 'Cumulative GPA and other cumulative parameters for this level') |
---|
601 | course_registration_forbidden = Attribute( |
---|
602 | 'Return error message if course registration is forbidden') |
---|
603 | |
---|
604 | level = schema.Choice( |
---|
605 | title = _(u'Level'), |
---|
606 | source = StudyLevelSource(), |
---|
607 | required = True, |
---|
608 | readonly = False, |
---|
609 | ) |
---|
610 | |
---|
611 | level_session = schema.Choice( |
---|
612 | title = _(u'Session'), |
---|
613 | source = academic_sessions_vocab, |
---|
614 | required = True, |
---|
615 | ) |
---|
616 | |
---|
617 | level_verdict = schema.Choice( |
---|
618 | title = _(u'Verdict'), |
---|
619 | source = VerdictSource(), |
---|
620 | default = '0', |
---|
621 | required = False, |
---|
622 | ) |
---|
623 | |
---|
624 | validated_by = schema.TextLine( |
---|
625 | title = _(u'Validated by'), |
---|
626 | default = None, |
---|
627 | required = False, |
---|
628 | ) |
---|
629 | |
---|
630 | validation_date = schema.Datetime( |
---|
631 | title = _(u'Validation Date'), |
---|
632 | required = False, |
---|
633 | readonly = False, |
---|
634 | ) |
---|
635 | |
---|
636 | total_credits = schema.Int( |
---|
637 | title = _(u'Total Credits'), |
---|
638 | required = False, |
---|
639 | readonly = True, |
---|
640 | ) |
---|
641 | |
---|
642 | gpa = schema.TextLine( |
---|
643 | title = _(u'Unrectified GPA'), |
---|
644 | required = False, |
---|
645 | readonly = True, |
---|
646 | ) |
---|
647 | |
---|
648 | def addCourseTicket(ticket, course): |
---|
649 | """Add a course ticket object. |
---|
650 | """ |
---|
651 | |
---|
652 | def addCertCourseTickets(cert): |
---|
653 | """Collect all certificate courses and create course |
---|
654 | tickets automatically. |
---|
655 | """ |
---|
656 | |
---|
657 | def updateCourseTicket(ticket, course): |
---|
658 | """Updates a course ticket object and return code |
---|
659 | if ticket has been invalidated. |
---|
660 | """ |
---|
661 | |
---|
662 | class ICourseTicket(IKofaObject): |
---|
663 | """A representation of course ticket data. |
---|
664 | """ |
---|
665 | certcode = Attribute('Certificate code of the study course') |
---|
666 | level_session = Attribute('Session of the study level the ticket has been added to') |
---|
667 | level = Attribute('Level value of the study level the ticket has been added to') |
---|
668 | total_score = Attribute('Score') |
---|
669 | grade = Attribute('Grade calculated from total score') |
---|
670 | weight = Attribute('Weight calculated from total score') |
---|
671 | removable_by_student = Attribute('True if student is allowed to remove the ticket') |
---|
672 | editable_by_lecturer = Attribute('True if lecturer is allowed to edit the ticket') |
---|
673 | |
---|
674 | code = Attribute('Code of the original course') |
---|
675 | |
---|
676 | title = schema.TextLine( |
---|
677 | title = _(u'Title'), |
---|
678 | required = False, |
---|
679 | ) |
---|
680 | |
---|
681 | fcode = schema.TextLine( |
---|
682 | title = _(u'Faculty Code'), |
---|
683 | required = False, |
---|
684 | ) |
---|
685 | |
---|
686 | dcode = schema.TextLine( |
---|
687 | title = _(u'Department Code'), |
---|
688 | required = False, |
---|
689 | ) |
---|
690 | |
---|
691 | semester = schema.Choice( |
---|
692 | title = _(u'Semester/Term'), |
---|
693 | source = SemesterSource(), |
---|
694 | required = False, |
---|
695 | ) |
---|
696 | |
---|
697 | passmark = schema.Int( |
---|
698 | title = _(u'Passmark'), |
---|
699 | required = False, |
---|
700 | ) |
---|
701 | |
---|
702 | credits = schema.Int( |
---|
703 | title = _(u'Credits'), |
---|
704 | required = False, |
---|
705 | ) |
---|
706 | |
---|
707 | mandatory = schema.Bool( |
---|
708 | title = _(u'Required'), |
---|
709 | default = False, |
---|
710 | required = False, |
---|
711 | ) |
---|
712 | |
---|
713 | outstanding = schema.Bool( |
---|
714 | title = _(u'Outstanding Course'), |
---|
715 | default = False, |
---|
716 | required = False, |
---|
717 | ) |
---|
718 | |
---|
719 | course_category = schema.Choice( |
---|
720 | title = _(u'Course Category'), |
---|
721 | source = CourseCategorySource(), |
---|
722 | required = False, |
---|
723 | ) |
---|
724 | |
---|
725 | score = schema.Int( |
---|
726 | title = _(u'Score'), |
---|
727 | default = None, |
---|
728 | required = False, |
---|
729 | missing_value = None, |
---|
730 | ) |
---|
731 | |
---|
732 | carry_over = schema.Bool( |
---|
733 | title = _(u'Carry-over Course'), |
---|
734 | default = False, |
---|
735 | required = False, |
---|
736 | ) |
---|
737 | |
---|
738 | automatic = schema.Bool( |
---|
739 | title = _(u'Automatical Creation'), |
---|
740 | default = False, |
---|
741 | required = False, |
---|
742 | ) |
---|
743 | |
---|
744 | class ICourseTicketAdd(IKofaObject): |
---|
745 | """An interface for adding course tickets. |
---|
746 | """ |
---|
747 | course = schema.Choice( |
---|
748 | title = _(u'Course'), |
---|
749 | source = CourseSource(), |
---|
750 | readonly = False, |
---|
751 | ) |
---|
752 | |
---|
753 | class ICourseTicketImport(ICourseTicket): |
---|
754 | """An interface for importing course results and nothing more. |
---|
755 | """ |
---|
756 | score = schema.Int( |
---|
757 | title = _(u'Score'), |
---|
758 | required = False, |
---|
759 | readonly = False, |
---|
760 | ) |
---|
761 | |
---|
762 | level_session = schema.Choice( |
---|
763 | title = _(u'Level Session'), |
---|
764 | source = academic_sessions_vocab, |
---|
765 | required = False, |
---|
766 | readonly = False, |
---|
767 | ) |
---|
768 | |
---|
769 | class IStudentAccommodation(IKofaObject): |
---|
770 | """A container for student accommodation objects. |
---|
771 | """ |
---|
772 | |
---|
773 | desired_hostel = schema.TextLine( |
---|
774 | title = _(u'Desired Hostel'), |
---|
775 | required = False, |
---|
776 | ) |
---|
777 | |
---|
778 | def addBedTicket(bedticket): |
---|
779 | """Add a bed ticket object. |
---|
780 | """ |
---|
781 | |
---|
782 | |
---|
783 | class IBedTicket(IKofaObject): |
---|
784 | """A representation of accommodation booking data. |
---|
785 | """ |
---|
786 | bed = Attribute('The bed object') |
---|
787 | maint_payment_made = Attribute('True if maintenance payment is made') |
---|
788 | |
---|
789 | display_coordinates = schema.TextLine( |
---|
790 | title = _(u'Allocated Bed'), |
---|
791 | required = False, |
---|
792 | readonly = True, |
---|
793 | ) |
---|
794 | |
---|
795 | bed_coordinates = schema.TextLine( |
---|
796 | title = u'', |
---|
797 | required = True, |
---|
798 | readonly = False, |
---|
799 | ) |
---|
800 | |
---|
801 | bed_type = schema.TextLine( |
---|
802 | title = _(u'Requested Bed Type'), |
---|
803 | required = True, |
---|
804 | readonly = False, |
---|
805 | ) |
---|
806 | |
---|
807 | booking_session = schema.Choice( |
---|
808 | title = _(u'Session'), |
---|
809 | source = academic_sessions_vocab, |
---|
810 | required = True, |
---|
811 | readonly = False |
---|
812 | ) |
---|
813 | |
---|
814 | booking_date = schema.Datetime( |
---|
815 | title = _(u'Booking Date'), |
---|
816 | required = False, |
---|
817 | readonly = False, |
---|
818 | ) |
---|
819 | |
---|
820 | booking_code = schema.TextLine( |
---|
821 | title = _(u'Booking Activation Code'), |
---|
822 | required = False, |
---|
823 | readonly = False, |
---|
824 | ) |
---|
825 | |
---|
826 | def getSessionString(): |
---|
827 | """Returns the title of academic_sessions_vocab term of the session |
---|
828 | when the bed was booked. |
---|
829 | """ |
---|
830 | |
---|
831 | class IStudentPaymentsContainer(IPaymentsContainer): |
---|
832 | """A container for student payment objects. |
---|
833 | """ |
---|
834 | |
---|
835 | certificate = Attribute('Certificate to determine the correct p_level value') |
---|
836 | |
---|
837 | class IStudentOnlinePayment(IOnlinePayment): |
---|
838 | """A student payment via payment gateways. |
---|
839 | """ |
---|
840 | |
---|
841 | certificate = Attribute('Certificate to determine the correct p_level value') |
---|
842 | student = Attribute('Student') |
---|
843 | |
---|
844 | p_current = schema.Bool( |
---|
845 | title = _(u'Current Session Payment'), |
---|
846 | default = True, |
---|
847 | required = False, |
---|
848 | ) |
---|
849 | |
---|
850 | p_level = schema.Choice( |
---|
851 | title = _(u'Payment Level'), |
---|
852 | source = StudyLevelSource(), |
---|
853 | required = False, |
---|
854 | ) |
---|
855 | |
---|
856 | def redeemTicket(): |
---|
857 | """Either create an appropriate access code or trigger an action |
---|
858 | directly. |
---|
859 | """ |
---|
860 | |
---|
861 | def doAfterStudentPayment(): |
---|
862 | """Process student after payment was made. |
---|
863 | """ |
---|
864 | |
---|
865 | def doAfterStudentPaymentApproval(): |
---|
866 | """Process student after payment was approved. |
---|
867 | """ |
---|
868 | |
---|
869 | def approveStudentPayment(): |
---|
870 | """Approve payment and process student. |
---|
871 | """ |
---|
872 | |
---|
873 | IStudentOnlinePayment['p_level'].order = IStudentOnlinePayment[ |
---|
874 | 'p_session'].order |
---|
875 | |
---|
876 | class IStudentPreviousPayment(IKofaObject): |
---|
877 | """An interface for adding previous session payments. |
---|
878 | """ |
---|
879 | |
---|
880 | p_category = schema.Choice( |
---|
881 | title = _(u'Payment Category'), |
---|
882 | default = u'schoolfee', |
---|
883 | source = PreviousPaymentCategorySource(), |
---|
884 | required = True, |
---|
885 | ) |
---|
886 | |
---|
887 | p_session = schema.Choice( |
---|
888 | title = _(u'Payment Session'), |
---|
889 | source = academic_sessions_vocab, |
---|
890 | required = True, |
---|
891 | ) |
---|
892 | |
---|
893 | p_level = schema.Choice( |
---|
894 | title = _(u'Payment Level'), |
---|
895 | source = StudyLevelSource(), |
---|
896 | required = True, |
---|
897 | ) |
---|
898 | |
---|
899 | class IStudentBalancePayment(IKofaObject): |
---|
900 | """An interface for adding balances. |
---|
901 | """ |
---|
902 | |
---|
903 | p_category = schema.Choice( |
---|
904 | title = _(u'Payment Category'), |
---|
905 | default = u'schoolfee', |
---|
906 | required = True, |
---|
907 | source = BalancePaymentCategorySource(), |
---|
908 | ) |
---|
909 | |
---|
910 | balance_session = schema.Choice( |
---|
911 | title = _(u'Payment Session'), |
---|
912 | source = academic_sessions_vocab, |
---|
913 | required = True, |
---|
914 | ) |
---|
915 | |
---|
916 | balance_level = schema.Choice( |
---|
917 | title = _(u'Payment Level'), |
---|
918 | source = StudyLevelSource(), |
---|
919 | required = True, |
---|
920 | ) |
---|
921 | |
---|
922 | balance_amount = schema.Float( |
---|
923 | title = _(u'Balance Amount'), |
---|
924 | default = None, |
---|
925 | required = True, |
---|
926 | readonly = False, |
---|
927 | description = _( |
---|
928 | u'Balance in Naira '), |
---|
929 | ) |
---|
930 | |
---|
931 | class ICSVStudentExporter(ICSVExporter): |
---|
932 | """A regular ICSVExporter that additionally supports exporting |
---|
933 | data from a given student object. |
---|
934 | """ |
---|
935 | def get_filtered(site, **kw): |
---|
936 | """Get a filtered set of students. |
---|
937 | """ |
---|
938 | |
---|
939 | def get_selected(site, selected): |
---|
940 | """Get set of selected students. |
---|
941 | """ |
---|
942 | |
---|
943 | def export_student(student, filepath=None): |
---|
944 | """Export data for a given student. |
---|
945 | """ |
---|
946 | |
---|
947 | def export_filtered(site, filepath=None, **kw): |
---|
948 | """Export data for filtered set of students. |
---|
949 | """ |
---|
950 | |
---|
951 | def export_selected(site, filepath=None, **kw): |
---|
952 | """Export data for selected set of students. |
---|
953 | """ |
---|