src/pyams_content/component/paragraph/interfaces/milestone.py
changeset 456 07646760c1b5
child 555 8e8a14452567
equal deleted inserted replaced
455:95582493a5ac 456:07646760c1b5
       
     1 #
       
     2 # Copyright (c) 2008-2015 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.component.paragraph import IBaseParagraph
       
    20 from pyams_content.features.renderer import IRenderedContent
       
    21 from pyams_content.interfaces.container import IOrderedContainer
       
    22 from zope.annotation.interfaces import IAttributeAnnotatable
       
    23 
       
    24 # import packages
       
    25 from pyams_i18n.schema import I18nTextLineField
       
    26 from zope.container.constraints import containers, contains
       
    27 from zope.interface import Interface
       
    28 from zope.schema import Bool, Choice
       
    29 
       
    30 from pyams_content import _
       
    31 
       
    32 
       
    33 MILESTONE_CONTAINER_KEY = 'pyams_content.milestones'
       
    34 
       
    35 
       
    36 class IMilestone(IAttributeAnnotatable):
       
    37     """Base milestone interface"""
       
    38 
       
    39     containers('.IMilestoneContainer')
       
    40 
       
    41     visible = Bool(title=_("Visible?"),
       
    42                    description=_("Is this milestone visible in front-office?"),
       
    43                    required=True,
       
    44                    default=True)
       
    45 
       
    46     title = I18nTextLineField(title=_("Title"),
       
    47                               description=_("Milestone title"),
       
    48                               required=True)
       
    49 
       
    50     label = I18nTextLineField(title=_("Associated label"),
       
    51                               description=_("The way this label will be rendered depends on presentation template"),
       
    52                               required=False)
       
    53 
       
    54     anchor = Choice(title=_("Anchor"),
       
    55                     description=_("Paragraph to which this milestone should lead"),
       
    56                     vocabulary='PyAMS content paragraphs',
       
    57                     required=False)
       
    58 
       
    59 
       
    60 class IMilestoneContainer(IOrderedContainer):
       
    61     """Milestones container interface"""
       
    62 
       
    63     contains(IMilestone)
       
    64 
       
    65     def append(self, value, notify=True):
       
    66         """Append given milestone to container"""
       
    67 
       
    68     def get_visible_items(self):
       
    69         """Get list of visible milestones"""
       
    70 
       
    71 
       
    72 class IMilestoneContainerTarget(Interface):
       
    73     """Milestones container target interface"""
       
    74 
       
    75 
       
    76 MILESTONE_PARAGRAPH_TYPE = 'Milestones'
       
    77 MILESTONE_PARAGRAPH_RENDERERS = 'PyAMS.milestones.renderers'
       
    78 
       
    79 
       
    80 class IMilestoneParagraph(IMilestoneContainerTarget, IRenderedContent, IBaseParagraph):
       
    81     """Milestones paragraph interface"""
       
    82 
       
    83     renderer = Choice(title=_("Milestones template"),
       
    84                       description=_("Presentation template used for milestones"),
       
    85                       vocabulary=MILESTONE_PARAGRAPH_RENDERERS,
       
    86                       default='default')