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

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

added WAeUPImage Widget

  • Property svn:keywords set to Id
File size: 3.5 KB
Line 
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# $Id: student_edit.py 537 2006-09-20 06:40:54Z joachim $
10"""
11Called when a document form is posted.
12
13Validates data, then:
14
15 - if there's no error, updates the object and redirects to it,
16
17 - if there's an error, puts data in session and redirects to edit form.
18
19A form uid is propagated during the redirect to uniquely identify the
20form in the session.
21"""
22
23from urllib import urlencode
24from Products.CPSDocument.utils import getFormUidUrlArg
25
26# Until ajax posts directly to its own script...
27if 'ajax_edit' in REQUEST.form:
28    return context.cpsdocument_edit_ajax(REQUEST, cluster=cluster)
29
30# Check flexible controls
31#context.editLayouts(REQUEST=REQUEST)
32
33# Validate the document and write it if it's valid
34# (We don't call getEditableContent here, validate does it when needed.)
35info = context.getStudentInfo()
36
37student = info['student']
38app = info['app']
39app_doc = info['app_doc']
40state = context.getStudentInfo()['review_state']
41
42if context.portal_type == "Student":
43    if state == "application_pin_entered":
44        student.content_status_modify(workflow_action="apply_for_admission")
45    if app_doc.passport is None:
46        is_valid, ds = app_doc.validate(request=REQUEST,
47                                    proxy=app_doc,
48                                    layout_id = "student_application_fe",
49                                    layout_mode = 'edit',
50                                    use_session=True)
51   
52        action = "/student_edit"
53        if is_valid:
54            psm = 'You successfully uploaded your passport image.'
55            args = {}
56        else:
57            psm = 'psm_content_error'
58            args = getFormUidUrlArg(REQUEST)
59    elif 'apply_admission' not in REQUEST.form:
60        is_valid, ds = app_doc.validate(request=REQUEST,
61                                    proxy=app_doc,
62                                    layout_id = "student_application_fe",
63                                    layout_mode = 'edit',
64                                    use_session=True)
65        action = "/passport_entry_view"
66        if is_valid:
67            args = {}
68            if 'apply_admission' not in REQUEST.form:
69                args = {'apply_button': 'Save and Apply',}
70                psm = 'You successfully uploaded your passport image.'
71            else:
72                psm = 'You applied for admission.'
73        else:
74            args = getFormUidUrlArg(REQUEST)
75            #psm = 'psm_content_error'
76            psm = '%s' % ds
77    else:
78        args = {}
79        psm = 'You applied for admission.'
80        action = "/application_view"
81else:
82    is_valid, ds = app_doc.validate(request=REQUEST, proxy=context, cluster=cluster,
83                                use_session=True)
84
85    if action is None:
86        ti = app.getTypeInfo()
87        action = ti.queryMethodID('edit', 'cpsdocument_edit_form')
88        action = '/' + action
89
90    if is_valid:
91        comments = REQUEST.get('comments')
92        context.cpsdocument_notify_modification(comments=comments)
93        if cpsdocument_edit_and_view_button is not None:
94            action = ''
95        psm = 'psm_content_changed'
96        args = {}
97    else:
98        info['app'].content_status_modify(workflow_action="close")
99        psm = 'psm_content_error'
100        args = getFormUidUrlArg(REQUEST)
101
102args['portal_status_message'] = psm
103url = context.absolute_url() + action + '?' + urlencode(args)
104REQUEST.RESPONSE.redirect(url)
Note: See TracBrowser for help on using the repository browser.