[7419] | 1 | ## $Id: utils.py 8270 2012-04-25 06:45:16Z 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 | |
---|
[8263] | 25 | def get_school_fee(student): |
---|
[7152] | 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: |
---|
[8263] | 36 | return 40000.0 |
---|
[7152] | 37 | # returning |
---|
| 38 | elif state == RETURNING: |
---|
[8263] | 39 | return 20000.0 |
---|
[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 |
---|
[8270] | 80 | def getReturningData(self, student): |
---|
| 81 | """ This method defines what happens after school fee payment |
---|
| 82 | depending on the student's senate verdict. |
---|
[7621] | 83 | |
---|
[8270] | 84 | In the base configuration current level is always increased |
---|
| 85 | by 100 no matter which verdict has been assigned. |
---|
| 86 | """ |
---|
| 87 | new_level = student['studycourse'].current_level + 100 |
---|
| 88 | new_session = student['studycourse'].current_session + 1 |
---|
| 89 | return new_session, new_level |
---|
| 90 | |
---|
[7419] | 91 | def getPaymentDetails(self, category, student): |
---|
[7151] | 92 | d = {} |
---|
| 93 | d['p_item'] = u'' |
---|
[7928] | 94 | d['amount'] = 0.0 |
---|
[7151] | 95 | d['error'] = u'' |
---|
| 96 | d['p_session'] = student['studycourse'].current_session |
---|
| 97 | session = str(d['p_session']) |
---|
[8270] | 98 | d['p_level'] = student['studycourse'].current_level |
---|
[7151] | 99 | try: |
---|
| 100 | academic_session = grok.getSite()['configuration'][session] |
---|
| 101 | except KeyError: |
---|
[7879] | 102 | d['error'] = _(u'Session configuration object is not available.') |
---|
[7151] | 103 | return d |
---|
| 104 | if category == 'transfer': |
---|
| 105 | d['amount'] = academic_session.transfer_fee |
---|
| 106 | elif category == 'gown': |
---|
| 107 | d['amount'] = academic_session.gown_fee |
---|
| 108 | elif category == 'bed_allocation': |
---|
| 109 | d['amount'] = academic_session.booking_fee |
---|
| 110 | elif category == 'hostel_maintenance': |
---|
| 111 | d['amount'] = academic_session.maint_fee |
---|
| 112 | elif category == 'clearance': |
---|
| 113 | d['p_item'] = student['studycourse'].certificate.code |
---|
| 114 | d['amount'] = academic_session.clearance_fee |
---|
| 115 | elif category == 'schoolfee': |
---|
[8263] | 116 | d['amount'] = get_school_fee(student) |
---|
[7151] | 117 | code = student['studycourse'].certificate.code |
---|
| 118 | d['p_item'] = code |
---|
[8270] | 119 | # In case of school fee payment the payment session and level |
---|
| 120 | # contain the values of the session the student has paid for |
---|
| 121 | d['p_session'], d['p_level'] = self.getReturningData(student) |
---|
[7928] | 122 | if d['amount'] == 0.0: |
---|
[7879] | 123 | d['error'] = _(u'Amount could not be determined.') |
---|
[7021] | 124 | return d |
---|
[7621] | 125 | |
---|
[7845] | 126 | VERDICTS_DICT = { |
---|
| 127 | '0': 'not yet', |
---|
| 128 | 'A': 'Successful student', |
---|
| 129 | 'B': 'Student with carryover courses', |
---|
| 130 | 'C': 'Student on probation', |
---|
| 131 | 'D': 'Withdrawn from the faculty', |
---|
| 132 | 'E': 'Student who were previously on probation', |
---|
| 133 | 'F': 'Medical case', |
---|
| 134 | 'G': 'Absent from examination', |
---|
| 135 | 'H': 'Withheld results', |
---|
| 136 | 'I': 'Expelled/rusticated/suspended student', |
---|
| 137 | 'J': 'Temporary withdrawn from the university', |
---|
| 138 | 'K': 'Unregistered student', |
---|
| 139 | 'L': 'Referred student', |
---|
| 140 | 'M': 'Reinstatement', |
---|
| 141 | 'N': 'Student on transfer', |
---|
| 142 | 'O': 'NCE-III repeater', |
---|
| 143 | 'Y': 'No previous verdict', |
---|
| 144 | 'X': 'New 300 level student', |
---|
| 145 | 'Z': 'Successful student (provisional)', |
---|
| 146 | 'A1': 'First Class', |
---|
| 147 | 'A2': 'Second Class Upper', |
---|
| 148 | 'A3': 'Second Class Lower', |
---|
| 149 | 'A4': 'Third Class', |
---|
| 150 | 'A5': 'Pass', |
---|
| 151 | 'A6': 'Distinction', |
---|
| 152 | 'A7': 'Credit', |
---|
| 153 | 'A8': 'Merit', |
---|
| 154 | } |
---|
[8101] | 155 | |
---|
| 156 | SEPARATORS_DICT = { |
---|
[8265] | 157 | 'form.fst_sit_fname': _(u'First Sitting Record'), |
---|
[8101] | 158 | 'form.scd_sit_fname': _(u'Second Sitting Record'), |
---|
| 159 | 'form.alr_fname': _(u'Advanced Level Record'), |
---|
| 160 | 'form.hq_type': _(u'Higher Education Record'), |
---|
| 161 | 'form.hq2_type': _(u'Second Higher Education Record'), |
---|
| 162 | 'form.nysc_year': _(u'NYSC Information'), |
---|
| 163 | 'form.employer': _(u'Employment History'), |
---|
[8136] | 164 | 'form.uniben_matric': _(u'Former Uniben Student'), |
---|
[8101] | 165 | } |
---|