[478] | 1 | ## Script (Python) "cpsdocument_edit" |
---|
| 2 | ##bind container=container |
---|
| 3 | ##bind context=context |
---|
| 4 | ##bind namespace= |
---|
| 5 | ##bind script=script |
---|
| 6 | ##bind subpath=traverse_subpath |
---|
[788] | 7 | ##parameters=REQUEST,proceed=None, cpsdocument_edit_button=None, action=None |
---|
[478] | 8 | ##title= |
---|
[486] | 9 | # $Id: application_edit.py 788 2006-11-08 08:32:36Z joachim $ |
---|
[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() |
---|
[478] | 17 | |
---|
| 18 | # Until ajax posts directly to its own script... |
---|
[788] | 19 | ##if 'ajax_edit' in REQUEST.form: |
---|
| 20 | ## return context.cpsdocument_edit_ajax(REQUEST, cluster=cluster) |
---|
[478] | 21 | |
---|
| 22 | # Check flexible controls |
---|
[486] | 23 | #context.editLayouts(REQUEST=REQUEST) |
---|
[478] | 24 | |
---|
| 25 | # Validate the document and write it if it's valid |
---|
| 26 | # (We don't call getEditableContent here, validate does it when needed.) |
---|
[535] | 27 | info = context.getStudentInfo() |
---|
[478] | 28 | |
---|
[535] | 29 | student = info['student'] |
---|
| 30 | app = info['app'] |
---|
| 31 | app_doc = info['app_doc'] |
---|
[766] | 32 | clear = info['clear'] |
---|
| 33 | clear_doc = info['clear_doc'] |
---|
[535] | 34 | state = context.getStudentInfo()['review_state'] |
---|
[788] | 35 | is_valid, ds = app_doc.validate(request=REQUEST, |
---|
| 36 | schema_id = 'student_application', |
---|
| 37 | layout_id = 'student_application_fe', |
---|
| 38 | proxy=app, |
---|
[479] | 39 | use_session=True) |
---|
[483] | 40 | |
---|
[788] | 41 | psm = "" |
---|
| 42 | args = {} |
---|
| 43 | action = "/application_edit_view" |
---|
| 44 | if cpsdocument_edit_button: |
---|
[479] | 45 | if is_valid: |
---|
[788] | 46 | if app_doc.passport is not None: |
---|
| 47 | args['proceed'] = 'Continue to Clearance' |
---|
| 48 | psm = 'You successfully uploaded your passport image.' |
---|
| 49 | else: |
---|
| 50 | psm = "You didn't upload a passport image." |
---|
| 51 | elif proceed: |
---|
| 52 | if is_valid: |
---|
| 53 | action = "/request_clearance" |
---|
[479] | 54 | else: |
---|
| 55 | psm = 'psm_content_error' |
---|
[478] | 56 | args['portal_status_message'] = psm |
---|
[788] | 57 | url = app.absolute_url() + action + '?' + urlencode(args) |
---|
[478] | 58 | REQUEST.RESPONSE.redirect(url) |
---|