[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 1321 2007-01-19 11:03:16Z henrik $ |
---|
| 11 | """ |
---|
| 12 | pay online |
---|
| 13 | """ |
---|
| 14 | import logging |
---|
| 15 | from urllib import urlencode |
---|
| 16 | logger = logging.getLogger('EPayment.') |
---|
| 17 | import DateTime |
---|
| 18 | lt = context.portal_layouts |
---|
| 19 | request = context.REQUEST |
---|
| 20 | students = context.portal_url.getPortalObject().campus.students |
---|
| 21 | |
---|
| 22 | student_id = context.getStudentId() |
---|
| 23 | if student_id is None: |
---|
| 24 | return request.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url()) |
---|
| 25 | |
---|
| 26 | student = getattr(students,student_id) |
---|
| 27 | sbrain = context.students_catalog(id=student_id)[0] |
---|
| 28 | |
---|
| 29 | validate = request.has_key("cpsdocument_create_button") |
---|
| 30 | res,psm,ds = lt.renderLayout(layout_id= 'student_transfer', |
---|
| 31 | schema_id= 'epayment', |
---|
| 32 | context=context, |
---|
| 33 | mapping=validate and request, |
---|
| 34 | ob={}, |
---|
| 35 | layout_mode="create", |
---|
| 36 | formaction = "request_transfer", |
---|
| 37 | button = 'Start' |
---|
| 38 | ) |
---|
| 39 | if psm == 'invalid': |
---|
| 40 | psm = 'Please correct your errors!' |
---|
| 41 | return context.request_transfer_form(rendered = res, |
---|
| 42 | psm = psm, |
---|
| 43 | mode = 'edit', |
---|
| 44 | ds = ds, |
---|
| 45 | ) |
---|
| 46 | elif psm == '': |
---|
| 47 | return context.request_transfer_form(rendered = res, |
---|
| 48 | psm = None, |
---|
| 49 | mode = 'edit', |
---|
| 50 | ds = ds, |
---|
| 51 | ) |
---|
| 52 | elif psm == 'valid': |
---|
| 53 | pass |
---|
| 54 | if "payments" not in student.objectIds(): |
---|
| 55 | student.invokeFactory('PaymentsFolder','payments') |
---|
| 56 | payments = getattr(student,'payments') |
---|
| 57 | d = {} |
---|
| 58 | d['Title'] = 'Payments' |
---|
| 59 | payments.getContent().edit(mapping=d) |
---|
| 60 | wftool.doActionFor(payments,'open') |
---|
| 61 | else: |
---|
| 62 | payments = getattr(student,'payments') |
---|
| 63 | #from Products.zdb import set_trace; set_trace() |
---|
| 64 | info = {} |
---|
| 65 | order_id = ds.get('pin_n') |
---|
| 66 | p_id = "p%s" % order_id |
---|
| 67 | now = DateTime.DateTime() |
---|
| 68 | info['date'] = now |
---|
| 69 | info['amount'] = "n/a" |
---|
| 70 | pin = info['order_id'] = ds.get('pin') |
---|
| 71 | info['type_code'] = "%s" % pin |
---|
[1321] | 72 | info['type_description'] = 'Transfer Form SC %s' % pin |
---|
[1319] | 73 | payments.invokeFactory('Payment', p_id) |
---|
| 74 | payment = getattr(payments,p_id) |
---|
| 75 | wftool = context.portal_workflow |
---|
| 76 | wftool.doActionFor(payment,'open') |
---|
| 77 | payment.getContent().edit(mapping=info) |
---|
| 78 | wftool.doActionFor(payment,'close') |
---|
| 79 | url = "%s/payments" % (student.absolute_url()) |
---|
| 80 | request.RESPONSE.redirect(url) |
---|
| 81 | |
---|