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

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

changed button text to Apply

  • Property svn:keywords set to Id
File size: 3.5 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=
[486]9# $Id: student_edit.py 541 2006-09-20 13:54:07Z joachim $
[478]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"""
[539]22wftool = context.portal_workflow
[478]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
[486]31#context.editLayouts(REQUEST=REQUEST)
[478]32
33# Validate the document and write it if it's valid
34# (We don't call getEditableContent here, validate does it when needed.)
[535]35info = context.getStudentInfo()
[478]36
[535]37student = info['student']
38app = info['app']
39app_doc = info['app_doc']
40state = context.getStudentInfo()['review_state']
41
42if context.portal_type == "Student":
43    if app_doc.passport is None:
44        is_valid, ds = app_doc.validate(request=REQUEST,
45                                    proxy=app_doc,
[479]46                                    layout_id = "student_application_fe",
47                                    layout_mode = 'edit',
48                                    use_session=True)
[539]49        action = "/passport_entry_view"
50        if is_valid and app_doc.passport is not None:
[483]51            psm = 'You successfully uploaded your passport image.'
[541]52            args = {'apply_button': 'Apply',}
[539]53        else:
54            psm = "You didn't upload a passport image."
[479]55            args = {}
[535]56    elif 'apply_admission' not in REQUEST.form:
57        is_valid, ds = app_doc.validate(request=REQUEST,
58                                    proxy=app_doc,
59                                    layout_id = "student_application_fe",
60                                    layout_mode = 'edit',
61                                    use_session=True)
62        action = "/passport_entry_view"
63        if is_valid:
64            args = {}
65            if 'apply_admission' not in REQUEST.form:
[541]66                args = {'apply_button': 'Apply',}
[535]67                psm = 'You successfully uploaded your passport image.'
68            else:
69                psm = 'You applied for admission.'
70        else:
71            args = getFormUidUrlArg(REQUEST)
[539]72            psm = 'psm_content_error'
[479]73    else:
[482]74        args = {}
[540]75        student.content_status_modify(workflow_action="apply_for_admission")
[539]76        wftool.doActionFor(app,'close',dest_container= app)
[535]77        psm = 'You applied for admission.'
78        action = "/application_view"
[478]79else:
[535]80    is_valid, ds = app_doc.validate(request=REQUEST, proxy=context, cluster=cluster,
[479]81                                use_session=True)
[483]82
[479]83    if action is None:
[535]84        ti = app.getTypeInfo()
[479]85        action = ti.queryMethodID('edit', 'cpsdocument_edit_form')
86        action = '/' + action
[483]87
[479]88    if is_valid:
89        comments = REQUEST.get('comments')
90        context.cpsdocument_notify_modification(comments=comments)
91        if cpsdocument_edit_and_view_button is not None:
92            action = ''
93        psm = 'psm_content_changed'
94        args = {}
95    else:
96        psm = 'psm_content_error'
97        args = getFormUidUrlArg(REQUEST)
[483]98
[478]99args['portal_status_message'] = psm
100url = context.absolute_url() + action + '?' + urlencode(args)
101REQUEST.RESPONSE.redirect(url)
Note: See TracBrowser for help on using the repository browser.