1 | ## Script (Python) "application_edit" |
---|
2 | ##bind container=container |
---|
3 | ##bind context=context |
---|
4 | ##bind namespace= |
---|
5 | ##bind script=script |
---|
6 | ##bind subpath=traverse_subpath |
---|
7 | ##parameters=REQUEST, cpsdocument_edit_button=None, cpsdocument_edit_and_view_button=None, action=None |
---|
8 | ##title= |
---|
9 | # $Id: application_edit.py 892 2006-11-18 21:14:18Z 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 | # 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 | state = context.getStudentInfo()['review_state'] |
---|
33 | is_valid, ds = app_doc.validate(request=REQUEST, |
---|
34 | schema_id = 'student_application', |
---|
35 | layout_id = 'student_application_fe', |
---|
36 | proxy=app, |
---|
37 | use_session=True) |
---|
38 | |
---|
39 | psm = "" |
---|
40 | args = {} |
---|
41 | action = "/application_edit_form" |
---|
42 | base_url = app.absolute_url() |
---|
43 | |
---|
44 | if is_valid: |
---|
45 | if cpsdocument_edit_button: |
---|
46 | if app_doc.passport is not None: |
---|
47 | args['portal_status_message'] = 'You successfully uploaded your passport picture!' |
---|
48 | else: |
---|
49 | args['portal_status_message'] = "You didn't upload a passport picture!" |
---|
50 | elif cpsdocument_edit_and_view_button: |
---|
51 | if app_doc.passport is not None: |
---|
52 | action = "/start_clearance" |
---|
53 | base_url = student.absolute_url() |
---|
54 | url = base_url + action |
---|
55 | return REQUEST.RESPONSE.redirect(url) |
---|
56 | else: |
---|
57 | args['portal_status_message'] = "You didn't upload a passport picture!" |
---|
58 | if args: |
---|
59 | url = base_url + action + '?' + urlencode(args) |
---|
60 | else: |
---|
61 | url = base_url + action |
---|
62 | REQUEST.RESPONSE.redirect(url) |
---|