# HG changeset patch # User Thierry Florac # Date 1611758845 -3600 # Node ID b74f6ea0f791577f95f26c9f2faa7f498557588c # Parent 0f646872d21bad11e8230b59b0492dfc38aa3033 Added themes support on site root to handle advanced search on themes diff -r 0f646872d21b -r b74f6ea0f791 src/pyams_content/root/__init__.py --- 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""" diff -r 0f646872d21b -r b74f6ea0f791 src/pyams_content/root/zmi/search.py --- 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) diff -r 0f646872d21b -r b74f6ea0f791 src/pyams_content/root/zmi/templates/advanced-search.pt --- 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 @@ -
- Tags -
- -
-
-
- Collections -
- -
-
+ +
+ + ${widget.label} +
+ +
+
+
+