source: WAeUP_SRP/trunk/skins/waeup_student/application_edit.py @ 1146

Last change on this file since 1146 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
RevLine 
[845]1## Script (Python) "application_edit"
[478]2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
[851]7##parameters=REQUEST, cpsdocument_edit_button=None, cpsdocument_edit_and_view_button=None, action=None
[478]8##title=
[486]9# $Id: application_edit.py 1071 2006-12-16 15:53:13Z joachim $
[478]10"""
11"""
[539]12wftool = context.portal_workflow
[478]13from urllib import urlencode
14from Products.CPSDocument.utils import getFormUidUrlArg
[766]15import DateTime
16current = DateTime.DateTime()
[1016]17import logging
[1054]18logger = logging.getLogger('Student.Application.Edit')
[478]19
20# Until ajax posts directly to its own script...
[788]21##if 'ajax_edit' in REQUEST.form:
22##    return context.cpsdocument_edit_ajax(REQUEST, cluster=cluster)
[478]23
24# Check flexible controls
[486]25#context.editLayouts(REQUEST=REQUEST)
[478]26
27# Validate the document and write it if it's valid
28# (We don't call getEditableContent here, validate does it when needed.)
[1071]29info = context.getApplicationInfo()
[478]30
[1016]31if info is None:
[1024]32    logger.info('"anonymous access","%s"' % REQUEST.get('URL0'))
33    return REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url())
[1017]34
[535]35student = info['student']
36app = info['app']
37app_doc = info['app_doc']
[1071]38state = info['review_state']
[796]39is_valid, ds = app_doc.validate(request=REQUEST,
[788]40                                schema_id = 'student_application',
41                                layout_id = 'student_application_fe',
42                                proxy=app,
[479]43                                use_session=True)
[483]44
[788]45psm = ""
46args = {}
[794]47action = "/application_edit_form"
48base_url = app.absolute_url()
[796]49
[851]50if is_valid:
51    if cpsdocument_edit_button:
[788]52        if app_doc.passport is not None:
[892]53            args['portal_status_message'] = 'You successfully uploaded your passport picture!'
[788]54        else:
[892]55            args['portal_status_message'] = "You didn't upload a passport picture!"
[851]56    elif cpsdocument_edit_and_view_button:
57        if app_doc.passport is not None:
[1024]58            logger.info('"%s", "proceeded to start clearance"' % (info['id']))
[851]59            action = "/start_clearance"
60            base_url = student.absolute_url()
61            url = base_url + action
62            return REQUEST.RESPONSE.redirect(url)
63        else:
[892]64            args['portal_status_message'] = "You didn't upload a passport picture!"
[796]65if args:
66  url = base_url + action + '?' + urlencode(args)
67else:
68  url = base_url + action
[478]69REQUEST.RESPONSE.redirect(url)
Note: See TracBrowser for help on using the repository browser.