source: WAeUP_SRP/trunk/skins/waeup_student/clearance_edit.py @ 984

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

reserve_accommodation only allowed for cleared_and_validated
several bugs fixed

  • Property svn:keywords set to Id
File size: 2.8 KB
Line 
1## Script (Python) "clearance_edit"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=REQUEST, acknowledge=None
8##title=
9# $Id: clearance_edit.py 942 2006-11-25 21:09:18Z henrik $
10"""
11"""
12wftool = context.portal_workflow
13from urllib import urlencode
14from Products.CPSDocument.utils import getFormUidUrlArg
15import DateTime
16current = DateTime.DateTime()
17
18cpsdocument_edit_button = REQUEST.has_key('cpsdocument_edit_button')
19cpsdocument_edit_and_view_button = REQUEST.has_key('cpsdocument_edit_and_view_button')
20clear_and_validate_button = REQUEST.has_key('clear_and_validate_button')
21reject_clearance_button = REQUEST.has_key('reject_clearance_button')
22
23# Until ajax posts directly to its own script...
24##if 'ajax_edit' in REQUEST.form:
25##    return context.cpsdocument_edit_ajax(REQUEST, cluster=cluster)
26
27# Validate the document and write it if it's valid
28# (We don't call getEditableContent here, validate does it when needed.)
29wftool = context.portal_workflow
30info = context.getStudentInfo()
31
32student = info['student']
33app = info['app']
34app_doc = info['app_doc']
35clear = info['clear']
36clear_doc = info['clear_doc']
37
38is_valid, ds = clear_doc.validate(request=REQUEST,
39                                schema_id = 'student_clearance',
40                                layout_id = 'student_clearance',
41                                proxy=clear,
42                                use_session=True)
43
44psm = ""
45args = {}
46action = "/external_clearance_edit_form"
47if is_valid:
48    if cpsdocument_edit_button:
49        psm = "Content changed!"
50        if context.isStudent():
51           action = "/clearance_edit_form"       
52    elif cpsdocument_edit_and_view_button:
53        if acknowledge:
54            wftool.doActionFor(info['clear'],'close')
55            wftool.doActionFor(info['student'],'request_clearance',dest_container=1)
56            psm = "You successfully requested clearance!"
57            if context.isStudent():
58               action = "/clearance_view"
59        else:
60            psm = "You must tick the acknowledgement check box before submission!"
61            if context.isStudent():
62               action = "/clearance_edit_form"
63    elif clear_and_validate_button:
64        wftool.doActionFor(info['student'],'clear_and_validate')
65        psm = "Clearance and eligibility record is validated and and student is cleared!"
66    elif reject_clearance_button:
67        wftool.doActionFor(info['clear'],'open')
68        wftool.doActionFor(info['student'],'reject_clearance')
69        action = "/contact_student_form"
70        psm = "Student's clearance request has been rejected! Please fill and submit the form below!"
71else:
72    psm = "Please correct your errors!"
73    args = getFormUidUrlArg(REQUEST)
74
75args['portal_status_message'] = psm
76url = clear.absolute_url() + action + '?' + urlencode(args)
77REQUEST.RESPONSE.redirect(url)
Note: See TracBrowser for help on using the repository browser.