--- a/src/pyams_content_es/component/theme.py Tue Jun 27 13:34:29 2017 +0200
+++ b/src/pyams_content_es/component/theme.py Tue Jun 27 13:35:40 2017 +0200
@@ -17,10 +17,12 @@
# import interfaces
from pyams_content.component.theme.interfaces import IThemesTarget, IThemesInfo
+from pyams_content.shared.view.interfaces import IWfView, IViewQueryEsParamsExtension, IViewThemesSettings
from pyams_content_es.interfaces import IDocumentIndexInfo
# import packages
-from pyams_utils.adapter import adapter_config
+from elasticsearch_dsl import Q
+from pyams_utils.adapter import adapter_config, ContextAdapter
from pyams_utils.list import unique
@@ -42,3 +44,16 @@
'parents': unique(parents),
'synonyms': unique(synonyms),
'associations': unique(associations)}}
+
+
+@adapter_config(name='themes', context=IWfView, provides=IViewQueryEsParamsExtension)
+class ViewThemesQueryEsParamsExtension(ContextAdapter):
+ """View themes query adapter """
+
+ weight = 60
+
+ def get_es_params(self, context):
+ settings = IViewThemesSettings(self.context)
+ themes = settings.get_themes_index(context)
+ if themes:
+ return Q('terms', **{'themes.terms': themes})