[2048] | 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 2048 2007-07-23 15:53:30Z joachim $ |
---|
| 11 | """ |
---|
| 12 | return Info about the current Student |
---|
| 13 | """ |
---|
| 14 | import logging |
---|
| 15 | logger = logging.getLogger('Skins.getStudentBaseInfo') |
---|
| 16 | from DateTime import DateTime |
---|
| 17 | |
---|
| 18 | request = context.REQUEST |
---|
| 19 | mtool = context.portal_membership |
---|
| 20 | wf = context.portal_workflow |
---|
| 21 | member = mtool.getAuthenticatedMember() |
---|
| 22 | member_id = str(member) |
---|
| 23 | |
---|
| 24 | if mtool.isAnonymousUser(): |
---|
| 25 | return None |
---|
| 26 | info = {} |
---|
| 27 | requested_id = context.getStudentId() |
---|
| 28 | if requested_id and not context.isStaff() and member_id != requested_id: |
---|
| 29 | logger.info('%s tried to access %s' % (member_id,requested_id)) |
---|
| 30 | return None |
---|
| 31 | elif context.isStaff(): |
---|
| 32 | student_id = requested_id |
---|
| 33 | else: |
---|
| 34 | student_id = member_id |
---|
| 35 | |
---|
| 36 | |
---|
| 37 | #students_object = context.portal_url.getPortalObject().campus.students |
---|
| 38 | #student = getattr(students_object,student_id) |
---|
| 39 | |
---|
| 40 | res = context.students_catalog(id = student_id) |
---|
| 41 | if len(res) != 1: |
---|
| 42 | return None |
---|
| 43 | sbrain = res[0] |
---|
| 44 | info['id'] = student_id |
---|
| 45 | info['student'] = context.getFormattedStudentEntry(sbrain) |
---|
| 46 | payment = context.getContent() |
---|
| 47 | info['payment'] = payment |
---|
| 48 | info['is_online_pmt'] = io = payment.resp_code in ('00','AP','IP') |
---|
| 49 | info['is_scratchcard_pmt'] = isc = payment.resp_code == 'SC' |
---|
| 50 | if isc: |
---|
| 51 | from Products.zdb import set_trace |
---|
| 52 | set_trace() |
---|
| 53 | p,b,n = str(payment.order_id).split('-') |
---|
| 54 | batch_object = getattr(context.pins,"%s_%s" % (p,b),None) |
---|
| 55 | if batch_object is None: |
---|
| 56 | info['cost'] = "unknown" |
---|
| 57 | else: |
---|
| 58 | info['cost'] = "%6.2f N" % getattr(batch_object.getContent(),'cost',0.0) |
---|
| 59 | info['is_interrupted'] = ii = payment.resp_code == '' |
---|
| 60 | info['unknown_code'] = not (io or isc or ii) |
---|
| 61 | info['resp_code'] = payment.resp_code |
---|
| 62 | info['resp_desc'] = payment.resp_desc |
---|
| 63 | #info['entry_mode'] = sbrain.entry_mode |
---|
| 64 | |
---|
| 65 | |
---|
| 66 | return info |
---|