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

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

not type but category!

File size: 4.1 KB
RevLine 
[2847]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
[2859]18"""
[2847]19
[3228]20from Products.AdvancedQuery import Eq, Between, Le,In
21
[2859]22mtool = context.portal_membership
[3068]23wftool = context.portal_workflow
[2939]24member = mtool.getAuthenticatedMember()
[3228]25payments_catalog = context.payments_catalog
26aq_payments = payments_catalog.evalAdvancedQuery
[2859]27if mtool.isAnonymousUser():
28    return None
[2847]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
[3228]43#students = context.portal_url.getPortalObject().campus.students
[2847]44student_id = context.getStudentId()
45if student_id is None:
46    return context.REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url())
[3228]47#student = getattr(students,student_id)
[2859]48student_record = context.students_catalog.getRecordByKey(student_id)
[2847]49
[3228]50
[2847]51info = {}
52is_so = info['is_so'] = context.isSectionOfficer()
53is_student = info['is_student'] = context.isStudent()
[2859]54info['student_name'] = student_record.name
[2847]55info['query_url'] = "https://webpay.interswitchng.com/paydirect/services/TransactionQueryURL.aspx"
[2859]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')
[2847]59
60
[2859]61session = student_record.session
62next_info = context.getNextInfo(student_record)
[2847]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
[3060]68if review_state == 'cleared_and_validated' and session != '07':
[2847]69    info['payment_method'] = "online_payment"
[3060]70#elif review_state == 'cleared_and_validated' and session == '07':
[3228]71#    info['payment_method'] = "sc_payment"
[2847]72elif review_state == 'returning' and info['next_session'] != session:
73    info['payment_method'] = "sc_payment"
74info['prod_id'] = '61'
75
[2859]76info['student_name'] = student_record.name
[3228]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":
[3231]84        paid_fees += "%s_%s" % (payment.category,payment.session_id),
85#info['pf'] = paid_fees       
[3228]86for payment in payment_records:
[2847]87    row = {}
[3228]88    row['id'] = payment.key
89    row['title'] = "%s for Session %s, Naira %s, %s" % (vocabularies.payment_categories.get(payment.category),
90                                                        vocabularies.sessions.get(payment.session_id),
91                                                        payment.amount,
92                                                        payment.date.strftime("%d/%m/%y %H:%M:%S"))
93    url = row['url'] = "%s/p%s" % (payments_path,payment.order_id[6:])
[3231]94    row['is_requeryable'] = "%s_%s" % (payment.category,payment.session_id) not in paid_fees or str(member) in ('admin',)
[3228]95    row['is_approvable'] = is_so and row['is_requeryable']
96    row['resp_desc'] = payment.resp_desc or 'Payment Process Interrupted'
97    row['trans_ref'] = payment.order_id
98    if row['is_requeryable']:
99        row['callback_url'] = "%(url)s/interswitch_cb" % row
100        href = '%(query_url)s' % info
101        href += '?transRef=%(trans_ref)s' % row
102        href += '&prodID=%(prod_id)s' % info
103        href += '&redirectURL=%(callback_url)s' % row
104        row['href'] = href
105    if payment.status == 'paid':
[2847]106        row['confirmed'] = 'active'
107    else:
108        row['confirmed'] = 'unsuccessful'
109    row['is_editable'] = is_so and (row['confirmed'] == 'active')
110    payments.append(row)
111
[3228]112
113
[2847]114payments.sort(cmp_id)
115info['payments'] = payments
[3228]116
117
[2847]118return info
119
Note: See TracBrowser for help on using the repository browser.