Added attributes to default milestones renderer
authorThierry Florac <thierry.florac@onf.fr>
Thu, 15 Nov 2018 17:55:49 +0100
changeset 220 0c28a10db587
parent 219 b82dc95dff03
child 221 52c1c11d0a0f
Added attributes to default milestones renderer
src/pyams_default_theme/component/paragraph/milestone.py
--- a/src/pyams_default_theme/component/paragraph/milestone.py	Wed Nov 14 09:52:13 2018 +0100
+++ b/src/pyams_default_theme/component/paragraph/milestone.py	Thu Nov 15 17:55:49 2018 +0100
@@ -12,7 +12,9 @@
 
 __docformat__ = 'restructuredtext'
 
-from pyams_content.component.paragraph.interfaces.milestone import IMilestoneParagraph
+from pyramid.decorator import reify
+
+from pyams_content.component.paragraph.interfaces.milestone import IMilestoneParagraph, IMilestoneContainer
 from pyams_content.features.renderer.interfaces import IContentRenderer
 from pyams_default_theme.features.renderer import BaseContentRenderer
 from pyams_skin.layer import IPyAMSLayer
@@ -35,3 +37,14 @@
     weight = 1
 
     i18n_context_attrs = ('title', 'body')
+
+    @reify
+    def milestones(self):
+        return IMilestoneContainer(self.context)
+
+    @property
+    def has_anchors(self):
+        for milestone in self.milestones.values():
+            if milestone.anchor is not None:
+                return True
+        return False