Make indexers independent of the user triggering them #22001
This commit is contained in:
parent
5598a60ee4
commit
6eb0c49aca
|
@ -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':
|
||||
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
|
||||
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
|
||||
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':
|
||||
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
|
||||
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
|
||||
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')
|
||||
|
|
Reference in New Issue