source: WAeUP_SRP/trunk/skins/waeup_student/clearance_edit_manager.py @ 866

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

clearance_edit_manager + clearance_edit_form_manager modified that all
buttons are shown according to the student's workflow-state.
The waeup_student_wf was modified, to allow the transitions
Even though the enter_clearance_pin-transition is allowed for Manager
in the clearance_requested state, the reject_clearance button does not work.

File size: 2.4 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
8##title=
9# $Id: clearance_edit.py 852 2006-11-12 21:21:07Z 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')
21undo_clear_button = REQUEST.has_key('undo_clear_button')
22reject_clearance_button = REQUEST.has_key('reject_clearance_button')
23
24# Until ajax posts directly to its own script...
25##if 'ajax_edit' in REQUEST.form:
26##    return context.cpsdocument_edit_ajax(REQUEST, cluster=cluster)
27
28# Validate the document and write it if it's valid
29# (We don't call getEditableContent here, validate does it when needed.)
30wftool = context.portal_workflow
31info = context.getStudentInfo()
32
33student = info['student']
34app = info['app']
35app_doc = info['app_doc']
36clear = info['clear']
37clear_doc = info['clear_doc']
38review_state = info['review_state']
39
40is_valid, ds = clear_doc.validate(request=REQUEST,
41                                schema_id = 'student_clearance',
42                                layout_id = 'student_clearance',
43                                proxy=clear,
44                                use_session=True)
45
46psm = ""
47args = {}
48action = "/clearance_edit_form_manager"
49if is_valid:
50    if cpsdocument_edit_button:
51        psm = 'Content changed.'
52    elif cpsdocument_edit_and_view_button:
53        wftool.doActionFor(info['clear'],'close')
54        wftool.doActionFor(info['student'],'request_clearance')
55    elif clear_and_validate_button:
56        wftool.doActionFor(info['student'],'clear_and_validate')
57    elif reject_clearance_button:
58        wftool.doActionFor(info['clear'],'open')
59        wftool.doActionFor(info['student'],'enter_clearance_pin')
60    elif undo_clear_button:
61        wftool.doActionFor(info['student'],'request_clearance')
62else:
63    psm = "Please correct your errors."
64args = getFormUidUrlArg(REQUEST)
65args['review_state'] = review_state
66args['portal_status_message'] = psm
67if args:
68  url = clear.absolute_url() + action + '?' + urlencode(args)
69else:
70  url = clear.absolute_url() + action
71REQUEST.RESPONSE.redirect(url)
Note: See TracBrowser for help on using the repository browser.