src/pyams_content/component/association/interfaces.py
changeset 1059 34e6d07ea2e9
parent 841 d50743e69693
child 1129 2effaa115498
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/component/association/interfaces.py	Tue Nov 06 14:40:22 2018 +0100
@@ -0,0 +1,103 @@
+#
+# 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.interfaces import IBaseParagraph
+from zope.annotation.interfaces import IAttributeAnnotatable
+from zope.container.interfaces import IOrderedContainer
+
+# import packages
+from zope.container.constraints import containers, contains
+from zope.interface import Interface, Attribute
+from zope.schema import Bool, Choice
+
+from pyams_content import _
+
+
+ASSOCIATION_CONTAINER_KEY = 'pyams_content.associations'
+
+
+class IAssociationItem(IAttributeAnnotatable):
+    """Base association item interface"""
+
+    containers('.IAssociationContainer')
+
+    icon_class = Attribute("Icon class in associations list")
+    icon_hint = Attribute("Icon hint in associations list")
+
+    visible = Bool(title=_("Visible?"),
+                   description=_("Is this item visible in front-office?"),
+                   required=True,
+                   default=True)
+
+    def is_visible(self, request=None):
+        """Is association item published?"""
+
+    def get_url(self, request=None, view_name=None):
+        """Get link URL"""
+
+
+class IAssociationInfo(Interface):
+    """Association information interface"""
+
+    pictogram = Attribute("Association pictogram")
+
+    user_title = Attribute("Association title proposed on public site")
+
+    user_icon = Attribute("Iocn associated with user title")
+
+    inner_title = Attribute("Inner content, if available")
+
+    human_size = Attribute("Content size, if available")
+
+
+class IAssociationContainer(IOrderedContainer):
+    """Associations container interface"""
+
+    contains(IAssociationItem)
+
+    def append(self, value, notify=True):
+        """Append given value to container"""
+
+    def get_visible_items(self, request=None):
+        """Get list of visible items"""
+
+
+class IAssociationContainerTarget(IAttributeAnnotatable):
+    """Associations container target interface"""
+
+
+class IAssociationRenderer(Interface):
+    """Association renderer adapter interface"""
+
+
+#
+# Associations paragraph
+#
+
+ASSOCIATION_PARAGRAPH_TYPE = 'Associations'
+ASSOCIATION_PARAGRAPH_NAME = _("Associations")
+ASSOCIATION_PARAGRAPH_RENDERERS = 'PyAMS.associations.renderers'
+
+
+class IAssociationParagraph(IBaseParagraph):
+    """Associations paragraph interface"""
+
+    renderer = Choice(title=_("Associations template"),
+                      description=_("Presentation template used for associations"),
+                      vocabulary=ASSOCIATION_PARAGRAPH_RENDERERS,
+                      default='default')