source: WAeUP_SRP/branches/srpp_on_branch/skins/waeup_student/application_edit.py @ 11096

Last change on this file since 11096 was 1071, checked in by joachim, 18 years ago

speed improvements for waeup_edit and portlet_session_info

  • Property svn:keywords set to Id
File size: 2.3 KB
Line 
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 1071 2006-12-16 15:53:13Z joachim $
10"""
11"""
12wftool = context.portal_workflow
13from urllib import urlencode
14from Products.CPSDocument.utils import getFormUidUrlArg
15import DateTime
16current = DateTime.DateTime()
17import logging
18logger = 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.)
29info = context.getApplicationInfo()
30
31if 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
35student = info['student']
36app = info['app']
37app_doc = info['app_doc']
38state = info['review_state']
39is_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
45psm = ""
46args = {}
47action = "/application_edit_form"
48base_url = app.absolute_url()
49
50if 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!"
65if args:
66  url = base_url + action + '?' + urlencode(args)
67else:
68  url = base_url + action
69REQUEST.RESPONSE.redirect(url)
Note: See TracBrowser for help on using the repository browser.