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, final_submit=None, action=None |
---|
8 | ##title= |
---|
9 | # $Id: clearance_edit.py 832 2006-11-10 16:52:23Z joachim $ |
---|
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 | wftool = context.portal_workflow |
---|
28 | info = context.getStudentInfo() |
---|
29 | |
---|
30 | student = info['student'] |
---|
31 | app = info['app'] |
---|
32 | app_doc = info['app_doc'] |
---|
33 | clear = info['clear'] |
---|
34 | clear_doc = info['clear_doc'] |
---|
35 | state = context.getStudentInfo()['review_state'] |
---|
36 | if final_submit: |
---|
37 | wftool.doActionFor(info['clear'],'close') |
---|
38 | wftool.doActionFor(info['student'],'request_clearance') |
---|
39 | return REQUEST.RESPONSE.redirect("%s/student_index" % info['url']) |
---|
40 | |
---|
41 | is_valid, ds = clear_doc.validate(request=REQUEST, |
---|
42 | schema_id = 'student_clearance', |
---|
43 | layout_id = 'student_clearance_fe', |
---|
44 | proxy=clear, |
---|
45 | use_session=True) |
---|
46 | |
---|
47 | psm = "" |
---|
48 | args = {} |
---|
49 | action = "/clearance_edit_form" |
---|
50 | if cpsdocument_edit_button: |
---|
51 | if is_valid: |
---|
52 | psm = 'Content changed.' |
---|
53 | if ds.get('acknow'): |
---|
54 | args['final_submit'] = "Finally Submit" |
---|
55 | else: |
---|
56 | args = getFormUidUrlArg(REQUEST) |
---|
57 | psm = "Please correct Your errors." |
---|
58 | args['portal_status_message'] = psm |
---|
59 | url = clear.absolute_url() + action + '?' + urlencode(args) |
---|
60 | REQUEST.RESPONSE.redirect(url) |
---|