source: WAeUP_SRP/trunk/skins/waeup_student/student_edit.py @ 512

Last change on this file since 512 was 486, checked in by joachim, 18 years ago

svn -R propset svn:keywords "Id" .
added layout_application_/edit/create/view
and cleaned that up.

  • Property svn:keywords set to Id
File size: 2.9 KB
RevLine 
[478]1## Script (Python) "cpsdocument_edit"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=REQUEST, cluster=None, cpsdocument_edit_and_view_button=None, action=None
8##title=
9##
[486]10# $Id: student_edit.py 486 2006-09-06 10:09:39Z joachim $
[478]11"""
12Called when a document form is posted.
13
14Validates data, then:
15
16 - if there's no error, updates the object and redirects to it,
17
18 - if there's an error, puts data in session and redirects to edit form.
19
20A form uid is propagated during the redirect to uniquely identify the
21form in the session.
22"""
23
24from urllib import urlencode
25from Products.CPSDocument.utils import getFormUidUrlArg
26
27# Until ajax posts directly to its own script...
28if 'ajax_edit' in REQUEST.form:
29    return context.cpsdocument_edit_ajax(REQUEST, cluster=cluster)
30
31# Check flexible controls
[486]32#context.editLayouts(REQUEST=REQUEST)
[478]33
34# Validate the document and write it if it's valid
35# (We don't call getEditableContent here, validate does it when needed.)
36doc = context.getContent()
37
[479]38if context.portal_type == "StudentApplication":
39    student = context.aq_parent
40    if context.portal_workflow.getInfoFor(student,'review_state',None) == "application_pin_entered":
41        student.content_status_modify(workflow_action="apply_for_admission")
[483]42        is_valid, ds = doc.validate(request=REQUEST,
43                                    proxy=context,
[479]44                                    layout_id = "student_application_fe",
45                                    layout_mode = 'edit',
46                                    use_session=True)
[483]47
[479]48        action = '/application_form'
[483]49
[479]50        if is_valid:
51            comments = REQUEST.get('comments')
52            context.cpsdocument_notify_modification(comments=comments)
53            if cpsdocument_edit_and_view_button is not None:
54                action = ''
[483]55            psm = 'You successfully uploaded your passport image.'
[479]56            args = {}
[482]57            action = "/view"
[479]58        else:
59            psm = 'psm_content_error'
60            args = getFormUidUrlArg(REQUEST)
61    else:
[482]62        args = {}
[483]63        psm = "You successfully applied for admission."
[479]64        action = "/view"
[478]65else:
[479]66    is_valid, ds = doc.validate(request=REQUEST, proxy=context, cluster=cluster,
67                                use_session=True)
[483]68
[479]69    if action is None:
70        ti = doc.getTypeInfo()
71        action = ti.queryMethodID('edit', 'cpsdocument_edit_form')
72        action = '/' + action
[483]73
[479]74    if is_valid:
75        comments = REQUEST.get('comments')
76        context.cpsdocument_notify_modification(comments=comments)
77        if cpsdocument_edit_and_view_button is not None:
78            action = ''
79        psm = 'psm_content_changed'
80        args = {}
81    else:
82        psm = 'psm_content_error'
83        args = getFormUidUrlArg(REQUEST)
[483]84
[478]85args['portal_status_message'] = psm
86url = context.absolute_url() + action + '?' + urlencode(args)
87REQUEST.RESPONSE.redirect(url)
Note: See TracBrowser for help on using the repository browser.