src/pyams_content/component/paragraph/interfaces/milestone.py
changeset 456 07646760c1b5
child 555 8e8a14452567
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/component/paragraph/interfaces/milestone.py	Fri Mar 09 16:53:46 2018 +0100
@@ -0,0 +1,86 @@
+#
+# Copyright (c) 2008-2015 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.paragraph import IBaseParagraph
+from pyams_content.features.renderer import IRenderedContent
+from pyams_content.interfaces.container import IOrderedContainer
+from zope.annotation.interfaces import IAttributeAnnotatable
+
+# import packages
+from pyams_i18n.schema import I18nTextLineField
+from zope.container.constraints import containers, contains
+from zope.interface import Interface
+from zope.schema import Bool, Choice
+
+from pyams_content import _
+
+
+MILESTONE_CONTAINER_KEY = 'pyams_content.milestones'
+
+
+class IMilestone(IAttributeAnnotatable):
+    """Base milestone interface"""
+
+    containers('.IMilestoneContainer')
+
+    visible = Bool(title=_("Visible?"),
+                   description=_("Is this milestone visible in front-office?"),
+                   required=True,
+                   default=True)
+
+    title = I18nTextLineField(title=_("Title"),
+                              description=_("Milestone title"),
+                              required=True)
+
+    label = I18nTextLineField(title=_("Associated label"),
+                              description=_("The way this label will be rendered depends on presentation template"),
+                              required=False)
+
+    anchor = Choice(title=_("Anchor"),
+                    description=_("Paragraph to which this milestone should lead"),
+                    vocabulary='PyAMS content paragraphs',
+                    required=False)
+
+
+class IMilestoneContainer(IOrderedContainer):
+    """Milestones container interface"""
+
+    contains(IMilestone)
+
+    def append(self, value, notify=True):
+        """Append given milestone to container"""
+
+    def get_visible_items(self):
+        """Get list of visible milestones"""
+
+
+class IMilestoneContainerTarget(Interface):
+    """Milestones container target interface"""
+
+
+MILESTONE_PARAGRAPH_TYPE = 'Milestones'
+MILESTONE_PARAGRAPH_RENDERERS = 'PyAMS.milestones.renderers'
+
+
+class IMilestoneParagraph(IMilestoneContainerTarget, IRenderedContent, IBaseParagraph):
+    """Milestones paragraph interface"""
+
+    renderer = Choice(title=_("Milestones template"),
+                      description=_("Presentation template used for milestones"),
+                      vocabulary=MILESTONE_PARAGRAPH_RENDERERS,
+                      default='default')