1 | ## $Id: utils.py 7822 2012-03-09 07:26:31Z 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 | import grok |
---|
19 | from waeup.kofa.students.workflow import CLEARED, RETURNING |
---|
20 | from waeup.kofa.students.utils import StudentsUtils |
---|
21 | from waeup.kofa.students.interfaces import IStudentsUtils |
---|
22 | |
---|
23 | def get_school_fee(student, surcharge): |
---|
24 | study_mode = student['studycourse'].certificate.study_mode |
---|
25 | entry_mode = student['studycourse'].entry_mode |
---|
26 | state = student.state |
---|
27 | #lga = student.lga |
---|
28 | lga = 'nothing' |
---|
29 | current_level = student['studycourse'].current_level |
---|
30 | |
---|
31 | if study_mode.endswith('_ft'): |
---|
32 | # fresh |
---|
33 | if state == CLEARED: |
---|
34 | return 40000 - surcharge |
---|
35 | # returning |
---|
36 | elif state == RETURNING: |
---|
37 | return 20000 - surcharge |
---|
38 | else: |
---|
39 | return 0 |
---|
40 | else: |
---|
41 | return 0 |
---|
42 | |
---|
43 | class StudentsUtils(StudentsUtils): |
---|
44 | """A collection of customized methods. |
---|
45 | |
---|
46 | """ |
---|
47 | grok.implements(IStudentsUtils) |
---|
48 | |
---|
49 | # not yet changed |
---|
50 | def setReturningData(self, student): |
---|
51 | student['studycourse'].current_level += 100 |
---|
52 | student['studycourse'].current_session += 1 |
---|
53 | verdict = student['studycourse'].current_verdict |
---|
54 | student['studycourse'].current_verdict = '0' |
---|
55 | student['studycourse'].previous_verdict = verdict |
---|
56 | return |
---|
57 | |
---|
58 | def getPaymentDetails(self, category, student): |
---|
59 | d = {} |
---|
60 | d['surcharge_1'] = d['surcharge_2'] = d['surcharge_3'] = 0 |
---|
61 | d['p_item'] = u'' |
---|
62 | d['amount'] = 0 |
---|
63 | d['error'] = u'' |
---|
64 | d['p_session'] = student['studycourse'].current_session |
---|
65 | session = str(d['p_session']) |
---|
66 | try: |
---|
67 | academic_session = grok.getSite()['configuration'][session] |
---|
68 | except KeyError: |
---|
69 | d['error'] = u'Session configuration object is not available.' |
---|
70 | return d |
---|
71 | if category == 'transfer': |
---|
72 | d['amount'] = academic_session.transfer_fee |
---|
73 | elif category == 'gown': |
---|
74 | d['amount'] = academic_session.gown_fee |
---|
75 | elif category == 'bed_allocation': |
---|
76 | d['amount'] = academic_session.booking_fee |
---|
77 | elif category == 'hostel_maintenance': |
---|
78 | d['amount'] = academic_session.maint_fee |
---|
79 | elif category == 'clearance': |
---|
80 | d['p_item'] = student['studycourse'].certificate.code |
---|
81 | d['amount'] = academic_session.clearance_fee |
---|
82 | elif category == 'schoolfee': |
---|
83 | d['surcharge_1'] = academic_session.surcharge_1 |
---|
84 | d['surcharge_2'] = academic_session.surcharge_2 |
---|
85 | d['amount'] = get_school_fee(student, d['surcharge_1'] + d['surcharge_2']) |
---|
86 | code = student['studycourse'].certificate.code |
---|
87 | d['p_item'] = code |
---|
88 | d['p_session'] += 1 |
---|
89 | if d['amount'] == 0: |
---|
90 | d['error'] = u'Amount could not be determined.' |
---|
91 | return d |
---|
92 | |
---|
93 | def getVerdictsDict(self): |
---|
94 | """Provide a dictionary of verdicts. |
---|
95 | """ |
---|
96 | return { |
---|
97 | '0': 'not yet', |
---|
98 | 'A': 'Successful student', |
---|
99 | 'B': 'Student with carryover courses', |
---|
100 | 'C': 'Student on probation', |
---|
101 | 'D': 'Withdrawn from the faculty', |
---|
102 | 'E': 'Student who were previously on probation', |
---|
103 | 'F': 'Medical case', |
---|
104 | 'G': 'Absent from examination', |
---|
105 | } |
---|
106 | |
---|