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

Last change on this file since 1331 was 1327, checked in by joachim, 18 years ago

request_transfer_form is directly shown, if transferfee is payed.

  • 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 1327 2007-01-19 18:14:23Z joachim $
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
34if payed:
35    return context.request_transfer_form(rendered = None,
36                                 psm = None,
37                                 payed = True,
38                                 )
39   
40validate = request.has_key("cpsdocument_create_button")
41res,psm,ds = lt.renderLayout(layout_id= 'student_transfer',
42                      schema_id= 'epayment',
43                      context=context,
44                      mapping=validate and request,
45                      ob={},
46                      layout_mode="create",
47                      formaction = "request_transfer",
48                      button = 'Start'
49                      )
50if psm == 'invalid':
51    psm = 'Please correct your errors!'
52    return context.request_transfer_form(rendered = res,
53                                 psm = psm,
54                                 mode = 'edit',
55                                 ds = ds,
56                                 )
57elif psm == '':
58    return context.request_transfer_form(rendered = res,
59                                 psm = None,
60                                 mode = 'edit',
61                                 ds = ds,
62                                 )
63elif psm == 'valid':
64    pass
65if "payments" not in student.objectIds():
66    student.invokeFactory('PaymentsFolder','payments')
67    payments = getattr(student,'payments')
68    d = {}
69    d['Title'] = 'Payments'
70    payments.getContent().edit(mapping=d)
71    wftool.doActionFor(payments,'open')
72else:
73    payments = getattr(student,'payments')
74#from Products.zdb import set_trace; set_trace()
75info = {}
76order_id = ds.get('pin_n')
77p_id = "transfer_%s" % order_id
78now = DateTime.DateTime()
79info['date'] = now
80info['amount'] = "n/a"
81pin = info['order_id'] = ds.get('pin')
82info['type_code'] = "transfer_%s" % pin
83info['type_description'] = 'Transfer Form SC %s' % pin
84payments.invokeFactory('Payment', p_id)
85payment = getattr(payments,p_id)
86wftool = context.portal_workflow
87wftool.doActionFor(payment,'open')
88payment.getContent().edit(mapping=info)
89wftool.doActionFor(payment,'close')
90return context.request_transfer_form(rendered = None,
91                                 psm = None,
92                                 payed = True,
93                                 )
94
Note: See TracBrowser for help on using the repository browser.