Updated tags manager interface
authorThierry Florac <tflorac@ulthar.net>
Wed, 12 Sep 2018 18:11:41 +0200
changeset 947 b5eeec049869
parent 946 0db1b4637bae
child 948 6d3438907215
Updated tags manager interface
src/pyams_content/component/theme/__init__.py
src/pyams_content/component/theme/interfaces/__init__.py
src/pyams_content/component/theme/zmi/manager.py
--- a/src/pyams_content/component/theme/__init__.py	Wed Sep 12 16:57:06 2018 +0200
+++ b/src/pyams_content/component/theme/__init__.py	Wed Sep 12 18:11:41 2018 +0200
@@ -44,6 +44,9 @@
     thesaurus_name = FieldProperty(ITagsManager['thesaurus_name'])
     extract_name = FieldProperty(ITagsManager['extract_name'])
 
+    enable_tags_search = FieldProperty(ITagsManager['enable_tags_search'])
+    tags_search_target = FieldProperty(ITagsManager['tags_search_target'])
+
 
 @adapter_config(context=ITagsManagerTarget, provides=ITagsManager)
 def tags_manager_factory(target):
--- a/src/pyams_content/component/theme/interfaces/__init__.py	Wed Sep 12 16:57:06 2018 +0200
+++ b/src/pyams_content/component/theme/interfaces/__init__.py	Wed Sep 12 18:11:41 2018 +0200
@@ -19,8 +19,10 @@
 from pyams_thesaurus.interfaces.thesaurus import IThesaurusContextManager, IThesaurusContextManagerTarget
 
 # import packages
+from pyams_sequence.schema import InternalReferenceField
 from pyams_thesaurus.schema import ThesaurusTermsListField
-from zope.interface import Interface
+from zope.interface import Interface, invariant, Invalid
+from zope.schema import Bool
 
 from pyams_content import _
 
@@ -36,6 +38,21 @@
 class ITagsManager(IThesaurusContextManager):
     """Tags manager interface"""
 
+    enable_tags_search = Bool(title=_("Enable search by tag?"),
+                              description=_("If 'yes', displayed tags will lead to a search engine "
+                                            "displaying contents matching given tag"),
+                              required=True,
+                              default=False)
+
+    tags_search_target = InternalReferenceField(title=_("Tags search target"),
+                                                description=_("Site or folder where tags search is displayed"),
+                                                required=False)
+
+    @invariant
+    def check_search_target(self):
+        if self.enable_tags_search and not self.tags_search_target:
+            raise Invalid(_("You must specify search target when activating search by tags!"))
+
 
 class ITagsManagerTarget(IThesaurusContextManagerTarget):
     """Marker interface for tags manager"""
--- a/src/pyams_content/component/theme/zmi/manager.py	Wed Sep 12 16:57:06 2018 +0200
+++ b/src/pyams_content/component/theme/zmi/manager.py	Wed Sep 12 18:11:41 2018 +0200
@@ -70,6 +70,7 @@
     prefix = 'manager_themes.'
 
     legend = _("Selected tags")
+    dialog_class = 'modal-large'
 
     fields = field.Fields(ITagsManager)
     edit_permission = MANAGE_SITE_ROOT_PERMISSION