source: WAeUP_SRP/uniben/waeup_custom/getPaymentsFolderInfo.py @ 3228

Last change on this file since 3228 was 3228, checked in by Henrik Bettermann, 17 years ago

fix WAeUPLevelWidget

adjust getPaymentsFolderInfo.py to Okene version

File size: 4.1 KB
Line 
1## Script (Python) "getPaymentsFolderInfo"
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: getPaymentsFolderInfo.py 2761 2007-11-26 09:45:58Z henrik $
11"""
12Info for the PaymentsFolder
13try:
14    from Products.zdb import set_trace
15except:
16    def set_trace():
17        pass
18"""
19
20from Products.AdvancedQuery import Eq, Between, Le,In
21
22mtool = context.portal_membership
23wftool = context.portal_workflow
24member = mtool.getAuthenticatedMember()
25payments_catalog = context.payments_catalog
26aq_payments = payments_catalog.evalAdvancedQuery
27if mtool.isAnonymousUser():
28    return None
29
30#import logging
31#logger = logging.getLogger('Skins.getPaymentsFolderInfo')
32def cmp_id(a,b):
33    s1 = "%(id)s" % a
34    s2 = "%(id)s" % b
35    if s1 == s2:
36        return 0
37    if s1 > s2:
38        return 1
39    return -1
40
41import DateTime
42request = context.REQUEST
43#students = context.portal_url.getPortalObject().campus.students
44student_id = context.getStudentId()
45if student_id is None:
46    return context.REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url())
47#student = getattr(students,student_id)
48student_record = context.students_catalog.getRecordByKey(student_id)
49
50
51info = {}
52is_so = info['is_so'] = context.isSectionOfficer()
53is_student = info['is_student'] = context.isStudent()
54info['student_name'] = student_record.name
55info['query_url'] = "https://webpay.interswitchng.com/paydirect/services/TransactionQueryURL.aspx"
56review_state = info['review_state'] = student_record.review_state
57parttime = student_record.mode and student_record.mode.endswith('_pt')
58fulltime = student_record.mode and student_record.mode.endswith('_ft')
59
60
61session = student_record.session
62next_info = context.getNextInfo(student_record)
63info['next_session'] = next_info['next_session_id']
64info['next_session_str'] = next_info['next_session_str']
65info['payment_method'] = ""
66info['reasons'] = next_info['reasons']
67
68if review_state == 'cleared_and_validated' and session != '07':
69    info['payment_method'] = "online_payment"
70#elif review_state == 'cleared_and_validated' and session == '07':
71#    info['payment_method'] = "sc_payment"
72elif review_state == 'returning' and info['next_session'] != session:
73    info['payment_method'] = "sc_payment"
74info['prod_id'] = '61'
75
76info['student_name'] = student_record.name
77payments_path = "%s/campus/students/%s/payments" % (context.portal_url(),student_id)
78payments = []
79payment_records = aq_payments(Eq('student_id',student_id) & Eq('session_id',student_record.session))
80vocabularies = context.portal_vocabularies
81paid_fees = []
82for payment in payment_records:
83    if payment.status == "paid":
84        paid_fees += "%s_%s" % (payment.type,payment.session_id),
85for payment in payment_records:
86    row = {}
87    row['id'] = payment.key
88    row['title'] = "%s for Session %s, Naira %s, %s" % (vocabularies.payment_categories.get(payment.category),
89                                                        vocabularies.sessions.get(payment.session_id),
90                                                        payment.amount,
91                                                        payment.date.strftime("%d/%m/%y %H:%M:%S"))
92    url = row['url'] = "%s/p%s" % (payments_path,payment.order_id[6:])
93    row['is_requeryable'] = "%s_%s" % (payment.type,payment.session_id) not in paid_fees or str(member) in ('admin',)
94    row['is_approvable'] = is_so and row['is_requeryable']
95    row['resp_desc'] = payment.resp_desc or 'Payment Process Interrupted'
96    row['trans_ref'] = payment.order_id
97    if row['is_requeryable']:
98        row['callback_url'] = "%(url)s/interswitch_cb" % row
99        href = '%(query_url)s' % info
100        href += '?transRef=%(trans_ref)s' % row
101        href += '&prodID=%(prod_id)s' % info
102        href += '&redirectURL=%(callback_url)s' % row
103        row['href'] = href
104    if payment.status == 'paid':
105        row['confirmed'] = 'active'
106    else:
107        row['confirmed'] = 'unsuccessful'
108    row['is_editable'] = is_so and (row['confirmed'] == 'active')
109    payments.append(row)
110
111
112
113payments.sort(cmp_id)
114info['payments'] = payments
115
116
117return info
118
Note: See TracBrowser for help on using the repository browser.