[7419] | 1 | ## $Id: utils.py 8247 2012-04-22 12:56:07Z 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 | ## |
---|
[7151] | 18 | import grok |
---|
[7822] | 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 |
---|
[8247] | 22 | from waeup.kofa.accesscodes import create_accesscode |
---|
[8020] | 23 | from waeup.uniben.interfaces import MessageFactory as _ |
---|
[6902] | 24 | |
---|
[7152] | 25 | def get_school_fee(student, surcharge): |
---|
| 26 | study_mode = student['studycourse'].certificate.study_mode |
---|
| 27 | entry_mode = student['studycourse'].entry_mode |
---|
| 28 | state = student.state |
---|
| 29 | #lga = student.lga |
---|
| 30 | lga = 'nothing' |
---|
| 31 | current_level = student['studycourse'].current_level |
---|
| 32 | |
---|
| 33 | if study_mode.endswith('_ft'): |
---|
| 34 | # fresh |
---|
| 35 | if state == CLEARED: |
---|
[7928] | 36 | return 40000.0 - surcharge |
---|
[7152] | 37 | # returning |
---|
| 38 | elif state == RETURNING: |
---|
[7928] | 39 | return 20000.0 - surcharge |
---|
[7152] | 40 | else: |
---|
[7928] | 41 | return 0.0 |
---|
[7152] | 42 | else: |
---|
[7928] | 43 | return 0.0 |
---|
[7152] | 44 | |
---|
[8247] | 45 | def actions_after_student_payment(student, payment, view): |
---|
| 46 | if payment.p_category == 'clearance': |
---|
| 47 | # Create CLR access code |
---|
| 48 | pin, error = create_accesscode('CLR',0,student.student_id) |
---|
| 49 | if error: |
---|
| 50 | view.flash(_('Valid callback received. ${a}', |
---|
| 51 | mapping = {'a':error})) |
---|
| 52 | return |
---|
| 53 | payment.ac = pin |
---|
| 54 | elif payment.p_category == 'schoolfee': |
---|
| 55 | # Create SFE access code |
---|
| 56 | pin, error = create_accesscode('SFE',0,student.student_id) |
---|
| 57 | if error: |
---|
| 58 | view.flash(_('Valid callback received. ${a}', |
---|
| 59 | mapping = {'a':error})) |
---|
| 60 | return |
---|
| 61 | payment.ac = pin |
---|
| 62 | elif payment.p_category == 'bed_allocation': |
---|
| 63 | # Create HOS access code |
---|
| 64 | pin, error = create_accesscode('HOS',0,student.student_id) |
---|
| 65 | if error: |
---|
| 66 | view.flash(_('Valid callback received. ${a}', |
---|
| 67 | mapping = {'a':error})) |
---|
| 68 | return |
---|
| 69 | payment.ac = pin |
---|
| 70 | view.flash(_('Valid callback received.')) |
---|
| 71 | return |
---|
| 72 | |
---|
[8204] | 73 | class CustomStudentsUtils(StudentsUtils): |
---|
[7151] | 74 | """A collection of customized methods. |
---|
| 75 | |
---|
| 76 | """ |
---|
| 77 | grok.implements(IStudentsUtils) |
---|
| 78 | |
---|
[7621] | 79 | # not yet changed |
---|
| 80 | def setReturningData(self, student): |
---|
| 81 | student['studycourse'].current_level += 100 |
---|
| 82 | student['studycourse'].current_session += 1 |
---|
| 83 | verdict = student['studycourse'].current_verdict |
---|
| 84 | student['studycourse'].current_verdict = '0' |
---|
| 85 | student['studycourse'].previous_verdict = verdict |
---|
| 86 | return |
---|
| 87 | |
---|
[7419] | 88 | def getPaymentDetails(self, category, student): |
---|
[7151] | 89 | d = {} |
---|
[7928] | 90 | d['surcharge_1'] = d['surcharge_2'] = d['surcharge_3'] = 0.0 |
---|
[7151] | 91 | d['p_item'] = u'' |
---|
[7928] | 92 | d['amount'] = 0.0 |
---|
[7151] | 93 | d['error'] = u'' |
---|
| 94 | d['p_session'] = student['studycourse'].current_session |
---|
| 95 | session = str(d['p_session']) |
---|
| 96 | try: |
---|
| 97 | academic_session = grok.getSite()['configuration'][session] |
---|
| 98 | except KeyError: |
---|
[7879] | 99 | d['error'] = _(u'Session configuration object is not available.') |
---|
[7151] | 100 | return d |
---|
| 101 | if category == 'transfer': |
---|
| 102 | d['amount'] = academic_session.transfer_fee |
---|
| 103 | elif category == 'gown': |
---|
| 104 | d['amount'] = academic_session.gown_fee |
---|
| 105 | elif category == 'bed_allocation': |
---|
| 106 | d['amount'] = academic_session.booking_fee |
---|
| 107 | elif category == 'hostel_maintenance': |
---|
| 108 | d['amount'] = academic_session.maint_fee |
---|
| 109 | elif category == 'clearance': |
---|
| 110 | d['p_item'] = student['studycourse'].certificate.code |
---|
| 111 | d['amount'] = academic_session.clearance_fee |
---|
| 112 | elif category == 'schoolfee': |
---|
| 113 | d['surcharge_1'] = academic_session.surcharge_1 |
---|
| 114 | d['surcharge_2'] = academic_session.surcharge_2 |
---|
[7152] | 115 | d['amount'] = get_school_fee(student, d['surcharge_1'] + d['surcharge_2']) |
---|
[7151] | 116 | code = student['studycourse'].certificate.code |
---|
| 117 | d['p_item'] = code |
---|
| 118 | d['p_session'] += 1 |
---|
[7928] | 119 | if d['amount'] == 0.0: |
---|
[7879] | 120 | d['error'] = _(u'Amount could not be determined.') |
---|
[7021] | 121 | return d |
---|
[7621] | 122 | |
---|
[7845] | 123 | VERDICTS_DICT = { |
---|
| 124 | '0': 'not yet', |
---|
| 125 | 'A': 'Successful student', |
---|
| 126 | 'B': 'Student with carryover courses', |
---|
| 127 | 'C': 'Student on probation', |
---|
| 128 | 'D': 'Withdrawn from the faculty', |
---|
| 129 | 'E': 'Student who were previously on probation', |
---|
| 130 | 'F': 'Medical case', |
---|
| 131 | 'G': 'Absent from examination', |
---|
| 132 | 'H': 'Withheld results', |
---|
| 133 | 'I': 'Expelled/rusticated/suspended student', |
---|
| 134 | 'J': 'Temporary withdrawn from the university', |
---|
| 135 | 'K': 'Unregistered student', |
---|
| 136 | 'L': 'Referred student', |
---|
| 137 | 'M': 'Reinstatement', |
---|
| 138 | 'N': 'Student on transfer', |
---|
| 139 | 'O': 'NCE-III repeater', |
---|
| 140 | 'Y': 'No previous verdict', |
---|
| 141 | 'X': 'New 300 level student', |
---|
| 142 | 'Z': 'Successful student (provisional)', |
---|
| 143 | 'A1': 'First Class', |
---|
| 144 | 'A2': 'Second Class Upper', |
---|
| 145 | 'A3': 'Second Class Lower', |
---|
| 146 | 'A4': 'Third Class', |
---|
| 147 | 'A5': 'Pass', |
---|
| 148 | 'A6': 'Distinction', |
---|
| 149 | 'A7': 'Credit', |
---|
| 150 | 'A8': 'Merit', |
---|
| 151 | } |
---|
[8101] | 152 | |
---|
| 153 | SEPARATORS_DICT = { |
---|
| 154 | 'form.fst_sit_fname': _(u'First Sitting Recod'), |
---|
| 155 | 'form.scd_sit_fname': _(u'Second Sitting Record'), |
---|
| 156 | 'form.alr_fname': _(u'Advanced Level Record'), |
---|
| 157 | 'form.hq_type': _(u'Higher Education Record'), |
---|
| 158 | 'form.hq2_type': _(u'Second Higher Education Record'), |
---|
| 159 | 'form.nysc_year': _(u'NYSC Information'), |
---|
| 160 | 'form.employer': _(u'Employment History'), |
---|
[8136] | 161 | 'form.uniben_matric': _(u'Former Uniben Student'), |
---|
[8101] | 162 | } |
---|