src/pyams_content/component/keynumber/interfaces/__init__.py
changeset 671 b6ca6378a8f8
child 845 6b039f09a91c
equal deleted inserted replaced
670:fecfd4969c4f 671:b6ca6378a8f8
       
     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 
       
    16 # import standard library
       
    17 
       
    18 # import interfaces
       
    19 from pyams_content.interfaces.container import IOrderedContainer
       
    20 from zope.annotation.interfaces import IAttributeAnnotatable
       
    21 
       
    22 # import packages
       
    23 from pyams_i18n.schema import I18nTextLineField
       
    24 from zope.container.constraints import containers, contains
       
    25 from zope.interface import Interface
       
    26 from zope.schema import Bool, TextLine
       
    27 
       
    28 from pyams_content import _
       
    29 
       
    30 
       
    31 KEYNUMBER_CONTAINER_KEY = 'pyams_content.keynumbers'
       
    32 
       
    33 
       
    34 class IKeyNumber(IAttributeAnnotatable):
       
    35     """Base key number interface"""
       
    36 
       
    37     containers('.IKeyNumberContainer')
       
    38 
       
    39     visible = Bool(title=_("Visible?"),
       
    40                    description=_("Is this key number visible in front-office?"),
       
    41                    required=True,
       
    42                    default=True)
       
    43 
       
    44     label = I18nTextLineField(title=_('key-number-label', default="Header"),
       
    45                               description=_("Small text to be displayed above number (according to selected "
       
    46                                             "renderer)"),
       
    47                               required=False)
       
    48 
       
    49     number = TextLine(title=_("Number"),
       
    50                       description=_("Key number value"),
       
    51                       required=True)
       
    52 
       
    53     unit = I18nTextLineField(title=_('key-number-unit', default="Unit"),
       
    54                              description=_("Displayed unit"),
       
    55                              required=False)
       
    56 
       
    57     text = I18nTextLineField(title=_("Associated text"),
       
    58                              description=_("The way this text will be rendered depends on presentation template"),
       
    59                              required=False)
       
    60 
       
    61 
       
    62 class IKeyNumberContainer(IOrderedContainer):
       
    63     """Key numbers container interface"""
       
    64 
       
    65     contains(IKeyNumber)
       
    66 
       
    67     def append(self, value, notify=True):
       
    68         """Append given key number to container"""
       
    69 
       
    70     def get_visible_items(self):
       
    71         """Get list of visible key numbers"""
       
    72 
       
    73 
       
    74 class IKeyNumberContainerTarget(Interface):
       
    75     """Key numbers container target interface"""