# HG changeset patch # User Thierry Florac # Date 1605269489 -3600 # Node ID 48c1ee485dc0a37d86caac5dd35426df9bc5825a # Parent 43bd56f3a72631c9860dfd75360dcf7b29ddc1a5 Allow selection of sub-themes in view's themes settings diff -r 43bd56f3a726 -r 48c1ee485dc0 src/pyams_content/shared/view/interfaces.py --- a/src/pyams_content/shared/view/interfaces.py Fri Nov 13 13:08:48 2020 +0100 +++ b/src/pyams_content/shared/view/interfaces.py Fri Nov 13 13:11:29 2020 +0100 @@ -10,15 +10,12 @@ # FOR A PARTICULAR PURPOSE. # -__docformat__ = 'restructuredtext' - from collections import OrderedDict from zope.interface import Attribute, Interface from zope.schema import Bool, Choice, Int, Set from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary -from pyams_content import _ from pyams_content.shared.common.interfaces import ISharedContent, ISharedTool, IWfSharedContent, \ SHARED_CONTENT_TYPES_VOCABULARY from pyams_content.shared.common.interfaces.types import ALL_DATA_TYPES_VOCABULARY @@ -27,6 +24,11 @@ from pyams_thesaurus.schema import ThesaurusTermsListField +__docformat__ = 'restructuredtext' + +from pyams_content import _ + + VIEW_CONTENT_TYPE = 'view' VIEW_CONTENT_NAME = _('View') @@ -273,6 +275,12 @@ themes = ThesaurusTermsListField(title=_("Other themes"), required=False) + include_subthemes = Bool(title=_("Include all subthemes?"), + description=_("If 'yes', subthemes of selected themes will also " + "be used to search contents"), + required=False, + default=False) + def get_themes(self, context): """Get all themes for given context""" diff -r 43bd56f3a726 -r 48c1ee485dc0 src/pyams_content/shared/view/theme.py --- a/src/pyams_content/shared/view/theme.py Fri Nov 13 13:08:48 2020 +0100 +++ b/src/pyams_content/shared/view/theme.py Fri Nov 13 13:11:29 2020 +0100 @@ -10,8 +10,6 @@ # FOR A PARTICULAR PURPOSE. # -__docformat__ = 'restructuredtext' - from hypatia.interfaces import ICatalog from hypatia.query import Any from persistent import Persistent @@ -32,6 +30,9 @@ from pyams_utils.registry import get_utility, query_utility +__docformat__ = 'restructuredtext' + + # # Tags management # @@ -118,6 +119,7 @@ select_context_themes = FieldProperty(IViewThemesSettings['select_context_themes']) themes = FieldProperty(IViewThemesSettings['themes']) + include_subthemes = FieldProperty(IViewThemesSettings['include_subthemes']) @property def is_using_context(self): @@ -131,6 +133,9 @@ themes |= set(themes_info.themes or ()) if self.themes: themes |= set(self.themes) + if self.include_subthemes: + for theme in themes.copy(): + themes |= set(theme.gel_all_childs()) return themes def get_themes_index(self, context): diff -r 43bd56f3a726 -r 48c1ee485dc0 src/pyams_content/shared/view/zmi/theme.py --- a/src/pyams_content/shared/view/zmi/theme.py Fri Nov 13 13:08:48 2020 +0100 +++ b/src/pyams_content/shared/view/zmi/theme.py Fri Nov 13 13:11:29 2020 +0100 @@ -10,18 +10,15 @@ # FOR A PARTICULAR PURPOSE. # -__docformat__ = 'restructuredtext' - from z3c.form import button, field from z3c.form.browser.checkbox import SingleCheckBoxFieldWidget from z3c.form.interfaces import INPUT_MODE from zope.interface import Interface, implementer -from pyams_content import _ from pyams_content.component.theme import ICollectionsManager, ITagsManager, IThemesManager from pyams_content.interfaces import MANAGE_CONTENT_PERMISSION -from pyams_content.shared.view.interfaces import IViewCollectionsSettings, IViewTagsSettings, IViewThemesSettings, \ - IViewsManager, IWfView +from pyams_content.shared.view.interfaces import IViewCollectionsSettings, IViewTagsSettings, \ + IViewThemesSettings, IViewsManager, IWfView from pyams_form.form import ajax_config from pyams_form.interfaces.form import IUncheckedEditFormButtons, IWidgetForm from pyams_pagelet.pagelet import pagelet_config @@ -37,6 +34,11 @@ from pyams_zmi.layer import IAdminLayer +__docformat__ = 'restructuredtext' + +from pyams_content import _ + + # # Tags management # @@ -51,8 +53,10 @@ url = '#tags.html' -@pagelet_config(name='tags.html', context=IWfView, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION) -@ajax_config(name='tags.json', context=IWfView, layer=IPyAMSLayer, permission=MANAGE_CONTENT_PERMISSION) +@pagelet_config(name='tags.html', context=IWfView, layer=IPyAMSLayer, + permission=VIEW_SYSTEM_PERMISSION) +@ajax_config(name='tags.json', context=IWfView, layer=IPyAMSLayer, + permission=MANAGE_CONTENT_PERMISSION) @implementer(IWidgetForm, IInnerPage) class ViewTagsEditForm(AdminEditForm): """View tags settings edit form""" @@ -88,7 +92,7 @@ # @viewlet_config(name='themes.menu', context=IWfView, layer=IAdminLayer, - manager=IPropertiesMenu, permission=VIEW_SYSTEM_PERMISSION, weight=352) + manager=IPropertiesMenu, permission=VIEW_SYSTEM_PERMISSION, weight=360) class ViewThemesMenu(MenuItem): """View themes menu""" @@ -97,8 +101,10 @@ url = '#themes.html' -@pagelet_config(name='themes.html', context=IWfView, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION) -@ajax_config(name='themes.json', context=IWfView, layer=IPyAMSLayer, permission=MANAGE_CONTENT_PERMISSION) +@pagelet_config(name='themes.html', context=IWfView, layer=IPyAMSLayer, + permission=VIEW_SYSTEM_PERMISSION) +@ajax_config(name='themes.json', context=IWfView, layer=IPyAMSLayer, + permission=MANAGE_CONTENT_PERMISSION) @implementer(IWidgetForm, IInnerPage) class ViewThemesEditForm(AdminEditForm): """View themes settings edit form""" @@ -110,6 +116,7 @@ fields = field.Fields(IViewThemesSettings) fields['select_context_themes'].widgetFactory = SingleCheckBoxFieldWidget fields['themes'].widgetFactory = ThesaurusTermsTreeFieldWidget + fields['include_subthemes'].widgetFactory = SingleCheckBoxFieldWidget @property def buttons(self): @@ -134,7 +141,7 @@ # @viewlet_config(name='collections.menu', context=IWfView, layer=IAdminLayer, - manager=IPropertiesMenu, permission=VIEW_SYSTEM_PERMISSION, weight=354) + manager=IPropertiesMenu, permission=VIEW_SYSTEM_PERMISSION, weight=370) class ViewCollectionsMenu(MenuItem): """View collections menu""" @@ -143,8 +150,10 @@ url = '#collections.html' -@pagelet_config(name='collections.html', context=IWfView, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION) -@ajax_config(name='collections.json', context=IWfView, layer=IPyAMSLayer, permission=MANAGE_CONTENT_PERMISSION) +@pagelet_config(name='collections.html', context=IWfView, layer=IPyAMSLayer, + permission=VIEW_SYSTEM_PERMISSION) +@ajax_config(name='collections.json', context=IWfView, layer=IPyAMSLayer, + permission=MANAGE_CONTENT_PERMISSION) @implementer(IWidgetForm, IInnerPage) class ViewCollectionsEditForm(AdminEditForm): """View collections settings edit form"""