def __call__(self): context = self.context request = self.request policy_ids = request.get('policy_ids', []) policy_id = request.get('policy_id', None) delete = request.get('delete', None) add = request.get('add', None) policy_duplicate_id = request.get('policy_duplicate_id', 'empty') pwtool = getToolByName(context, 'portal_placeful_workflow') plone_utils = getToolByName(context, 'plone_utils') if delete and policy_ids: for policy_id in policy_ids: if policy_id in pwtool.objectIds(): pwtool.manage_delObjects([policy_id, ]) plone_utils.addPortalMessage(_(u'Deleted Local Workflow Policy.'), 'info') return request.response.redirect('prefs_workflow_localpolicies_form') elif add: if policy_id: pwtool.manage_addWorkflowPolicy(id=policy_id, duplicate_id=policy_duplicate_id) plone_utils.addPortalMessage(_(u'Local Workflow Policy added.'), 'info') return request.response.redirect('prefs_workflow_policy_mapping?wfpid=' + policy_id) else: plone_utils.addPortalMessage(_(u'The policy Id is required.'), 'error') return request.response.redirect('prefs_workflow_localpolicies_form') return self.index()
def __call__(self): request = self.request if not request.get('submit', None): return self.index() context = self.context plone_utils = getToolByName(context, 'plone_utils') wfpid = request.get('wfpid', None) if not wfpid: plone_utils.addPortalMessage(_(u'No Policy selected.'), 'error') return request.response.redirect(portal_url + '/@@prefs_workflow_localpolicies_form') tool = getToolByName(context, 'portal_placeful_workflow') policy = tool.getWorkflowPolicyById(wfpid) title = request.get('title', None) description = request.get('description', None) default_workflow_id = request.get('default_workflow_id', None) wf = request.get('wf', None) if title: plone_utils.addPortalMessage(title) policy.setTitle(title) else: plone_utils.addPortalMessage(_(u'Title is required.'), 'error') return request.response.redirect('@@prefs_workflow_policy_mapping?wfpid=%s' % wfpid) policy.setDescription(description) policy.setDefaultChain( default_chain=(default_workflow_id, ), REQUEST=request) # for filtering special option values CHAIN_MAP = {'acquisition': None, '': ()} for pt, wflow in list(wf.items()): if wflow in CHAIN_MAP: chain = CHAIN_MAP[wflow] else: chain = (wflow, ) policy.setChain(portal_type=pt, chain=chain, REQUEST=request) wf_tool = getToolByName(context, 'portal_workflow') wf_tool.updateRoleMappings() plone_utils.addPortalMessage(_(u'Changes to criteria saved.')) return request.response.redirect('prefs_workflow_policy_mapping?wfpid=%s' % wfpid)
def __call__(self): context = self.context request = self.request policy_in = request.form.get('policy_in', None) policy_below = request.form.get('policy_below', None) # Form submission will either have update_security as a key # meaning user wants to do it OR no key at all. If this script # is called directly, we use the parameter update_security = request.form.get('update_security', None) if 'add_wp_for_type' in request.form: context.manage_addProduct['CMFPlacefulWorkflow'].manage_addWorkflowPolicyConfig(request) context.plone_utils.addPortalMessage(_(u'Workflow policy configuration added.')) return request.response.redirect('placeful_workflow_configuration') # This script is used for both the save and cancel button cancel = False submit = request.form.get('submit', None) if not submit: return self.index() if submit is not None and submit == 'Cancel': cancel = True message = _(u'Configuration changes cancelled.') if not cancel: tool = getToolByName(context, 'portal_placeful_workflow') config = tool.getWorkflowPolicyConfig(context) if not config: message = _(u'No config in this folder.') else: if not tool.isValidPolicyName(policy_in) and not policy_in == '': raise AttributeError("%s is not a valid policy id" % policy_in) if not tool.isValidPolicyName(policy_below) and not policy_below == '': raise AttributeError("%s is not a valid policy id" % policy_below) config.setPolicyIn(policy_in, update_security) config.setPolicyBelow(policy_below, update_security) message = _('Changed policies.') context.plone_utils.addPortalMessage(message) return request.response.redirect('placeful_workflow_configuration')
request = context.REQUEST policy_ids = request.get('policy_ids', []) policy_id = request.get('policy_id', None) policy_duplicate_id = request.get('policy_duplicate_id', 'empty') pwtool = getToolByName(context, 'portal_placeful_workflow') plone_utils = getToolByName(context, 'plone_utils') if delete and policy_ids: for policy_id in policy_ids: if policy_id in pwtool.objectIds(): pwtool.manage_delObjects([ policy_id, ]) plone_utils.addPortalMessage(_(u'Deleted Local Workflow Policy.'), 'info') request.RESPONSE.redirect('prefs_workflow_localpolicies_form') elif add: if policy_id: pwtool.manage_addWorkflowPolicy(id=policy_id, duplicate_id=policy_duplicate_id) plone_utils.addPortalMessage(_(u'Local Workflow Policy added.'), 'info') request.RESPONSE.redirect('prefs_workflow_policy_mapping?wfpid=' + policy_id) else: plone_utils.addPortalMessage(_(u'The policy Id is required.'), 'error') request.RESPONSE.redirect('prefs_workflow_localpolicies_form')
##parameters=submit, wfpid, title, description, wf, default_workflow_id ##title=set local workflow policy mapping #-*- coding: utf-8 -*- from Products.CMFCore.utils import getToolByName from Products.CMFPlacefulWorkflow import CMFPlacefulWorkflowMessageFactory as _ request = context.REQUEST policy = getToolByName(context, 'portal_placeful_workflow').getWorkflowPolicyById(wfpid) policy.setTitle(title) policy.setDescription(description) policy.setDefaultChain(default_chain=(default_workflow_id,),REQUEST=context.REQUEST) for pt, wf in wf.items(): policy.setChain(portal_type=pt, chain=(wf,),REQUEST=context.REQUEST) wf_tool = getToolByName(context, 'portal_workflow') wf_tool.updateRoleMappings() context.plone_utils.addPortalMessage(_(u'Changes to criteria saved.')) if request: request.RESPONSE.redirect('prefs_workflow_policy_mapping?wfpid=%s' % wfpid) return request
##parameters=policy_in='', policy_below='', update_security=True ##title=set placeful workflow configuration ## from Products.CMFCore.utils import getToolByName from Products.CMFPlacefulWorkflow import CMFPlacefulWorkflowMessageFactory as _ request = context.REQUEST # This script is used for both the save and cancel button cancel = False submit = request.form.get('submit', None) if submit is not None and submit == 'Cancel': cancel = True message = _(u'Configuration changes cancelled.') if not cancel: config = getToolByName(context, 'portal_placeful_workflow').getWorkflowPolicyConfig(context) if not config: message = _(u'No config in this folder.') else: if not context.portal_placeful_workflow.isValidPolicyName(policy_in) \ and not policy_in == '': raise AttributeError("%s is not a valid policy id" % policy_in) if not context.portal_placeful_workflow.isValidPolicyName(policy_below) \ and not policy_below == '': raise AttributeError("%s is not a valid policy id" % policy_below) config.setPolicyIn(policy_in, update_security) config.setPolicyBelow(policy_below, update_security)
##parameters=delete=None, add=None ##title=set local workflow policies prefs ## from Products.CMFPlacefulWorkflow import CMFPlacefulWorkflowMessageFactory as _ from Products.CMFCore.utils import getToolByName request = context.REQUEST policy_ids = request.get('policy_ids',[]) policy_id = request.get('policy_id', None) policy_duplicate_id = request.get('policy_duplicate_id', 'empty') pwtool = getToolByName(context, 'portal_placeful_workflow') if delete and policy_ids: for policy_id in policy_ids: if policy_id in pwtool.objectIds(): pwtool.manage_delObjects([policy_id,]) context.plone_utils.addPortalMessage(_(u'Deleted Local Workflow Policy.')) context.REQUEST.RESPONSE.redirect('prefs_workflow_localpolicies_form') elif add and policy_id: pwtool.manage_addWorkflowPolicy(id=policy_id, duplicate_id=policy_duplicate_id) context.plone_utils.addPortalMessage(_(u'Local Workflow Policy added.')) context.REQUEST.RESPONSE.redirect('prefs_workflow_policy_mapping?wfpid='+policy_id)
## from Products.CMFPlacefulWorkflow import CMFPlacefulWorkflowMessageFactory as _ from Products.CMFCore.utils import getToolByName request = context.REQUEST policy_ids = request.get('policy_ids',[]) policy_id = request.get('policy_id', None) policy_duplicate_id = request.get('policy_duplicate_id', 'empty') pwtool = getToolByName(context, 'portal_placeful_workflow') plone_utils = getToolByName(context, 'plone_utils') if delete and policy_ids: for policy_id in policy_ids: if policy_id in pwtool.objectIds(): pwtool.manage_delObjects([policy_id,]) plone_utils.addPortalMessage(_(u'Deleted Local Workflow Policy.'), 'info') request.RESPONSE.redirect('prefs_workflow_localpolicies_form') elif add: if policy_id: pwtool.manage_addWorkflowPolicy(id=policy_id, duplicate_id=policy_duplicate_id) plone_utils.addPortalMessage(_(u'Local Workflow Policy added.'), 'info') request.RESPONSE.redirect('prefs_workflow_policy_mapping?wfpid='+policy_id) else: plone_utils.addPortalMessage(_(u'The policy Id is required.'), 'error') request.RESPONSE.redirect('prefs_workflow_localpolicies_form')
##title=set local workflow policy mapping #-*- coding: utf-8 -*- from Products.CMFCore.utils import getToolByName from Products.CMFPlacefulWorkflow import CMFPlacefulWorkflowMessageFactory as _ plone_utils = getToolByName(context, 'plone_utils') request = context.REQUEST policy = getToolByName(context, 'portal_placeful_workflow').getWorkflowPolicyById(wfpid) if title: plone_utils.addPortalMessage(title) policy.setTitle(title) else: plone_utils.addPortalMessage(_(u'Title is required.'), 'error') if request: request.RESPONSE.redirect('prefs_workflow_policy_mapping?wfpid=%s' % wfpid) return request policy.setDescription(description) policy.setDefaultChain(default_chain=(default_workflow_id, ), REQUEST=context.REQUEST) # for filtering special option values CHAIN_MAP = {'acquisition': None, '': ()} for pt, wf in wf.items(): if wf in CHAIN_MAP: chain = CHAIN_MAP[wf] else: chain = (wf, )
##parameters= ##title=add workflow policy configuration ## from Products.CMFPlacefulWorkflow import CMFPlacefulWorkflowMessageFactory as _ context.manage_addProduct['CMFPlacefulWorkflow'].manage_addWorkflowPolicyConfig() context.plone_utils.addPortalMessage(_(u'Workflow policy configuration added.')) context.REQUEST.RESPONSE.redirect('placeful_workflow_configuration')
##parameters=policy_in='', policy_below='' ##title=set placeful workflow configuration ## from Products.CMFCore.utils import getToolByName from Products.CMFPlacefulWorkflow import CMFPlacefulWorkflowMessageFactory as _ request = context.REQUEST config = getToolByName(context, 'portal_placeful_workflow').getWorkflowPolicyConfig(context) if not config: message = _(u'No config in this folder.') else: if context.portal_placeful_workflow.getWorkflowPolicyById(policy_in): config.setPolicyIn(policy=policy_in) elif policy_in == '': config.setPolicyIn(policy='') else: raise str(policy_in) if context.portal_placeful_workflow.getWorkflowPolicyById(policy_below): config.setPolicyBelow(policy=policy_below) elif policy_below == '': config.setPolicyBelow(policy='') else: raise str(policy_below) message = _('Changed policies.') getToolByName(context, 'portal_workflow').updateRoleMappings() context.plone_utils.addPortalMessage(message) request.RESPONSE.redirect('placeful_workflow_configuration')
from Products.CMFCore.utils import getToolByName from Products.CMFPlacefulWorkflow import CMFPlacefulWorkflowMessageFactory as _ request = context.REQUEST # Form submission will either have update_security as a key # meaning user wants to do it OR no key at all. If this script # is called directly, we use the parameter update_security = ('update_security' in request.form) or update_security # This script is used for both the save and cancel button cancel = False submit = request.form.get('submit', None) if submit is not None and submit == 'Cancel': cancel = True message = _(u'Configuration changes cancelled.') if not cancel: tool = getToolByName(context, 'portal_placeful_workflow') config = tool.getWorkflowPolicyConfig(context) if not config: message = _(u'No config in this folder.') else: if not tool.isValidPolicyName(policy_in) and not policy_in == '': raise AttributeError("%s is not a valid policy id" % policy_in) if not tool.isValidPolicyName(policy_below) and not policy_below == '': raise AttributeError("%s is not a valid policy id" % policy_below) config.setPolicyIn(policy_in, update_security) config.setPolicyBelow(policy_below, update_security)