add custom can_last_version_validate index (#22001)

This commit is contained in:
Frédéric Péters 2018-12-11 08:30:45 +01:00
parent 4a59ea5caa
commit afde54bb3b
2 changed files with 18 additions and 0 deletions

View File

@ -1,6 +1,7 @@
from five import grok
from plone.indexer import indexer
from plone import api
from Products.CMFCore.utils import getToolByName
from collective.dms.basecontent.dmsdocument import IDmsDocument
@ -36,3 +37,16 @@ def recipients_as_text(obj, **kw):
return ' / '.join([x.to_object.get_full_title() for x in obj.recipients])
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('validate' in [x.get('id') for x in workflowActions])
return False
grok.global_adapter(can_last_version_validate, name='can_last_version_validate')

View File

@ -3,6 +3,9 @@
<index name="has_final_unsigned_version" meta_type="FieldIndex">
<indexed_attr value="has_final_unsigned_version"/>
</index>
<index name="can_last_version_validate" meta_type="FieldIndex">
<indexed_attr value="can_last_version_validate"/>
</index>
<!-- those two are actually delegated to solr, but plone.app.querystring
requires indexes to be declared in the plone catalog -->
@ -14,6 +17,7 @@
</index>
<column value="has_final_unsigned_version"/>
<column value="can_last_version_validate"/>
<column value="sender_as_text"/>
<column value="recipients_as_text"/>
</object>