[7900] | 1 | ## Script (Python) "getPaymentInfo" |
---|
| 2 | ##bind container=container |
---|
| 3 | ##bind context=context |
---|
| 4 | ##bind namespace= |
---|
| 5 | ##bind script=script |
---|
| 6 | ##bind subpath=traverse_subpath |
---|
| 7 | ##parameters= |
---|
| 8 | ##title= |
---|
| 9 | ## |
---|
| 10 | # $Id: getPaymentInfo.py 8315 2012-04-30 12:15:36Z henrik $ |
---|
| 11 | """ |
---|
| 12 | return Info about the current Student |
---|
| 13 | """ |
---|
| 14 | import logging |
---|
| 15 | logger = logging.getLogger('Skins.getStudentBaseInfo') |
---|
| 16 | from DateTime import DateTime |
---|
| 17 | try: |
---|
| 18 | from Products.zdb import set_trace |
---|
| 19 | except: |
---|
| 20 | def set_trace(): |
---|
| 21 | pass |
---|
| 22 | |
---|
| 23 | info = context.waeup_tool.getAccessInfo(context) |
---|
| 24 | student_id = info['student_id'] |
---|
| 25 | if student_id is None: |
---|
| 26 | return None |
---|
| 27 | |
---|
| 28 | |
---|
| 29 | |
---|
| 30 | res = context.students_catalog(id = student_id) |
---|
| 31 | if len(res) != 1: |
---|
| 32 | return None |
---|
| 33 | sbrain = res[0] |
---|
| 34 | info['id'] = student_id |
---|
| 35 | info['student'] = context.getFormattedStudentEntry(sbrain) |
---|
| 36 | payment = context.getContent() |
---|
| 37 | info['payment_doc'] = payment |
---|
[8205] | 38 | info['is_im_pmt'] = im = payment.resp_code in ('IM',) |
---|
[7901] | 39 | info['is_etranzact_pmt'] = ie = payment.type == 'etranzact' |
---|
[7900] | 40 | info['is_online_pmt'] = io = payment.resp_code in ('0','00','AP','IP',) |
---|
| 41 | info['is_request_pmt'] = ir = payment.resp_code in ('RP',) |
---|
| 42 | info['is_scratchcard_pmt'] = isc = payment.resp_code == 'SC' |
---|
[7901] | 43 | info['is_interrupted'] = ii = payment.resp_code == '' and not ie |
---|
[8205] | 44 | info['unknown_code'] = not (io or isc or ii or ir or ie or im) |
---|
[7900] | 45 | info['resp_code'] = payment.resp_code |
---|
| 46 | info['resp_desc'] = payment.resp_desc |
---|
| 47 | #info['entry_mode'] = sbrain.entry_mode |
---|
| 48 | |
---|
[8315] | 49 | try: |
---|
| 50 | p_date = payment.date.strftime("%d/%m/%y %H:%M:%S") |
---|
| 51 | except: |
---|
| 52 | p_date = '(no payment date provided)' |
---|
[7900] | 53 | |
---|
[8315] | 54 | info['p_date'] = p_date |
---|
[7900] | 55 | return info |
---|