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, cluster=None, cpsdocument_edit_and_view_button=None, action=None |
---|
8 | ##title= |
---|
9 | # $Id: student_edit_not_used.py 805 2006-11-09 09:38:29Z 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 | 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'] |
---|
35 | |
---|
36 | if context.portal_type == "Student": |
---|
37 | if app_doc.passport is None: |
---|
38 | is_valid, ds = app_doc.validate(request=REQUEST, |
---|
39 | proxy=app_doc, |
---|
40 | layout_id = "student_application_fe", |
---|
41 | layout_mode = 'edit', |
---|
42 | use_session=True) |
---|
43 | action = "/application_edit" |
---|
44 | if is_valid: |
---|
45 | if app_doc.passport is not None: |
---|
46 | psm = 'You successfully uploaded your passport image.' |
---|
47 | args = {'apply_button': 'Apply',} |
---|
48 | else: |
---|
49 | psm = "You didn't upload a passport image." |
---|
50 | args = {} |
---|
51 | else: |
---|
52 | psm = 'psm_content_error' |
---|
53 | args = getFormUidUrlArg(REQUEST) |
---|
54 | elif 'apply_admission' not in REQUEST.form: |
---|
55 | is_valid, ds = app_doc.validate(request=REQUEST, |
---|
56 | proxy=app_doc, |
---|
57 | layout_id = "student_application_fe", |
---|
58 | layout_mode = 'edit', |
---|
59 | use_session=True) |
---|
60 | action = "/application_edit" |
---|
61 | if is_valid: |
---|
62 | args = {} |
---|
63 | if 'apply_admission' not in REQUEST.form: |
---|
64 | args = {'apply_button': 'Apply',} |
---|
65 | psm = 'You successfully uploaded your passport image.' |
---|
66 | else: |
---|
67 | psm = 'You applied for admission.' |
---|
68 | else: |
---|
69 | args = getFormUidUrlArg(REQUEST) |
---|
70 | psm = 'psm_content_error' |
---|
71 | else: |
---|
72 | psm = '' |
---|
73 | args = {} |
---|
74 | if info['review_state'] == "student_created": |
---|
75 | student.content_status_modify(workflow_action="apply_for_admission") |
---|
76 | wftool.doActionFor(app,'close',dest_container= app) |
---|
77 | psm = 'You applied for admission.' |
---|
78 | action = "/application_view" |
---|
79 | elif info['review_state'] == "admitted": |
---|
80 | student.content_status_modify(workflow_action="enter_clearance_pin") |
---|
81 | #wftool.doActionFor(info['clear'],'open',dest_container=info['clear']) |
---|
82 | app_doc = info['app_doc'] |
---|
83 | dc = {} |
---|
84 | dc['email'] = app_doc.app_email |
---|
85 | info['clear_doc'].edit(mapping = dc) |
---|
86 | wftool.doActionFor(app,'close',dest_container= app) |
---|
87 | psm = 'You successfully started the clearance process.' |
---|
88 | action = "/clearance_edit" |
---|
89 | else: |
---|
90 | action = "/clearance_view" |
---|
91 | |
---|
92 | else: |
---|
93 | is_valid, ds = app_doc.validate(request=REQUEST, proxy=context, cluster=cluster, |
---|
94 | use_session=True) |
---|
95 | |
---|
96 | if action is None: |
---|
97 | ti = app.getTypeInfo() |
---|
98 | action = ti.queryMethodID('edit', 'cpsdocument_edit_form') |
---|
99 | action = '/' + action |
---|
100 | |
---|
101 | if is_valid: |
---|
102 | comments = REQUEST.get('comments') |
---|
103 | context.cpsdocument_notify_modification(comments=comments) |
---|
104 | if cpsdocument_edit_and_view_button is not None: |
---|
105 | action = '' |
---|
106 | psm = 'psm_content_changed' |
---|
107 | args = {} |
---|
108 | else: |
---|
109 | psm = 'psm_content_error' |
---|
110 | args = getFormUidUrlArg(REQUEST) |
---|
111 | |
---|
112 | args['portal_status_message'] = psm |
---|
113 | url = context.absolute_url() + action + '?' + urlencode(args) |
---|
114 | REQUEST.RESPONSE.redirect(url) |
---|