src/pyams_content/component/keynumber/portlet/__init__.py
changeset 705 6490cb72a126
parent 702 5d1e4e777dbc
child 719 79281dfc31f0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/component/keynumber/portlet/__init__.py	Sun Jun 17 16:41:24 2018 +0200
@@ -0,0 +1,57 @@
+#
+# 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'
+
+# import standard library
+
+# import interfaces
+from pyams_content.component.keynumber.interfaces import IKeyNumberContainerTarget, IKeyNumberContainer
+from pyams_content.component.keynumber.portlet.interfaces import IKeyNumberPortletSettings
+from pyams_utils.interfaces import VIEW_PERMISSION
+
+# import packages
+from pyams_portal.portlet import PortletSettings, portlet_config, Portlet
+from pyams_utils.factory import factory_config
+from zope.interface import implementer
+from zope.schema.fieldproperty import FieldProperty
+
+from pyams_content import _
+
+
+KEYNUMBER_PORTLET_NAME = "pyams_portal.portlet.keynumber"
+
+
+@implementer(IKeyNumberPortletSettings, IKeyNumberContainerTarget)
+@factory_config(provided=IKeyNumberPortletSettings)
+class KeyNumberPortletSettings(PortletSettings):
+    """Key Number portlet settings"""
+
+    title = FieldProperty(IKeyNumberPortletSettings['title'])
+    teaser = FieldProperty(IKeyNumberPortletSettings['teaser'])
+
+    @property
+    def keynumbers(self):
+        return IKeyNumberContainer(self)
+
+
+@portlet_config(permission=VIEW_PERMISSION)
+class KeyNumberPortlet(Portlet):
+    """Key number portlet"""
+
+    name = KEYNUMBER_PORTLET_NAME
+    label = _("Key Numbers")
+
+    toolbar_image = None
+    toolbar_css_class = 'fa fa-fw fa-2x fa-dashboard'
+
+    settings_factory = IKeyNumberPortletSettings