Added default renderer for toolbox portlet
authorThierry Florac <tflorac@ulthar.net>
Wed, 28 Nov 2018 17:53:42 +0100
changeset 263 37a0b0a69b02
parent 262 afe9d8d8692d
child 264 a57d4369f179
Added default renderer for toolbox portlet
src/pyams_default_theme/features/share/__init__.py
src/pyams_default_theme/features/share/portlet/__init__.py
src/pyams_default_theme/features/share/portlet/templates/toolbox.pt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_default_theme/features/share/__init__.py	Wed Nov 28 17:53:42 2018 +0100
@@ -0,0 +1,15 @@
+#
+# Copyright (c) 2008-2018 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_default_theme/features/share/portlet/__init__.py	Wed Nov 28 17:53:42 2018 +0100
@@ -0,0 +1,40 @@
+#
+# Copyright (c) 2008-2018 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+from zope.interface import Interface
+
+from pyams_content.features.share.interfaces import ISocialShareManager
+from pyams_content.features.share.portlet import IToolboxPortletSettings
+from pyams_portal.interfaces import IPortalContext, IPortletRenderer
+from pyams_portal.portlet import PortletRenderer
+from pyams_skin.layer import IPyAMSLayer
+from pyams_template.template import template_config
+from pyams_utils.adapter import adapter_config
+
+from pyams_default_theme import _
+
+
+@adapter_config(context=(IPortalContext, IPyAMSLayer, Interface, IToolboxPortletSettings),
+                provides=IPortletRenderer)
+@template_config(template='templates/toolbox.pt', layer=IPyAMSLayer)
+class ToolboxPortletDefaultRenderer(PortletRenderer):
+    """Toolbox portlet renderer"""
+
+    label = _("Default toolbox")
+
+    @property
+    def social_items(self):
+        manager = ISocialShareManager(self.request.root, None)
+        if manager is not None:
+            yield from manager.get_active_items()