Added shared "hidden" renderer
authorThierry Florac <thierry.florac@onf.fr>
Mon, 19 Feb 2018 10:22:06 +0100
changeset 397 fe989328a54f
parent 396 a6c3d1974420
child 398 59e2dddd1bd9
Added shared "hidden" renderer
src/pyams_content/component/illustration/interfaces/__init__.py
src/pyams_content/component/illustration/zmi/renderer.py
src/pyams_content/features/renderer/zmi/__init__.py
--- a/src/pyams_content/component/illustration/interfaces/__init__.py	Thu Feb 15 15:10:27 2018 +0100
+++ b/src/pyams_content/component/illustration/interfaces/__init__.py	Mon Feb 19 10:22:06 2018 +0100
@@ -88,7 +88,8 @@
 
     renderer = Choice(title=_("Illustration template"),
                       description=_("Presentation template used for illustration"),
-                      vocabulary='PyAMS illustration renderers')
+                      vocabulary='PyAMS illustration renderers',
+                      default='hidden')
 
     language = Choice(title=_("Language"),
                       description=_("File's content language"),
--- a/src/pyams_content/component/illustration/zmi/renderer.py	Thu Feb 15 15:10:27 2018 +0100
+++ b/src/pyams_content/component/illustration/zmi/renderer.py	Mon Feb 19 10:22:06 2018 +0100
@@ -52,17 +52,6 @@
             self.legend = i18n.query_attribute('alt_title', request=self.request)
 
 
-@adapter_config(name='hidden', context=(IIllustration, IPyAMSLayer), provides=IContentRenderer)
-class HiddenIllustrationRenderer(BaseIllustrationRenderer):
-    """Hidden illustration renderer"""
-
-    label = _("Hidden illustration")
-    weight = -999
-
-    def render(self):
-        return ''
-
-
 @adapter_config(name='default', context=(IIllustration, IPyAMSLayer), provides=IContentRenderer)
 @template_config(template='templates/renderer-default.pt', layer=IPyAMSLayer)
 class DefaultIllustrationRenderer(BaseIllustrationRenderer):
--- a/src/pyams_content/features/renderer/zmi/__init__.py	Thu Feb 15 15:10:27 2018 +0100
+++ b/src/pyams_content/features/renderer/zmi/__init__.py	Mon Feb 19 10:22:06 2018 +0100
@@ -24,7 +24,7 @@
 from pyams_form.form import AJAXEditForm
 from pyams_pagelet.pagelet import pagelet_config
 from pyams_template.template import get_view_template
-from pyams_utils.adapter import ContextRequestAdapter
+from pyams_utils.adapter import ContextRequestAdapter, adapter_config
 from pyams_zmi.form import AdminDialogEditForm
 from pyramid.view import view_config
 from z3c.form import field
@@ -45,6 +45,9 @@
             return None
         return IRendererSettings(self.context)
 
+    def update(self):
+        pass
+
     render = get_view_template()
 
 
@@ -72,3 +75,18 @@
              permission=MANAGE_CONTENT_PERMISSION, renderer='json', xhr=True)
 class RendererPropertiesAJAXEditForm(AJAXEditForm, RendererPropertiesEditForm):
     """Renderer properties edit form, JSON renderer"""
+
+
+#
+# Default common renderers
+#
+
+@adapter_config(name='hidden', context=(IRenderedContent, IPyAMSLayer), provides=IContentRenderer)
+class HiddenContentRenderer(BaseContentRenderer):
+    """Hidden content renderer"""
+
+    label = _("Hidden content")
+    weight = -999
+
+    def render(self):
+        return ''