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

Last change on this file since 17367 was 4002, checked in by Henrik Bettermann, 16 years ago

just in case

I didn't like it because personal object will be closed instead of created .

  • Property svn:keywords set to Id
File size: 2.4 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
[2920]7##parameters=REQUEST, cpsdocument_edit_and_view_button=None, action=None, portal_status_message=''
[478]8##title=
[486]9# $Id: application_edit.py 4002 2009-03-06 18:19:15Z henrik $
[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
[1571]18logger = logging.getLogger('Skins.application_edit')
[478]19
[2920]20psm = ""
21args = {}
[478]22
[1071]23info = context.getApplicationInfo()
[478]24
[2920]25student = info['student']
26
[1016]27if info is None:
[1866]28    logger.info('Anonymous user tried to access %s' % REQUEST.get('URL0'))
[1024]29    return REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url())
[1017]30
[2920]31if info['has_passport'] and info['app_doc'].app_email:
32    logger.info('%s proceeded to start clearance' % (info['id']))
[4002]33    #personal_doc = student.personal.getContent()
34    #try:
35    #    wftool.doActionFor(student.personal,'open')
36    #except:
37    #    pass
38    #personal_doc.edit(mapping = {'email' : info['app_doc'].app_email})
39    #wftool.doActionFor(student.personal,'close')
[2920]40    action = "/start_clearance"
41    base_url = student.absolute_url()
42    url = base_url + action
43    return REQUEST.RESPONSE.redirect(url)
44elif not cpsdocument_edit_and_view_button:
45    action = "/application_edit_form"
46    base_url = student.absolute_url()
47    #url = base_url + action
48    if portal_status_message:
49        args['portal_status_message'] = portal_status_message
50        url = base_url + action + '?' + urlencode(args)
51    else:
52        url = base_url + action
53    return REQUEST.RESPONSE.redirect(url)
54
55
56
[535]57app = info['app']
58app_doc = info['app_doc']
[1071]59state = info['review_state']
[3749]60
61app_review_state = wftool.getInfoFor(app,'review_state',None)
62if app_review_state != 'opened':
63    wftool.doActionFor(app,'open')
64
[796]65is_valid, ds = app_doc.validate(request=REQUEST,
[788]66                                schema_id = 'student_application',
[2579]67                                layout_id = 'student_application',
[788]68                                proxy=app,
[2390]69                                use_session=False)
[483]70
[2920]71
72action = "/application_edit"
[794]73base_url = app.absolute_url()
[796]74
[851]75if is_valid:
[2920]76    args['portal_status_message'] = "You didn't upload all required data!"
77
[796]78else:
[2920]79    args['portal_status_message'] = "Please correct your error!"
80
81url = base_url + action + '?' + urlencode(args)
82
83
84 
85return REQUEST.RESPONSE.redirect(url)
Note: See TracBrowser for help on using the repository browser.