Back to index

plone3  3.1.7
prefs_workflow_localpolicies_set.py
Go to the documentation of this file.
00001 ##parameters=delete=None, add=None
00002 ##title=set local workflow policies prefs
00003 ##
00004 
00005 from Products.CMFPlacefulWorkflow import CMFPlacefulWorkflowMessageFactory as _
00006 from Products.CMFCore.utils import getToolByName
00007 
00008 request = context.REQUEST
00009 
00010 policy_ids = request.get('policy_ids',[])
00011 policy_id = request.get('policy_id', None)
00012 policy_duplicate_id = request.get('policy_duplicate_id', 'empty')
00013 
00014 pwtool = getToolByName(context, 'portal_placeful_workflow')
00015 
00016 if delete and policy_ids:
00017     for policy_id in policy_ids:
00018         if policy_id in pwtool.objectIds():
00019             pwtool.manage_delObjects([policy_id,])
00020     context.plone_utils.addPortalMessage(_(u'Deleted Local Workflow Policy.'))
00021     context.REQUEST.RESPONSE.redirect('prefs_workflow_localpolicies_form')
00022 
00023 elif add and policy_id:
00024     pwtool.manage_addWorkflowPolicy(id=policy_id, duplicate_id=policy_duplicate_id)
00025     context.plone_utils.addPortalMessage(_(u'Local Workflow Policy added.'))
00026     context.REQUEST.RESPONSE.redirect('prefs_workflow_policy_mapping?wfpid='+policy_id)