Ignore:
Timestamp:
20 Nov 2011, 07:46:49 (13 years ago)
Author:
Henrik Bettermann
Message:

Customize global utility StudentsUtils? instead of functions. The customized browser module is now obsolete.

Location:
main/waeup.custom/trunk/src/waeup/custom/students
Files:
1 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.custom/trunk/src/waeup/custom/students/utils.py

    r7145 r7151  
    1 from grok import getSite
     1import grok
    22from waeup.sirp.students.vocabularies import academic_sessions_vocab
    33from waeup.sirp.students.workflow import CLEARED, RETURNING
     4from waeup.sirp.students.utils import StudentsUtils
     5from waeup.sirp.students.interfaces import IStudentsUtils
    46
    5 def get_payment_details(category, student):
    6     d = {}
    7     d['surcharge_1'] = d['surcharge_2'] = d['surcharge_3'] = 0
    8     d['p_item'] = u''
    9     d['amount'] = 0
    10     d['error'] = u''
    11     d['p_session'] = student['studycourse'].current_session
    12     session = str(d['p_session'])
    13     try:
    14         academic_session = getSite()['configuration'][session]
    15     except KeyError:
    16         d['error'] = u'Session configuration object is not available.'
     7class StudentsUtils(StudentsUtils):
     8    """A collection of customized methods.
     9
     10    """
     11    grok.implements(IStudentsUtils)
     12
     13    def get_payment_details(self, category, student):
     14        d = {}
     15        d['surcharge_1'] = d['surcharge_2'] = d['surcharge_3'] = 0
     16        d['p_item'] = u''
     17        d['amount'] = 0
     18        d['error'] = u''
     19        d['p_session'] = student['studycourse'].current_session
     20        session = str(d['p_session'])
     21        try:
     22            academic_session = grok.getSite()['configuration'][session]
     23        except KeyError:
     24            d['error'] = u'Session configuration object is not available.'
     25            return d
     26        if category == 'transfer':
     27            d['amount'] = academic_session.transfer_fee
     28        elif category == 'gown':
     29            d['amount'] = academic_session.gown_fee
     30        elif category == 'bed_allocation':
     31            d['amount'] = academic_session.booking_fee
     32        elif category == 'hostel_maintenance':
     33            d['amount'] = academic_session.maint_fee
     34        elif category == 'clearance':
     35            d['p_item'] = student['studycourse'].certificate.code
     36            d['amount'] = academic_session.clearance_fee
     37        elif category == 'schoolfee':
     38            d['surcharge_1'] = academic_session.surcharge_1
     39            d['surcharge_2'] = academic_session.surcharge_2
     40            d['amount'] = self.getSchoolFee(student, d['surcharge_1'] + d['surcharge_2'])
     41            code = student['studycourse'].certificate.code
     42            #session_string = academic_sessions_vocab.by_value[p_session + 1].title
     43            d['p_item'] = code
     44            d['p_session'] += 1
     45        if d['amount'] == 0:
     46            d['error'] = u'Amount could not be determined.'
    1747        return d
    18     if category == 'transfer':
    19         d['amount'] = academic_session.transfer_fee
    20     elif category == 'gown':
    21         d['amount'] = academic_session.gown_fee
    22     elif category == 'bed_allocation':
    23         d['amount'] = academic_session.booking_fee
    24     elif category == 'hostel_maintenance':
    25         d['amount'] = academic_session.maint_fee
    26     elif category == 'clearance':
    27         d['p_item'] = student['studycourse'].certificate.code
    28         d['amount'] = academic_session.clearance_fee
    29     elif category == 'schoolfee':
    30         d['surcharge_1'] = academic_session.surcharge_1
    31         d['surcharge_2'] = academic_session.surcharge_2
    32         d['amount'] = getSchoolFee(student, d['surcharge_1'] + d['surcharge_2'])
    33         code = student['studycourse'].certificate.code
    34         #session_string = academic_sessions_vocab.by_value[p_session + 1].title
    35         d['p_item'] = code
    36         d['p_session'] += 1
    37     if d['amount'] == 0:
    38         d['error'] = u'Amount could not be determined.'
    39     return d
    4048
    41 def getSchoolFee(student, surcharge):
    42     study_mode = student['studycourse'].certificate.study_mode
    43     entry_mode = student['studycourse'].entry_mode
    44     state = student.state
    45     #lga = student.lga
    46     lga = 'nothing'
    47     current_level = student['studycourse'].current_level
     49    def getSchoolFee(self, student, surcharge):
     50        study_mode = student['studycourse'].certificate.study_mode
     51        entry_mode = student['studycourse'].entry_mode
     52        state = student.state
     53        #lga = student.lga
     54        lga = 'nothing'
     55        current_level = student['studycourse'].current_level
    4856
    49     if study_mode.endswith('_ft'):
    50         # fresh
    51         if state == CLEARED:
    52             return 40000 - surcharge
    53         # returning
    54         elif state == RETURNING:
    55             return 20000 - surcharge
     57        if study_mode.endswith('_ft'):
     58            # fresh
     59            if state == CLEARED:
     60                return 40000 - surcharge
     61            # returning
     62            elif state == RETURNING:
     63                return 20000 - surcharge
     64            else:
     65                return 0
    5666        else:
    5767            return 0
    58     else:
    59         return 0
Note: See TracChangeset for help on using the changeset viewer.