1 | ## $Id: utils.py 8473 2012-05-20 11:19:55Z 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.interfaces import CLEARED, RETURNING, PAID |
---|
20 | from waeup.kofa.students.utils import StudentsUtils |
---|
21 | from waeup.kofa.students.interfaces import IStudentsUtils |
---|
22 | from waeup.kofa.accesscodes import create_accesscode |
---|
23 | from waeup.uniben.interfaces import MessageFactory as _ |
---|
24 | |
---|
25 | def get_school_fee(student): |
---|
26 | state = student.state |
---|
27 | fee = None |
---|
28 | if state == CLEARED: |
---|
29 | fee = getattr(student['studycourse'].certificate,'school_fee_1') |
---|
30 | elif state == RETURNING: |
---|
31 | fee = getattr(student['studycourse'].certificate,'school_fee_2') |
---|
32 | if fee is not None: |
---|
33 | return fee |
---|
34 | return 0.0 |
---|
35 | |
---|
36 | class CustomStudentsUtils(StudentsUtils): |
---|
37 | """A collection of customized methods. |
---|
38 | |
---|
39 | """ |
---|
40 | grok.implements(IStudentsUtils) |
---|
41 | |
---|
42 | def getReturningData(self, student): |
---|
43 | """ This method defines what happens after school fee payment |
---|
44 | of returning students depending on the student's senate verdict. |
---|
45 | """ |
---|
46 | prev_level = student['studycourse'].current_level |
---|
47 | cur_verdict = student['studycourse'].current_verdict |
---|
48 | if cur_verdict in ('A','B','L','M','N','Z',): |
---|
49 | # Successful student |
---|
50 | new_level = divmod(int(prev_level),100)[0]*100 + 100 |
---|
51 | elif cur_verdict == 'C': |
---|
52 | # Student on probation |
---|
53 | new_level = int(prev_level) + 10 |
---|
54 | else: |
---|
55 | # Student is somehow in an undefined state. |
---|
56 | # Level has to be set manually. |
---|
57 | new_level = prev_level |
---|
58 | new_session = student['studycourse'].current_session + 1 |
---|
59 | return new_session, new_level |
---|
60 | |
---|
61 | def getPaymentDetails(self, category, student): |
---|
62 | details = {} |
---|
63 | details['p_item'] = u'' |
---|
64 | details['amount'] = 0.0 |
---|
65 | details['error'] = u'' |
---|
66 | details['p_session'] = student['studycourse'].current_session |
---|
67 | session = str(details['p_session']) |
---|
68 | details['p_level'] = student['studycourse'].current_level |
---|
69 | try: |
---|
70 | academic_session = grok.getSite()['configuration'][session] |
---|
71 | except KeyError: |
---|
72 | details['error'] = _(u'Session configuration object is not available.') |
---|
73 | return details |
---|
74 | if category == 'transfer': |
---|
75 | details['amount'] = academic_session.transfer_fee |
---|
76 | elif category == 'gown': |
---|
77 | details['amount'] = academic_session.gown_fee |
---|
78 | elif category == 'bed_allocation': |
---|
79 | details['amount'] = academic_session.booking_fee |
---|
80 | elif category == 'hostel_maintenance': |
---|
81 | details['amount'] = academic_session.maint_fee |
---|
82 | elif category == 'clearance': |
---|
83 | details['p_item'] = student['studycourse'].certificate.code |
---|
84 | if details['p_item'] in ('BEDCET', 'BIOEDCET', 'CHMEDCET', 'ISEDCET', |
---|
85 | 'MTHEDCET', 'PHYEDCET', 'ITECET', 'AGREDCET', 'HEEDCET'): |
---|
86 | details['amount'] = 17250.0 |
---|
87 | else: |
---|
88 | details['amount'] = 34250.0 |
---|
89 | elif category == 'schoolfee': |
---|
90 | details['amount'] = get_school_fee(student) |
---|
91 | code = student['studycourse'].certificate.code |
---|
92 | details['p_item'] = code |
---|
93 | if student.state == RETURNING: |
---|
94 | # In case of returning school fee payment the payment session |
---|
95 | # and level contain the values of the session the student |
---|
96 | # has paid for. |
---|
97 | details['p_session'], details['p_level'] = self.getReturningData(student) |
---|
98 | elif student.current_mode.startswith('pg') and student.state == PAID: |
---|
99 | # Returning postgraduate students also pay for the next session |
---|
100 | # but their level always remains the same. |
---|
101 | details['p_session'] += 1 |
---|
102 | details['amount'] = getattr( |
---|
103 | student['studycourse'].certificate,'school_fee_2') |
---|
104 | if details['amount'] in (0.0, None): |
---|
105 | details['error'] = _(u'Amount could not be determined.') |
---|
106 | return details |
---|
107 | |
---|
108 | VERDICTS_DICT = { |
---|
109 | '0': 'not yet', |
---|
110 | 'A': 'Successful student', |
---|
111 | 'B': 'Student with carryover courses', |
---|
112 | 'C': 'Student on probation', |
---|
113 | 'D': 'Withdrawn from the faculty', |
---|
114 | 'E': 'Student who were previously on probation', |
---|
115 | 'F': 'Medical case', |
---|
116 | 'G': 'Absent from examination', |
---|
117 | 'H': 'Withheld results', |
---|
118 | 'I': 'Expelled/rusticated/suspended student', |
---|
119 | 'J': 'Temporary withdrawn from the university', |
---|
120 | 'K': 'Unregistered student', |
---|
121 | 'L': 'Referred student', |
---|
122 | 'M': 'Reinstatement', |
---|
123 | 'N': 'Student on transfer', |
---|
124 | 'O': 'NCE-III repeater', |
---|
125 | 'Y': 'No previous verdict', |
---|
126 | 'X': 'New 300 level student', |
---|
127 | 'Z': 'Successful student (provisional)', |
---|
128 | 'A1': 'First Class', |
---|
129 | 'A2': 'Second Class Upper', |
---|
130 | 'A3': 'Second Class Lower', |
---|
131 | 'A4': 'Third Class', |
---|
132 | 'A5': 'Pass', |
---|
133 | 'A6': 'Distinction', |
---|
134 | 'A7': 'Credit', |
---|
135 | 'A8': 'Merit', |
---|
136 | } |
---|
137 | |
---|
138 | # Uniben separators |
---|
139 | SEPARATORS_DICT = { |
---|
140 | 'form.fst_sit_fname': _(u'First Sitting Record'), |
---|
141 | 'form.scd_sit_fname': _(u'Second Sitting Record'), |
---|
142 | 'form.alr_fname': _(u'Advanced Level Record'), |
---|
143 | 'form.hq_type': _(u'Higher Education Record'), |
---|
144 | 'form.hq2_type': _(u'Second Higher Education Record'), |
---|
145 | 'form.nysc_year': _(u'NYSC Information'), |
---|
146 | 'form.employer': _(u'Employment History'), |
---|
147 | 'form.former_matric': _(u'Former Uniben Student'), |
---|
148 | } |
---|
149 | |
---|
150 | # Uniben prefix |
---|
151 | STUDENT_ID_PREFIX = u'B' |
---|