source: main/waeup.fceokene/trunk/src/waeup/fceokene/students/utils.py @ 8531

Last change on this file since 8531 was 8528, checked in by Henrik Bettermann, 13 years ago

See r8526.

The comment in r8627 refers to this revision.

  • Property svn:keywords set to Id
File size: 6.2 KB
RevLine 
[7419]1## $Id: utils.py 8528 2012-05-26 10:46:13Z 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]18import grok
[8475]19from waeup.kofa.interfaces import CLEARED, RETURNING, PAID
[7822]20from waeup.kofa.students.utils import StudentsUtils
21from waeup.kofa.students.interfaces import IStudentsUtils
[8247]22from waeup.kofa.accesscodes import create_accesscode
[8460]23from waeup.fceokene.interfaces import MessageFactory as _
[6902]24
[8263]25def get_school_fee(student):
[7152]26    state = student.state
[8306]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
[7152]35
[8204]36class CustomStudentsUtils(StudentsUtils):
[7151]37    """A collection of customized methods.
38
39    """
40    grok.implements(IStudentsUtils)
41
[8270]42    def getReturningData(self, student):
43        """ This method defines what happens after school fee payment
[8319]44        of returning students depending on the student's senate verdict.
[8270]45        """
[8319]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
[8270]58        new_session = student['studycourse'].current_session + 1
59        return new_session, new_level
60
[7419]61    def getPaymentDetails(self, category, student):
[8306]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
[7151]69        try:
70            academic_session = grok.getSite()['configuration'][session]
71        except KeyError:
[8306]72            details['error'] = _(u'Session configuration object is not available.')
73            return details
[7151]74        if category == 'transfer':
[8306]75            details['amount'] = academic_session.transfer_fee
[7151]76        elif category == 'gown':
[8306]77            details['amount'] = academic_session.gown_fee
[7151]78        elif category == 'bed_allocation':
[8306]79            details['amount'] = academic_session.booking_fee
[7151]80        elif category == 'hostel_maintenance':
[8306]81            details['amount'] = academic_session.maint_fee
[7151]82        elif category == 'clearance':
[8306]83            details['p_item'] = student['studycourse'].certificate.code
84            if details['p_item'] in ('BEDCET', 'BIOEDCET', 'CHMEDCET', 'ISEDCET',
[8294]85                'MTHEDCET', 'PHYEDCET', 'ITECET', 'AGREDCET', 'HEEDCET'):
[8306]86                details['amount'] = 17250.0
[8294]87            else:
[8306]88                details['amount'] = 34250.0
[7151]89        elif category == 'schoolfee':
[8306]90            details['amount'] = get_school_fee(student)
[7151]91            code = student['studycourse'].certificate.code
[8306]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)
[8475]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')
[8421]104        if details['amount'] in (0.0, None):
[8306]105            details['error'] = _(u'Amount could not be determined.')
106        return details
[7621]107
[7845]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        }
[8101]137
[8460]138    # FCEOkene separators
[8101]139    SEPARATORS_DICT = {
[8265]140        'form.fst_sit_fname': _(u'First Sitting Record'),
[8101]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'),
[8460]147        'form.former_matric': _(u'Former FCEOkene Student'),
[8413]148        }
149
[8460]150    # FCEOkene prefix
[8528]151    STUDENT_ID_PREFIX = u'K'
Note: See TracBrowser for help on using the repository browser.