source: WAeUP_SRP/trunk/skins/waeup_epayment/getPaymentsFolderInfo.py @ 1943

Last change on this file since 1943 was 1938, checked in by joachim, 18 years ago

missing for epayment

  • Property svn:keywords set to Id
File size: 3.1 KB
RevLine 
[1568]1## Script (Python) "getPaymentsFolderInfo"
[1238]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 1938 2007-06-19 17:28:07Z joachim $
11"""
12Info for the PaymentsFolder
13"""
[1783]14
15mtool = context.portal_membership
16if mtool.isAnonymousUser():
17    return None
[1845]18try:
19    from Products.zdb import set_trace
20except:
21    def set_trace():
22        pass
[1783]23
24
[1568]25#import logging
26#logger = logging.getLogger('Skins.getPaymentsFolderInfo')
[1661]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
[1568]35
[1238]36import DateTime
37request = context.REQUEST
38students = 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())
[1938]42student = getattr(students,student_id)
[1338]43s_brain = context.students_catalog(id = student_id)[0]
[1427]44
[1238]45payments = []
[1283]46#from Products.zdb import set_trace;set_trace()
[1427]47
[1238]48info = {}
49is_so = info['is_so'] = context.isSectionOfficer()
[1938]50info['query_url'] = "https://webpay.interswitchng.com/TransactionQuery.aspx"
51info['prod_id'] = '61'
[1758]52#res = context.portal_catalog(portal_type='Student',id = student_id)
53#res = context.students_catalog(id = student_id)
54info['review_state'] = s_brain.review_state
55session = s_brain.session
56info['next_session'], info['next_session_str'] = context.getNextSessionId(session)
[1427]57
[1238]58info['student_name'] = s_brain.name
[1427]59payments_path = "%s/campus/students/%s/payments" % (context.portal_url.getPortalPath(),student_id)
60sos = context.portal_catalog(container_path=payments_path)
61info['is_so'] = is_so
62
63for so in sos:
64    row = {}
65    row['id'] = so.getId
66    row['title'] = so.Title
67    url = row['url'] = "%s/%s" % (payments_path,so.getId)
68    so_object = context.restrictedTraverse(url,default=None).getContent()
69    row['type'] = so.portal_type
70    review_state = row['review_state'] = so.review_state
71    if so_object.type_description.startswith('School Fee'):
72        row['is_approvable'] = is_so and (review_state == "opened") and info['review_state'] == 'cleared_and_validated'
73    else:
74        row['is_approvable'] = is_so and (review_state == "opened")
[1938]75    row['is_requeryable'] = False
[1613]76    if so_object.type_description.startswith('School Fee'):
[1938]77        if (review_state == "opened") and\
78           info['review_state'] == 'cleared_and_validated' and\
79           not hasattr(so,'resp_code') and hasattr(so, 'order_id'):
80            row['is_requeryable'] = True
81            row['trans_ref'] = getattr(so,'order_id')
82            row['callback_url'] = "%s/payments/p%s/interswitch_cb?echo=p%s" % (student.absolute_url(),
83                                                                  so.order_id,
84                                                                  so.order_id)
[1634]85    if (review_state == "closed") and so_object.resp_code in ('SC','00','AP','IP',):
[1427]86        row['confirmed'] = 'active'
87    else:
[1431]88        row['confirmed'] = 'unsuccessful'
[1427]89    payments.append(row)
90
[1661]91payments.sort(cmp_id)
[1238]92info['payments'] = payments
93return info
[1431]94
Note: See TracBrowser for help on using the repository browser.