source: WAeUP_SRP/trunk/skins/waeup_epayment/getPaymentInfo.py @ 2048

Last change on this file since 2048 was 2048, checked in by joachim, 17 years ago

show amount of payment, payment_receipt simplyfied

  • Property svn:keywords set to Id
File size: 1.8 KB
Line 
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"""
12return Info about the current Student
13"""
14import logging
15logger = logging.getLogger('Skins.getStudentBaseInfo')
16from DateTime import DateTime
17
18request = context.REQUEST
19mtool = context.portal_membership
20wf = context.portal_workflow
21member = mtool.getAuthenticatedMember()
22member_id = str(member)
23
24if mtool.isAnonymousUser():
25    return None
26info = {}
27requested_id = context.getStudentId()
28if 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
31elif context.isStaff():
32    student_id = requested_id
33else:
34    student_id = member_id
35
36
37#students_object = context.portal_url.getPortalObject().campus.students
38#student = getattr(students_object,student_id)
39
40res = context.students_catalog(id = student_id)
41if len(res) != 1:
42    return None
43sbrain = res[0]
44info['id'] = student_id
45info['student'] = context.getFormattedStudentEntry(sbrain)
46payment = context.getContent()
47info['payment'] = payment
48info['is_online_pmt'] = io = payment.resp_code in ('00','AP','IP')
49info['is_scratchcard_pmt'] = isc =  payment.resp_code == 'SC'
50if 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)
59info['is_interrupted'] = ii = payment.resp_code == ''
60info['unknown_code'] = not (io or isc or ii)
61info['resp_code'] = payment.resp_code
62info['resp_desc'] = payment.resp_desc
63#info['entry_mode'] = sbrain.entry_mode
64
65
66return info
Note: See TracBrowser for help on using the repository browser.