source: main/waeup.uniben/trunk/src/waeup/uniben/students/utils.py @ 8265

Last change on this file since 8265 was 8265, checked in by Henrik Bettermann, 12 years ago

Add tests for customized clearance forms and remove bugs found.

  • Property svn:keywords set to Id
File size: 5.8 KB
Line 
1## $Id: utils.py 8265 2012-04-24 20:02:14Z 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##
18import grok
19from waeup.kofa.students.workflow import CLEARED, RETURNING
20from waeup.kofa.students.utils import StudentsUtils
21from waeup.kofa.students.interfaces import IStudentsUtils
22from waeup.kofa.accesscodes import create_accesscode
23from waeup.uniben.interfaces import MessageFactory as _
24
25def get_school_fee(student):
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:
36            return 40000.0
37        # returning
38        elif state == RETURNING:
39            return 20000.0
40        else:
41            return 0.0
42    else:
43        return 0.0
44
45def 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
73class CustomStudentsUtils(StudentsUtils):
74    """A collection of customized methods.
75
76    """
77    grok.implements(IStudentsUtils)
78
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
88    def getPaymentDetails(self, category, student):
89        d = {}
90        d['p_item'] = u''
91        d['amount'] = 0.0
92        d['error'] = u''
93        d['p_session'] = student['studycourse'].current_session
94        session = str(d['p_session'])
95        try:
96            academic_session = grok.getSite()['configuration'][session]
97        except KeyError:
98            d['error'] = _(u'Session configuration object is not available.')
99            return d
100        if category == 'transfer':
101            d['amount'] = academic_session.transfer_fee
102        elif category == 'gown':
103            d['amount'] = academic_session.gown_fee
104        elif category == 'bed_allocation':
105            d['amount'] = academic_session.booking_fee
106        elif category == 'hostel_maintenance':
107            d['amount'] = academic_session.maint_fee
108        elif category == 'clearance':
109            d['p_item'] = student['studycourse'].certificate.code
110            d['amount'] = academic_session.clearance_fee
111        elif category == 'schoolfee':
112            d['amount'] = get_school_fee(student)
113            code = student['studycourse'].certificate.code
114            d['p_item'] = code
115            d['p_session'] += 1
116        if d['amount'] == 0.0:
117            d['error'] = _(u'Amount could not be determined.')
118        return d
119
120    VERDICTS_DICT = {
121        '0': 'not yet',
122        'A': 'Successful student',
123        'B': 'Student with carryover courses',
124        'C': 'Student on probation',
125        'D': 'Withdrawn from the faculty',
126        'E': 'Student who were previously on probation',
127        'F': 'Medical case',
128        'G': 'Absent from examination',
129        'H': 'Withheld results',
130        'I': 'Expelled/rusticated/suspended student',
131        'J': 'Temporary withdrawn from the university',
132        'K': 'Unregistered student',
133        'L': 'Referred student',
134        'M': 'Reinstatement',
135        'N': 'Student on transfer',
136        'O': 'NCE-III repeater',
137        'Y': 'No previous verdict',
138        'X': 'New 300 level student',
139        'Z': 'Successful student (provisional)',
140        'A1': 'First Class',
141        'A2': 'Second Class Upper',
142        'A3': 'Second Class Lower',
143        'A4': 'Third Class',
144        'A5': 'Pass',
145        'A6': 'Distinction',
146        'A7': 'Credit',
147        'A8': 'Merit',
148        }
149
150    SEPARATORS_DICT = {
151        'form.fst_sit_fname': _(u'First Sitting Record'),
152        'form.scd_sit_fname': _(u'Second Sitting Record'),
153        'form.alr_fname': _(u'Advanced Level Record'),
154        'form.hq_type': _(u'Higher Education Record'),
155        'form.hq2_type': _(u'Second Higher Education Record'),
156        'form.nysc_year': _(u'NYSC Information'),
157        'form.employer': _(u'Employment History'),
158        'form.uniben_matric': _(u'Former Uniben Student'),
159        }
Note: See TracBrowser for help on using the repository browser.