--- a/src/pyams_content_es/component/theme.py Mon Jun 11 12:42:04 2018 +0200
+++ b/src/pyams_content_es/component/theme.py Mon Jun 11 12:43:02 2018 +0200
@@ -19,11 +19,13 @@
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
+from zope.intid.interfaces import IIntIds
# import packages
from elasticsearch_dsl import Q
from pyams_utils.adapter import adapter_config, ContextAdapter
from pyams_utils.list import unique
+from pyams_utils.registry import get_utility
@adapter_config(name='themes', context=IThemesTarget, provides=IDocumentIndexInfo)
@@ -33,17 +35,22 @@
parents = []
synonyms = []
associations = []
+ intids = get_utility(IIntIds)
for term in IThemesInfo(content).themes or ():
- terms.append(term.label)
+ terms.append(term)
if term.usage is not None:
- terms.append(term.usage.label)
- parents.extend([parent.label for parent in term.get_parents()])
- synonyms.extend([synonym.label for synonym in term.used_for])
- associations.extend([association.label for association in term.associations])
- return {'themes': {'terms': unique(terms),
- 'parents': unique(parents),
- 'synonyms': unique(synonyms),
- 'associations': unique(associations)}}
+ terms.append(term.usage)
+ parents.extend(term.get_parents())
+ synonyms.extend(term.used_for)
+ associations.extend(term.associations)
+ return {
+ 'themes': {
+ 'terms': [intids.register(term) for term in unique(terms)],
+ 'parents': [intids.register(term) for term in unique(parents)],
+ 'synonyms': [intids.register(term) for term in unique(synonyms)],
+ 'associations': [intids.register(term) for term in unique(associations)]
+ }
+ }
@adapter_config(name='themes', context=IWfView, provides=IViewQueryEsParamsExtension)