--- a/src/pyams_content/root/__init__.py Wed Jan 27 15:46:21 2021 +0100
+++ b/src/pyams_content/root/__init__.py Wed Jan 27 15:47:25 2021 +0100
@@ -17,7 +17,7 @@
from zope.interface import implementer
from pyams_content.component.illustration.interfaces import IIllustrationTarget
-from pyams_content.component.theme import ICollectionsManagerTarget
+from pyams_content.component.theme import ICollectionsManagerTarget, IThemesManagerTarget
from pyams_content.component.theme.interfaces import ITagsManagerTarget
from pyams_content.features.alert.interfaces import IAlertTarget
from pyams_content.features.footer.interfaces import IFooterTarget
@@ -51,8 +51,8 @@
@implementer(IDefaultProtectionPolicy, ISiteRoot, ISiteRootRoles, IPortalContext,
- ITagsManagerTarget, ICollectionsManagerTarget, IIllustrationTarget,
- IHeaderTarget, IFooterTarget, ISocialShareManagerTarget,
+ ITagsManagerTarget, ICollectionsManagerTarget, IThemesManagerTarget,
+ IIllustrationTarget, IHeaderTarget, IFooterTarget, ISocialShareManagerTarget,
IAlertTarget, IRedirectionManagerTarget, IPreviewTarget)
class SiteRoot(ProtectedObject, BaseSiteRoot, UserSkinnableContent):
"""Main site root"""
--- a/src/pyams_content/root/zmi/search.py Wed Jan 27 15:46:21 2021 +0100
+++ b/src/pyams_content/root/zmi/search.py Wed Jan 27 15:47:25 2021 +0100
@@ -22,7 +22,7 @@
from zope.schema import Choice, Datetime, List
from pyams_catalog.query import CatalogResultSet
-from pyams_content.component.theme import ICollectionsManager
+from pyams_content.component.theme import ICollectionsManager, IThemesManager
from pyams_content.component.theme.interfaces import ITagsManager
from pyams_content.profile.interfaces import IAdminProfile
from pyams_content.root import ISiteRoot
@@ -184,6 +184,9 @@
tags = ThesaurusTermsListField(title=_("Tags"),
required=False)
+ themes = ThesaurusTermsListField(title=_("Themes"),
+ required=False)
+
collections = ThesaurusTermsListField(title=_("Collections"),
required=False)
@@ -210,6 +213,7 @@
def fields(self):
fields = field.Fields(self.fields_interface)
fields['tags'].widgetFactory = ThesaurusTermsTreeFieldWidget
+ fields['themes'].widgetFactory = ThesaurusTermsTreeFieldWidget
fields['collections'].widgetFactory = ThesaurusTermsTreeFieldWidget
return fields
@@ -220,6 +224,11 @@
manager = ITagsManager(self.request.root)
widget.thesaurus_name = manager.thesaurus_name
widget.extract_name = manager.extract_name
+ if 'themes' in self.widgets:
+ widget = self.widgets['themes']
+ manager = IThemesManager(self.request.root)
+ widget.thesaurus_name = manager.thesaurus_name
+ widget.extract_name = manager.extract_name
if 'collections' in self.widgets:
widget = self.widgets['collections']
manager = ICollectionsManager(self.request.root)
@@ -272,6 +281,9 @@
if data.get('tags'):
tags = [intids.register(term) for term in data['tags']]
params &= Any(catalog['tags'], tags)
+ if data.get('themes'):
+ tags = [intids.register(term) for term in data['themes']]
+ params &= Any(catalog['themes'], tags)
if data.get('collections'):
tags = [intids.register(term) for term in data['collections']]
params &= Any(catalog['collections'], tags)
--- a/src/pyams_content/root/zmi/templates/advanced-search.pt Wed Jan 27 15:46:21 2021 +0100
+++ b/src/pyams_content/root/zmi/templates/advanced-search.pt Wed Jan 27 15:47:25 2021 +0100
@@ -177,20 +177,16 @@
</div>
</div>
</div>
- <fieldset tal:condition="'tags' in view.widgets">
- <legend class="switcher" i18n:translate="">Tags</legend>
- <div class="input"
- tal:define="widget view.widgets['tags']">
- <input tal:replace="structure widget.render()" />
- </div>
- </fieldset>
- <fieldset tal:condition="'collections' in view.widgets">
- <legend class="switcher" i18n:translate="">Collections</legend>
- <div class="input"
- tal:define="widget view.widgets['collections']">
- <input tal:replace="structure widget.render()" />
- </div>
- </fieldset>
+ <tal:loop repeat="fieldname ('tags', 'themes', 'collections')">
+ <fieldset tal:condition="fieldname in view.widgets">
+ <tal:var define="widget view.widgets[fieldname]">
+ <legend class="switcher">${widget.label}</legend>
+ <div class="input">
+ <input tal:replace="structure widget.render()" />
+ </div>
+ </tal:var>
+ </fieldset>
+ </tal:loop>
</fieldset>
</tal:loop>
<div class="widgets-suffix"