source: WAeUP_SRP/trunk/skins/waeup_student/student_edit_not_used.py @ 820

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

propset Id

  • Property svn:keywords set to Id
File size: 4.1 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_not_used.py 805 2006-11-09 09:38:29Z joachim $
10"""
11"""
12wftool = context.portal_workflow
13from urllib import urlencode
14from Products.CPSDocument.utils import getFormUidUrlArg
15import DateTime
16current = DateTime.DateTime()
17
18# Until ajax posts directly to its own script...
19if 'ajax_edit' in REQUEST.form:
20    return context.cpsdocument_edit_ajax(REQUEST, cluster=cluster)
21
22# Check flexible controls
23#context.editLayouts(REQUEST=REQUEST)
24
25# Validate the document and write it if it's valid
26# (We don't call getEditableContent here, validate does it when needed.)
27info = context.getStudentInfo()
28
29student = info['student']
30app = info['app']
31app_doc = info['app_doc']
32clear = info['clear']
33clear_doc = info['clear_doc']
34state = context.getStudentInfo()['review_state']
35
36if context.portal_type == "Student":
37    if app_doc.passport is None:
38        is_valid, ds = app_doc.validate(request=REQUEST,
39                                    proxy=app_doc,
40                                    layout_id = "student_application_fe",
41                                    layout_mode = 'edit',
42                                    use_session=True)
43        action = "/application_edit"
44        if is_valid:
45            if app_doc.passport is not None:
46                psm = 'You successfully uploaded your passport image.'
47                args = {'apply_button': 'Apply',}
48            else:
49                psm = "You didn't upload a passport image."
50                args = {}
51        else:
52            psm = 'psm_content_error'
53            args = getFormUidUrlArg(REQUEST)
54    elif 'apply_admission' not in REQUEST.form:
55        is_valid, ds = app_doc.validate(request=REQUEST,
56                                    proxy=app_doc,
57                                    layout_id = "student_application_fe",
58                                    layout_mode = 'edit',
59                                    use_session=True)
60        action = "/application_edit"
61        if is_valid:
62            args = {}
63            if 'apply_admission' not in REQUEST.form:
64                args = {'apply_button': 'Apply',}
65                psm = 'You successfully uploaded your passport image.'
66            else:
67                psm = 'You applied for admission.'
68        else:
69            args = getFormUidUrlArg(REQUEST)
70            psm = 'psm_content_error'
71    else:
72        psm = ''
73        args = {}
74        if info['review_state'] == "student_created":
75            student.content_status_modify(workflow_action="apply_for_admission")
76            wftool.doActionFor(app,'close',dest_container= app)
77            psm = 'You applied for admission.'
78            action = "/application_view"
79        elif info['review_state'] == "admitted":
80            student.content_status_modify(workflow_action="enter_clearance_pin")
81            #wftool.doActionFor(info['clear'],'open',dest_container=info['clear'])
82            app_doc = info['app_doc']
83            dc = {}
84            dc['email'] = app_doc.app_email
85            info['clear_doc'].edit(mapping = dc)
86            wftool.doActionFor(app,'close',dest_container= app)
87            psm = 'You successfully started the clearance process.'
88            action = "/clearance_edit"
89        else:
90            action = "/clearance_view"
91
92else:
93    is_valid, ds = app_doc.validate(request=REQUEST, proxy=context, cluster=cluster,
94                                use_session=True)
95
96    if action is None:
97        ti = app.getTypeInfo()
98        action = ti.queryMethodID('edit', 'cpsdocument_edit_form')
99        action = '/' + action
100
101    if is_valid:
102        comments = REQUEST.get('comments')
103        context.cpsdocument_notify_modification(comments=comments)
104        if cpsdocument_edit_and_view_button is not None:
105            action = ''
106        psm = 'psm_content_changed'
107        args = {}
108    else:
109        psm = 'psm_content_error'
110        args = getFormUidUrlArg(REQUEST)
111
112args['portal_status_message'] = psm
113url = context.absolute_url() + action + '?' + urlencode(args)
114REQUEST.RESPONSE.redirect(url)
Note: See TracBrowser for help on using the repository browser.