summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Demonte <nicolas@affinitic.be>2019-04-09 13:53:25 (GMT)
committerNicolas Demonte <nicolas@affinitic.be>2019-04-09 13:53:25 (GMT)
commit6eb0c49aca3fe8ffe88b704ab124fd8df6e0eb95 (patch)
treee0895febefcac18c1f603e314b37f54b5ed9b809
parent5598a60ee4c0fd967a1293e49504e4cf72fbe595 (diff)
downloadpfwbged.policy-6eb0c49aca3fe8ffe88b704ab124fd8df6e0eb95.zip
pfwbged.policy-6eb0c49aca3fe8ffe88b704ab124fd8df6e0eb95.tar.gz
pfwbged.policy-6eb0c49aca3fe8ffe88b704ab124fd8df6e0eb95.tar.bz2
Make indexers independent of the user triggering them #22001
-rw-r--r--src/pfwbged/policy/indexers.py73
1 files changed, 38 insertions, 35 deletions
diff --git a/src/pfwbged/policy/indexers.py b/src/pfwbged/policy/indexers.py
index 8e1718c..fe94269 100644
--- a/src/pfwbged/policy/indexers.py
+++ b/src/pfwbged/policy/indexers.py
@@ -41,51 +41,54 @@ grok.global_adapter(recipients_as_text, name='recipients_as_text')
@indexer(IDmsDocument)
def can_last_version_validate(obj, **kw):
- for child in reversed(obj.values()):
- if child.portal_type != 'dmsmainfile':
- continue
- wf_tool = getToolByName(obj, 'portal_workflow')
- workflowActions = wf_tool.listActionInfos(object=child)
- return bool('submit' in [x.get('id') for x in workflowActions])
- return False
+ with api.env.adopt_user('admin'):
+ for child in reversed(obj.values()):
+ if child.portal_type != 'dmsmainfile':
+ continue
+ wf_tool = getToolByName(obj, 'portal_workflow')
+ workflowActions = wf_tool.listActionInfos(object=child)
+ return bool('submit' in [x.get('id') for x in workflowActions])
+ return False
grok.global_adapter(can_last_version_validate, name='can_last_version_validate')
@indexer(IDmsDocument)
def has_last_version_accept(obj, **kw):
- last_version = None
- wf_tool = getToolByName(obj, 'portal_workflow')
- for child in reversed(obj.values()):
- if child.portal_type != 'dmsmainfile':
- continue
- last_version = child
- for task in reversed(obj.values()):
- if task.portal_type != 'validation':
- continue
- if task.target.to_object.Title() != last_version.Title():
+ with api.env.adopt_user('admin'):
+ last_version = None
+ wf_tool = getToolByName(obj, 'portal_workflow')
+ for child in reversed(obj.values()):
+ if child.portal_type != 'dmsmainfile':
continue
- workflowActions = wf_tool.listActionInfos(object=task)
- return bool('validate' in [x.get('id') for x in workflowActions])
- break
- return False
+ last_version = child
+ for task in reversed(obj.values()):
+ if task.portal_type != 'validation':
+ continue
+ if task.target.to_object.Title() != last_version.Title():
+ continue
+ workflowActions = wf_tool.listActionInfos(object=task)
+ return bool('validate' in [x.get('id') for x in workflowActions])
+ break
+ return False
grok.global_adapter(has_last_version_accept, name='has_last_version_accept')
@indexer(IDmsDocument)
def has_last_version_refuse(obj, **kw):
- last_version = None
- wf_tool = getToolByName(obj, 'portal_workflow')
- for child in reversed(obj.values()):
- if child.portal_type != 'dmsmainfile':
- continue
- last_version = child
- for task in reversed(obj.values()):
- if task.portal_type != 'validation':
- continue
- if task.target.to_object.Title() != last_version.Title():
+ with api.env.adopt_user('admin'):
+ last_version = None
+ wf_tool = getToolByName(obj, 'portal_workflow')
+ for child in reversed(obj.values()):
+ if child.portal_type != 'dmsmainfile':
continue
- workflowActions = wf_tool.listActionInfos(object=task)
- return bool('refuse' in [x.get('id') for x in workflowActions])
- break
- return False
+ last_version = child
+ for task in reversed(obj.values()):
+ if task.portal_type != 'validation':
+ continue
+ if task.target.to_object.Title() != last_version.Title():
+ continue
+ workflowActions = wf_tool.listActionInfos(object=task)
+ return bool('refuse' in [x.get('id') for x in workflowActions])
+ break
+ return False
grok.global_adapter(has_last_version_refuse, name='has_last_version_refuse')