source: WAeUP_SRP/trunk/skins/waeup_custom/content_status_modify.py @ 890

Last change on this file since 890 was 486, checked in by joachim, 18 years ago

svn -R propset svn:keywords "Id" .
added layout_application_/edit/create/view
and cleaned that up.

  • Property svn:keywords set to Id
File size: 2.6 KB
Line 
1## Script (Python) "content_status_modify"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=workflow_action, REQUEST=None, **kw
8##title=
9##
10# $Id: content_status_modify.py 486 2006-09-06 10:09:39Z joachim $
11"""
12FIXME: add docstring.
13"""
14
15wftool = context.portal_workflow
16
17if REQUEST is not None:
18    kw.update(REQUEST.form)
19
20comments = kw.get('comments', '')
21
22folder = context.aq_parent
23id = context.getId()
24url = None
25
26psm = 'psm_status_changed'
27
28if workflow_action in ('retract','approve'):
29    # accept, reject, ...
30    if comments:
31        del kw['comments']
32    kw['comment'] = comments
33    res = wftool.doActionFor(context, workflow_action, dest_container=context, **kw)
34    if same_type(res, ()):
35        if res[0] == 'ObjectMoved':
36            rpath = res[1]
37            url = context.portal_url()
38            if not url.endswith('/'):
39                url += '/'
40            url += rpath
41elif workflow_action != 'copy_submit':
42    # accept, reject, ...
43    if comments:
44        del kw['comments']
45    kw['comment'] = comments
46    res = wftool.doActionFor(context, workflow_action, **kw)
47    if same_type(res, ()):
48        if res[0] == 'ObjectMoved':
49            rpath = res[1]
50            url = context.portal_url()
51            if not url.endswith('/'):
52                url += '/'
53            url += rpath
54else:
55    # No section has been specified
56    # XXX We should get a list in here
57    if REQUEST and len(REQUEST.form) < 3:
58        psm = 'psm_you_must_select_sections_for_publishing'
59
60    # publishing: copy and initalize proxy into one or more sections
61    allowed_transitions = wftool.getAllowedPublishingTransitions(context)
62    for transition in allowed_transitions:
63        rpaths = kw.get(transition)
64        if rpaths:
65            if same_type(rpaths, ''):
66                rpaths = (rpaths,)
67            for rpath in rpaths:
68                wftool.doActionFor(context, workflow_action,
69                                   dest_container=rpath,
70                                   initial_transition=transition,
71                                   comment=comments)
72
73if REQUEST is not None:
74    # If the object has been deleted, we can't redirect to it.
75    if url is None:
76        if id in folder.objectIds():
77            url = context.absolute_url()
78        else:
79            url = folder.absolute_url()
80
81    if psm == 'psm_you_must_select_sections_for_publishing':
82        redirect_url = '%s/content_submit_form?%s' % (
83            url, 'portal_status_message=%s'%psm)
84    else:
85        redirect_url = '%s/?%s' % (url, 'portal_status_message=%s'%psm)
86    REQUEST.RESPONSE.redirect(redirect_url)
Note: See TracBrowser for help on using the repository browser.