source: WAeUP_SRP/trunk/skins/waeup_student/request_transfer.py @ 11110

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

remove redundent payment fields

  • Property svn:keywords set to Id
File size: 3.7 KB
RevLine 
[1321]1## Script (Python) "request_transfer"
[1319]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: request_transfer.py 2877 2007-12-07 22:20:37Z henrik $
11"""
12pay online
13"""
14import logging
15from urllib import urlencode
[1571]16logger = logging.getLogger('Skins_request_transfer')
[1319]17import DateTime
18lt = context.portal_layouts
19request = context.REQUEST
20students = context.portal_url.getPortalObject().campus.students
21
[1340]22mtool = context.portal_membership
[1356]23if mtool.isAnonymousUser():
24    return context.REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url())
25
[1340]26member = mtool.getAuthenticatedMember()
27member_id = str(member)
28requested_id = context.getStudentId()
29if requested_id and not context.isStaff() and member_id != requested_id:
[1571]30    logger.info('%s tried to access object of %s' % (member_id,requested_id))
[1340]31    student_id = requested_id
[1571]32    return None
[1340]33elif context.isStaff():
34    student_id = requested_id
35else:
36    student_id = member_id
[1319]37if student_id is None:
38    return request.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url())
39
40student = getattr(students,student_id)
41sbrain = context.students_catalog(id=student_id)[0]
[1327]42payments = getattr(student,'payments').objectIds()
[1340]43paid = False
[1327]44for payment in payments:
45    if payment.startswith('transfer'):
[1340]46        paid = True
[1327]47        break
[1332]48
49# for testing of transfer forms
[1340]50#paid = True
[1338]51
[1340]52if paid:
[1571]53    logger.info('%s opened (paid) request transfer form of %s' % (member_id,student_id))
[1327]54    return context.request_transfer_form(rendered = None,
55                                 psm = None,
[1340]56                                 paid = True,
[1327]57                                 )
[1332]58
[1319]59validate = request.has_key("cpsdocument_create_button")
60res,psm,ds = lt.renderLayout(layout_id= 'student_transfer',
61                      schema_id= 'epayment',
62                      context=context,
63                      mapping=validate and request,
64                      ob={},
65                      layout_mode="create",
66                      formaction = "request_transfer",
67                      button = 'Start'
68                      )
69if psm == 'invalid':
70    psm = 'Please correct your errors!'
71    return context.request_transfer_form(rendered = res,
72                                 psm = psm,
73                                 mode = 'edit',
74                                 ds = ds,
75                                 )
76elif psm == '':
77    return context.request_transfer_form(rendered = res,
78                                 psm = None,
79                                 mode = 'edit',
80                                 ds = ds,
81                                 )
82elif psm == 'valid':
83    pass
84if "payments" not in student.objectIds():
85    student.invokeFactory('PaymentsFolder','payments')
86    payments = getattr(student,'payments')
87    d = {}
88    d['Title'] = 'Payments'
89    payments.getContent().edit(mapping=d)
90    wftool.doActionFor(payments,'open')
91else:
92    payments = getattr(student,'payments')
93#from Products.zdb import set_trace; set_trace()
[1571]94
95logger.info('%s paid transfer form for %s' % (member_id,student_id))
[1319]96info = {}
97order_id = ds.get('pin_n')
[1327]98p_id = "transfer_%s" % order_id
[1319]99now = DateTime.DateTime()
100info['date'] = now
101info['amount'] = "n/a"
102pin = info['order_id'] = ds.get('pin')
[2877]103#info['type_code'] = "%s" % pin
[2661]104info['type_description'] = 'Transfer Form'
[1371]105info['resp_code'] = "SC"
106info['resp_desc'] = "SC Payment Successful"
[1319]107payments.invokeFactory('Payment', p_id)
108payment = getattr(payments,p_id)
109wftool = context.portal_workflow
110wftool.doActionFor(payment,'open')
111payment.getContent().edit(mapping=info)
112wftool.doActionFor(payment,'close')
[1327]113return context.request_transfer_form(rendered = None,
114                                 psm = None,
[1340]115                                 paid = True,
[1327]116                                 )
[1319]117
Note: See TracBrowser for help on using the repository browser.