[845] | 1 | ## Script (Python) "application_edit" |
---|
[478] | 2 | ##bind container=container |
---|
| 3 | ##bind context=context |
---|
| 4 | ##bind namespace= |
---|
| 5 | ##bind script=script |
---|
| 6 | ##bind subpath=traverse_subpath |
---|
[851] | 7 | ##parameters=REQUEST, cpsdocument_edit_button=None, cpsdocument_edit_and_view_button=None, action=None |
---|
[478] | 8 | ##title= |
---|
[486] | 9 | # $Id: application_edit.py 1343 2007-01-23 16:50:50Z henrik $ |
---|
[478] | 10 | """ |
---|
| 11 | """ |
---|
[539] | 12 | wftool = context.portal_workflow |
---|
[478] | 13 | from urllib import urlencode |
---|
| 14 | from Products.CPSDocument.utils import getFormUidUrlArg |
---|
[766] | 15 | import DateTime |
---|
| 16 | current = DateTime.DateTime() |
---|
[1016] | 17 | import logging |
---|
[1054] | 18 | logger = logging.getLogger('Student.Application.Edit') |
---|
[478] | 19 | |
---|
| 20 | # Until ajax posts directly to its own script... |
---|
[788] | 21 | ##if 'ajax_edit' in REQUEST.form: |
---|
| 22 | ## return context.cpsdocument_edit_ajax(REQUEST, cluster=cluster) |
---|
[478] | 23 | |
---|
| 24 | # Check flexible controls |
---|
[486] | 25 | #context.editLayouts(REQUEST=REQUEST) |
---|
[478] | 26 | |
---|
| 27 | # Validate the document and write it if it's valid |
---|
| 28 | # (We don't call getEditableContent here, validate does it when needed.) |
---|
[1071] | 29 | info = context.getApplicationInfo() |
---|
[478] | 30 | |
---|
[1016] | 31 | if info is None: |
---|
[1024] | 32 | logger.info('"anonymous access","%s"' % REQUEST.get('URL0')) |
---|
| 33 | return REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url()) |
---|
[1017] | 34 | |
---|
[535] | 35 | student = info['student'] |
---|
| 36 | app = info['app'] |
---|
| 37 | app_doc = info['app_doc'] |
---|
[1071] | 38 | state = info['review_state'] |
---|
[796] | 39 | is_valid, ds = app_doc.validate(request=REQUEST, |
---|
[788] | 40 | schema_id = 'student_application', |
---|
| 41 | layout_id = 'student_application_fe', |
---|
| 42 | proxy=app, |
---|
[479] | 43 | use_session=True) |
---|
[483] | 44 | |
---|
[788] | 45 | psm = "" |
---|
| 46 | args = {} |
---|
[794] | 47 | action = "/application_edit_form" |
---|
| 48 | base_url = app.absolute_url() |
---|
[796] | 49 | |
---|
[851] | 50 | if is_valid: |
---|
| 51 | if cpsdocument_edit_button: |
---|
[788] | 52 | if app_doc.passport is not None: |
---|
[892] | 53 | args['portal_status_message'] = 'You successfully uploaded your passport picture!' |
---|
[788] | 54 | else: |
---|
[892] | 55 | args['portal_status_message'] = "You didn't upload a passport picture!" |
---|
[851] | 56 | elif cpsdocument_edit_and_view_button: |
---|
[1343] | 57 | if 1: ## app_doc.passport is not None: |
---|
[1024] | 58 | logger.info('"%s", "proceeded to start clearance"' % (info['id'])) |
---|
[851] | 59 | action = "/start_clearance" |
---|
| 60 | base_url = student.absolute_url() |
---|
| 61 | url = base_url + action |
---|
| 62 | return REQUEST.RESPONSE.redirect(url) |
---|
| 63 | else: |
---|
[892] | 64 | args['portal_status_message'] = "You didn't upload a passport picture!" |
---|
[796] | 65 | if args: |
---|
| 66 | url = base_url + action + '?' + urlencode(args) |
---|
| 67 | else: |
---|
| 68 | url = base_url + action |
---|
[478] | 69 | REQUEST.RESPONSE.redirect(url) |
---|