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