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

Last change on this file since 1389 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
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 1378 2007-01-30 18:55:59Z henrik $
11"""
12pay online
13"""
14import logging
15from urllib import urlencode
[1340]16logger = logging.getLogger('Student.Transfer.Request')
[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:
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
[1319]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]
[1327]41payments = getattr(student,'payments').objectIds()
[1340]42paid = False
[1327]43for payment in payments:
44    if payment.startswith('transfer'):
[1340]45        paid = True
[1327]46        break
[1332]47
48# for testing of transfer forms
[1340]49#paid = True
[1338]50
[1340]51if paid:
52    logger.info('"%s", "opened (paid) request transfer form of", "%s"' % (member_id,student_id))
[1327]53    return context.request_transfer_form(rendered = None,
54                                 psm = None,
[1340]55                                 paid = True,
[1327]56                                 )
[1332]57
[1319]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')
[1327]95p_id = "transfer_%s" % order_id
[1319]96now = DateTime.DateTime()
97info['date'] = now
98info['amount'] = "n/a"
99pin = info['order_id'] = ds.get('pin')
[1378]100info['type_code'] = "%s" % pin
[1371]101info['type_description'] = 'Transfer Form for Session 2006/2007'
102info['resp_code'] = "SC"
103info['resp_desc'] = "SC Payment Successful"
[1319]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')
[1327]110return context.request_transfer_form(rendered = None,
111                                 psm = None,
[1340]112                                 paid = True,
[1327]113                                 )
[1319]114
Note: See TracBrowser for help on using the repository browser.