## Script (Python) "content_status_modify"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=REQUEST, RESPONSE, workflow_action, comment=''
##title=Modify the status of a content object
##
# Perform the transition

from AccessControl import getSecurityManager
checkPermission = getSecurityManager().checkPermission

context.portal_workflow.doActionFor(context, workflow_action, comment=comment)

from DateTime import DateTime
from Products.PythonScripts.standard import url_quote_plus

msg = 'Status changed %s.'%DateTime().strftime('%d.%m.%Y %H:%M')

if checkPermission('Modify portal content', context):
  target = context.getTypeInfo().getActionById('edit')
else:
  target = context.getTypeInfo().getActionById('view')

redirect_url = '%s/%s?portal_status_message=%s'%(context.absolute_url(), target, url_quote_plus(msg))
  
RESPONSE.redirect( redirect_url )
