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 1024 2006-12-10 15:10:32Z 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 | import logging |
---|
18 | logger = logging.getLogger('Student.application_edit') |
---|
19 | |
---|
20 | # Until ajax posts directly to its own script... |
---|
21 | ##if 'ajax_edit' in REQUEST.form: |
---|
22 | ## return context.cpsdocument_edit_ajax(REQUEST, cluster=cluster) |
---|
23 | |
---|
24 | # Check flexible controls |
---|
25 | #context.editLayouts(REQUEST=REQUEST) |
---|
26 | |
---|
27 | # Validate the document and write it if it's valid |
---|
28 | # (We don't call getEditableContent here, validate does it when needed.) |
---|
29 | info = context.getStudentInfo() |
---|
30 | |
---|
31 | if info is None: |
---|
32 | logger.info('"anonymous access","%s"' % REQUEST.get('URL0')) |
---|
33 | return REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url()) |
---|
34 | |
---|
35 | student = info['student'] |
---|
36 | app = info['app'] |
---|
37 | app_doc = info['app_doc'] |
---|
38 | state = context.getStudentInfo()['review_state'] |
---|
39 | is_valid, ds = app_doc.validate(request=REQUEST, |
---|
40 | schema_id = 'student_application', |
---|
41 | layout_id = 'student_application_fe', |
---|
42 | proxy=app, |
---|
43 | use_session=True) |
---|
44 | |
---|
45 | psm = "" |
---|
46 | args = {} |
---|
47 | action = "/application_edit_form" |
---|
48 | base_url = app.absolute_url() |
---|
49 | |
---|
50 | if is_valid: |
---|
51 | if cpsdocument_edit_button: |
---|
52 | if app_doc.passport is not None: |
---|
53 | args['portal_status_message'] = 'You successfully uploaded your passport picture!' |
---|
54 | else: |
---|
55 | args['portal_status_message'] = "You didn't upload a passport picture!" |
---|
56 | elif cpsdocument_edit_and_view_button: |
---|
57 | if app_doc.passport is not None: |
---|
58 | logger.info('"%s", "proceeded to start clearance"' % (info['id'])) |
---|
59 | action = "/start_clearance" |
---|
60 | base_url = student.absolute_url() |
---|
61 | url = base_url + action |
---|
62 | return REQUEST.RESPONSE.redirect(url) |
---|
63 | else: |
---|
64 | args['portal_status_message'] = "You didn't upload a passport picture!" |
---|
65 | if args: |
---|
66 | url = base_url + action + '?' + urlencode(args) |
---|
67 | else: |
---|
68 | url = base_url + action |
---|
69 | REQUEST.RESPONSE.redirect(url) |
---|