source: WAeUP_SRP/branches/regebro-noskins/skins/waeup_student/request_transfer.py @ 5536

Last change on this file since 5536 was 1378, checked in by Henrik Bettermann, 18 years ago

remove 'transfer_' from type_code again

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