1 | ## Script (Python) "clearance_edit" |
---|
2 | ##bind container=container |
---|
3 | ##bind context=context |
---|
4 | ##bind namespace= |
---|
5 | ##bind script=script |
---|
6 | ##bind subpath=traverse_subpath |
---|
7 | ##parameters=REQUEST |
---|
8 | ##title= |
---|
9 | # $Id: clearance_edit.py 891 2006-11-18 20:59:12Z henrik $ |
---|
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 | cpsdocument_edit_button = REQUEST.has_key('cpsdocument_edit_button') |
---|
19 | cpsdocument_edit_and_view_button = REQUEST.has_key('cpsdocument_edit_and_view_button') |
---|
20 | clear_and_validate_button = REQUEST.has_key('clear_and_validate_button') |
---|
21 | reject_clearance_button = REQUEST.has_key('reject_clearance_button') |
---|
22 | # Until ajax posts directly to its own script... |
---|
23 | ##if 'ajax_edit' in REQUEST.form: |
---|
24 | ## return context.cpsdocument_edit_ajax(REQUEST, cluster=cluster) |
---|
25 | |
---|
26 | # Validate the document and write it if it's valid |
---|
27 | # (We don't call getEditableContent here, validate does it when needed.) |
---|
28 | wftool = context.portal_workflow |
---|
29 | info = context.getStudentInfo() |
---|
30 | |
---|
31 | student = info['student'] |
---|
32 | app = info['app'] |
---|
33 | app_doc = info['app_doc'] |
---|
34 | clear = info['clear'] |
---|
35 | clear_doc = info['clear_doc'] |
---|
36 | |
---|
37 | is_valid, ds = clear_doc.validate(request=REQUEST, |
---|
38 | schema_id = 'student_clearance', |
---|
39 | layout_id = 'student_clearance', |
---|
40 | proxy=clear, |
---|
41 | use_session=True) |
---|
42 | |
---|
43 | psm = "" |
---|
44 | args = {} |
---|
45 | action = "/clearance_edit_form" |
---|
46 | if is_valid: |
---|
47 | if cpsdocument_edit_button: |
---|
48 | psm = "Content changed!" |
---|
49 | elif cpsdocument_edit_and_view_button: |
---|
50 | wftool.doActionFor(info['clear'],'close') |
---|
51 | wftool.doActionFor(info['student'],'request_clearance',dest_container=1) |
---|
52 | psm = "You successfully requested clearance!" |
---|
53 | elif clear_and_validate_button: |
---|
54 | wftool.doActionFor(info['student'],'clear_and_validate') |
---|
55 | psm = "Clearance and eligibility record is validated and and student is cleared!" |
---|
56 | elif reject_clearance_button: |
---|
57 | wftool.doActionFor(info['clear'],'open') |
---|
58 | wftool.doActionFor(info['student'],'reject_clearance') |
---|
59 | action = "/contact_student_form" |
---|
60 | psm = "Student's clearance request has been rejected! Please fill and submit the form below!" |
---|
61 | else: |
---|
62 | psm = "Please correct your errors!" |
---|
63 | args = getFormUidUrlArg(REQUEST) |
---|
64 | |
---|
65 | |
---|
66 | |
---|
67 | args['portal_status_message'] = psm |
---|
68 | url = clear.absolute_url() + action + '?' + urlencode(args) |
---|
69 | REQUEST.RESPONSE.redirect(url) |
---|