src/pyams_content/component/keynumber/portlet/__init__.py
changeset 705 6490cb72a126
parent 702 5d1e4e777dbc
child 719 79281dfc31f0
equal deleted inserted replaced
704:9a84fae4ec97 705:6490cb72a126
       
     1 #
       
     2 # Copyright (c) 2008-2018 Thierry Florac <tflorac AT ulthar.net>
       
     3 # All Rights Reserved.
       
     4 #
       
     5 # This software is subject to the provisions of the Zope Public License,
       
     6 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
       
     7 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
       
     8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
       
     9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
       
    10 # FOR A PARTICULAR PURPOSE.
       
    11 #
       
    12 
       
    13 __docformat__ = 'restructuredtext'
       
    14 
       
    15 # import standard library
       
    16 
       
    17 # import interfaces
       
    18 from pyams_content.component.keynumber.interfaces import IKeyNumberContainerTarget, IKeyNumberContainer
       
    19 from pyams_content.component.keynumber.portlet.interfaces import IKeyNumberPortletSettings
       
    20 from pyams_utils.interfaces import VIEW_PERMISSION
       
    21 
       
    22 # import packages
       
    23 from pyams_portal.portlet import PortletSettings, portlet_config, Portlet
       
    24 from pyams_utils.factory import factory_config
       
    25 from zope.interface import implementer
       
    26 from zope.schema.fieldproperty import FieldProperty
       
    27 
       
    28 from pyams_content import _
       
    29 
       
    30 
       
    31 KEYNUMBER_PORTLET_NAME = "pyams_portal.portlet.keynumber"
       
    32 
       
    33 
       
    34 @implementer(IKeyNumberPortletSettings, IKeyNumberContainerTarget)
       
    35 @factory_config(provided=IKeyNumberPortletSettings)
       
    36 class KeyNumberPortletSettings(PortletSettings):
       
    37     """Key Number portlet settings"""
       
    38 
       
    39     title = FieldProperty(IKeyNumberPortletSettings['title'])
       
    40     teaser = FieldProperty(IKeyNumberPortletSettings['teaser'])
       
    41 
       
    42     @property
       
    43     def keynumbers(self):
       
    44         return IKeyNumberContainer(self)
       
    45 
       
    46 
       
    47 @portlet_config(permission=VIEW_PERMISSION)
       
    48 class KeyNumberPortlet(Portlet):
       
    49     """Key number portlet"""
       
    50 
       
    51     name = KEYNUMBER_PORTLET_NAME
       
    52     label = _("Key Numbers")
       
    53 
       
    54     toolbar_image = None
       
    55     toolbar_css_class = 'fa fa-fw fa-2x fa-dashboard'
       
    56 
       
    57     settings_factory = IKeyNumberPortletSettings