source: WAeUP_SRP/fceokene/waeup_custom/getPaymentsFolderInfo.py @ 2878

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

adopt changes from Uniben

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 2480 2007-10-30 15:23:25Z joachim $
11"""
12Info for the PaymentsFolder
13"""
14
15mtool = context.portal_membership
16if mtool.isAnonymousUser():
17    return None
18try:
19    from Products.zdb import set_trace
20except:
21    def set_trace():
22        pass
23
24
25#import logging
26#logger = logging.getLogger('Skins.getPaymentsFolderInfo')
27def cmp_id(a,b):
28    s1 = "%(id)s" % a
29    s2 = "%(id)s" % b
30    if s1 == s2:
31        return 0
32    if s1 > s2:
33        return 1
34    return -1
35
36import DateTime
37request = context.REQUEST
38#students = context.portal_url.getPortalObject().campus.students
39student_id = context.getStudentId()
40if student_id is None:
41    return context.REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url())
42#student = getattr(students,student_id)
43student_record = context.students_catalog.getRecordByKey(student_id)
44context['updatePayments']()
45payments = []
46
47info = {}
48is_so = info['is_so'] = context.isSectionOfficer()
49is_student = info['is_student'] = context.isStudent()
50info['student_name'] = student_record.name
51info['query_url'] = "https://webpay.interswitchng.com/paydirect/services/TransactionQueryURL.aspx"
52review_state = info['review_state'] = student_record.review_state
53parttime = student_record.mode and student_record.mode.endswith('_pt')
54fulltime = student_record.mode and student_record.mode.endswith('_ft')
55
56#if review_state == 'cleared_and_validated' or (parttime and review_state == 'returning'):
57#    online_payment = True
58#elif fulltime and review_state == 'returning':
59#    sc_payment = True
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':
69    info['payment_method'] = "online_payment"
70elif review_state == 'returning' and info['next_session'] != session:
71    info['payment_method'] = "online_payment"
72info['prod_id'] = '83'
73
74info['student_name'] = student_record.name
75payments_path = "%s/campus/students/%s/payments" % (context.portal_url.getPortalPath(),student_id)
76sos = context.portal_catalog(container_path=payments_path)
77info['is_so'] = is_so
78
79for so in sos:
80    row = {}
81    row['id'] = so.getId
82    row['title'] = so.Title
83    url = row['url'] = "%s/%s" % (payments_path,so.getId)
84    so_doc = context.restrictedTraverse(url,default=None).getContent()
85    row['type'] = so.portal_type
86    review_state = row['review_state'] = so.review_state
87    if so_doc.type_description.startswith('School Fee'):
88        row['is_approvable'] = is_so and (review_state == "opened") and info['review_state'] in ('cleared_and_validated','returning')
89    else:
90        row['is_approvable'] = is_so and (review_state == "opened")
91    row['is_requeryable'] = False
92    #set_trace()
93    row['resp_desc'] = getattr(so_doc,'resp_desc','no response')
94    row['trans_ref'] = getattr(so_doc,'order_id','')
95    if so_doc.type_description.startswith('School Fee'):
96        if review_state == 'opened' and info['review_state'] in ('cleared_and_validated','returning') and hasattr(so_doc, 'order_id') and not so_doc.resp_code:
97            row['is_requeryable'] = True
98            row['callback_url'] = "%s/payments/%s/interswitch_cb" % (student.absolute_url(),
99                                                            so.getId)
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 (review_state == "closed") and so_doc.resp_code in ('SC','00','AP','IP',):
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
112payments.sort(cmp_id)
113info['payments'] = payments
114return info
115
Note: See TracBrowser for help on using the repository browser.