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

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

make transfer work

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