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

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

testing enabled

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