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