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