[788] | 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 |
---|
| 7 | ##parameters=REQUEST,proceed=None, cpsdocument_edit_button=None, action=None |
---|
| 8 | ##title= |
---|
[805] | 9 | # $Id: clearance_edit.py 805 2006-11-09 09:38:29Z joachim $ |
---|
[788] | 10 | """ |
---|
| 11 | """ |
---|
| 12 | wftool = context.portal_workflow |
---|
| 13 | from urllib import urlencode |
---|
| 14 | from Products.CPSDocument.utils import getFormUidUrlArg |
---|
| 15 | import DateTime |
---|
| 16 | current = DateTime.DateTime() |
---|
| 17 | |
---|
| 18 | # Until ajax posts directly to its own script... |
---|
| 19 | ##if 'ajax_edit' in REQUEST.form: |
---|
| 20 | ## return context.cpsdocument_edit_ajax(REQUEST, cluster=cluster) |
---|
| 21 | |
---|
| 22 | # Check flexible controls |
---|
| 23 | #context.editLayouts(REQUEST=REQUEST) |
---|
| 24 | |
---|
| 25 | # Validate the document and write it if it's valid |
---|
| 26 | # (We don't call getEditableContent here, validate does it when needed.) |
---|
| 27 | info = context.getStudentInfo() |
---|
| 28 | |
---|
| 29 | student = info['student'] |
---|
| 30 | app = info['app'] |
---|
| 31 | app_doc = info['app_doc'] |
---|
| 32 | clear = info['clear'] |
---|
| 33 | clear_doc = info['clear_doc'] |
---|
| 34 | state = context.getStudentInfo()['review_state'] |
---|
[801] | 35 | is_valid, ds = clear_doc.validate(request=REQUEST, |
---|
[788] | 36 | schema_id = 'student_clearance', |
---|
| 37 | layout_id = 'student_clearance_fe', |
---|
| 38 | proxy=clear, |
---|
| 39 | use_session=True) |
---|
| 40 | |
---|
| 41 | psm = "" |
---|
| 42 | args = {} |
---|
[789] | 43 | action = "/clearance_edit_form" |
---|
[788] | 44 | if cpsdocument_edit_button: |
---|
| 45 | if is_valid: |
---|
| 46 | psm = 'Content changed.' |
---|
| 47 | else: |
---|
| 48 | args = getFormUidUrlArg(REQUEST) |
---|
| 49 | psm = "Please correct Your errors." |
---|
| 50 | args['portal_status_message'] = psm |
---|
| 51 | url = clear.absolute_url() + action + '?' + urlencode(args) |
---|
| 52 | REQUEST.RESPONSE.redirect(url) |
---|