#
# 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'
from zope.annotation.interfaces import IAttributeAnnotatable
from zope.container.constraints import containers, contains
from zope.container.interfaces import IOrderedContainer
from zope.interface import Attribute, Interface
from zope.schema import Bool, Choice
from pyams_content.component.paragraph.interfaces import IBaseParagraph
from pyams_content import _
ASSOCIATION_CONTAINER_KEY = 'pyams_content.associations'
[docs]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"""
[docs]class IAssociationInfo(Interface):
"""Association information interface"""
pictogram = Attribute("Association pictogram")
user_title = Attribute("Association title proposed on public site")
user_icon = Attribute("Icon associated with user title")
inner_title = Attribute("Inner content, if available")
human_size = Attribute("Content size, if available")
[docs]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"""
[docs]class IAssociationContainerTarget(IAttributeAnnotatable):
"""Associations container target interface"""
[docs]class IAssociationRenderer(Interface):
"""Association renderer adapter interface"""
#
# Associations paragraph
#
ASSOCIATION_PARAGRAPH_TYPE = 'Associations'
ASSOCIATION_PARAGRAPH_NAME = _("Associations")
ASSOCIATION_PARAGRAPH_RENDERERS = 'PyAMS.associations.renderers'
[docs]class IAssociationParagraph(IBaseParagraph):
"""Associations paragraph interface"""
renderer = Choice(title=_("Associations template"),
description=_("Presentation template used for associations"),
vocabulary=ASSOCIATION_PARAGRAPH_RENDERERS,
default='default')