## Script (Python) "application_edit" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters=REQUEST, cpsdocument_edit_and_view_button=None, action=None, portal_status_message='' ##title= # $Id: application_edit.py 2920 2007-12-11 15:40:35Z henrik $ """ """ wftool = context.portal_workflow from urllib import urlencode from Products.CPSDocument.utils import getFormUidUrlArg import DateTime current = DateTime.DateTime() import logging logger = logging.getLogger('Skins.application_edit') psm = "" args = {} info = context.getApplicationInfo() student = info['student'] if info is None: logger.info('Anonymous user tried to access %s' % REQUEST.get('URL0')) return REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url()) if info['has_passport'] and info['app_doc'].app_email: logger.info('%s proceeded to start clearance' % (info['id'])) action = "/start_clearance" base_url = student.absolute_url() url = base_url + action return REQUEST.RESPONSE.redirect(url) elif not cpsdocument_edit_and_view_button: action = "/application_edit_form" base_url = student.absolute_url() #url = base_url + action if portal_status_message: args['portal_status_message'] = portal_status_message url = base_url + action + '?' + urlencode(args) else: url = base_url + action return REQUEST.RESPONSE.redirect(url) app = info['app'] app_doc = info['app_doc'] state = info['review_state'] is_valid, ds = app_doc.validate(request=REQUEST, schema_id = 'student_application', layout_id = 'student_application', proxy=app, use_session=False) action = "/application_edit" base_url = app.absolute_url() if is_valid: args['portal_status_message'] = "You didn't upload all required data!" else: args['portal_status_message'] = "Please correct your error!" url = base_url + action + '?' + urlencode(args) return REQUEST.RESPONSE.redirect(url)