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

Last change on this file since 769 was 767, checked in by Henrik Bettermann, 18 years ago

changes made on the phone

  • Property svn:keywords set to Id
File size: 4.2 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 767 2006-10-27 18:41:45Z henrik $
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 = "/passport_entry_view"
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 = "/passport_entry_view"
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.appl_email
85            dc['mobil'] = app_doc.appl_mobile
86            info['clear_doc'].edit(mapping = dc)
87            wftool.doActionFor(app,'close',dest_container= app)
88            psm = 'You successfully started the clearance process.'
89            action = "/clearance_view"
90        else:
91            action = "/clearance_view"
92
93else:
94    is_valid, ds = app_doc.validate(request=REQUEST, proxy=context, cluster=cluster,
95                                use_session=True)
96
97    if action is None:
98        ti = app.getTypeInfo()
99        action = ti.queryMethodID('edit', 'cpsdocument_edit_form')
100        action = '/' + action
101
102    if is_valid:
103        comments = REQUEST.get('comments')
104        context.cpsdocument_notify_modification(comments=comments)
105        if cpsdocument_edit_and_view_button is not None:
106            action = ''
107        psm = 'psm_content_changed'
108        args = {}
109    else:
110        psm = 'psm_content_error'
111        args = getFormUidUrlArg(REQUEST)
112
113args['portal_status_message'] = psm
114url = context.absolute_url() + action + '?' + urlencode(args)
115REQUEST.RESPONSE.redirect(url)
Note: See TracBrowser for help on using the repository browser.