source: main/waeup.sirp/trunk/src/waeup/sirp/students/utils.py @ 6947

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

Add clearance payment category.

  • Property svn:keywords set to Id
File size: 1.8 KB
Line 
1"""General helper functions for the student section.
2"""
3from grok import getSite
4from random import SystemRandom as r
5from waeup.sirp.interfaces import academic_sessions_vocab
6
7def generate_student_id(students,letter):
8    if letter == '?':
9        letter= r().choice('ABCDEFGHKLMNPQRSTUVWXY')
10    sid = u"%c%d" % (letter,r().randint(99999,1000000))
11    while sid in students.keys():
12        sid = u"%c%d" % (letter,r().randint(99999,1000000))
13    return sid
14
15def set_returning_data(student):
16    student['studycourse'].current_level += 100
17    student['studycourse'].current_session += 1
18    verdict = student['studycourse'].current_verdict
19    student['studycourse'].current_verdict = '0'
20    student['studycourse'].previous_verdict = verdict
21    return
22
23# To be specified in customization packages.
24# This function is for demonstration and testing only.
25def getPaymentDetails(category, student):
26    surcharge_1 = surcharge_2 = surcharge_3 = 0
27    p_item = u''
28    amount = 0
29    error = u''
30    p_session = student['studycourse'].current_session
31    session = str(p_session)
32    try:
33        academic_session = getSite()['configuration'][session]
34    except KeyError:
35        error = u'Session configuration object is not available.'
36        return (amount, p_item, p_session,
37            surcharge_1, surcharge_2, surcharge_3, error)
38    if category == 'schoolfee':
39        amount = academic_session.fee_1
40        surcharge_1 = academic_session.surcharge_1
41        surcharge_2 = academic_session.surcharge_2
42        surcharge_3 = academic_session.surcharge_3
43        p_item = student['studycourse'].certificate.code
44    elif category == 'clearance':
45        p_item = student['studycourse'].certificate.code
46        amount = academic_session.fee_2
47    return (amount, p_item, p_session,
48        surcharge_1, surcharge_2, surcharge_3, error)
Note: See TracBrowser for help on using the repository browser.