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