|
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.interfaces import IBaseParagraph |
|
20 from zope.annotation.interfaces import IAttributeAnnotatable |
|
21 from zope.container.interfaces import IOrderedContainer |
|
22 |
|
23 # import packages |
|
24 from zope.container.constraints import containers, contains |
|
25 from zope.interface import Interface, Attribute |
|
26 from zope.schema import Bool, Choice |
|
27 |
|
28 from pyams_content import _ |
|
29 |
|
30 |
|
31 ASSOCIATION_CONTAINER_KEY = 'pyams_content.associations' |
|
32 |
|
33 |
|
34 class IAssociationItem(IAttributeAnnotatable): |
|
35 """Base association item interface""" |
|
36 |
|
37 containers('.IAssociationContainer') |
|
38 |
|
39 icon_class = Attribute("Icon class in associations list") |
|
40 icon_hint = Attribute("Icon hint in associations list") |
|
41 |
|
42 visible = Bool(title=_("Visible?"), |
|
43 description=_("Is this item visible in front-office?"), |
|
44 required=True, |
|
45 default=True) |
|
46 |
|
47 def is_visible(self, request=None): |
|
48 """Is association item published?""" |
|
49 |
|
50 def get_url(self, request=None, view_name=None): |
|
51 """Get link URL""" |
|
52 |
|
53 |
|
54 class IAssociationInfo(Interface): |
|
55 """Association information interface""" |
|
56 |
|
57 pictogram = Attribute("Association pictogram") |
|
58 |
|
59 user_title = Attribute("Association title proposed on public site") |
|
60 |
|
61 user_icon = Attribute("Iocn associated with user title") |
|
62 |
|
63 inner_title = Attribute("Inner content, if available") |
|
64 |
|
65 human_size = Attribute("Content size, if available") |
|
66 |
|
67 |
|
68 class IAssociationContainer(IOrderedContainer): |
|
69 """Associations container interface""" |
|
70 |
|
71 contains(IAssociationItem) |
|
72 |
|
73 def append(self, value, notify=True): |
|
74 """Append given value to container""" |
|
75 |
|
76 def get_visible_items(self, request=None): |
|
77 """Get list of visible items""" |
|
78 |
|
79 |
|
80 class IAssociationContainerTarget(IAttributeAnnotatable): |
|
81 """Associations container target interface""" |
|
82 |
|
83 |
|
84 class IAssociationRenderer(Interface): |
|
85 """Association renderer adapter interface""" |
|
86 |
|
87 |
|
88 # |
|
89 # Associations paragraph |
|
90 # |
|
91 |
|
92 ASSOCIATION_PARAGRAPH_TYPE = 'Associations' |
|
93 ASSOCIATION_PARAGRAPH_NAME = _("Associations") |
|
94 ASSOCIATION_PARAGRAPH_RENDERERS = 'PyAMS.associations.renderers' |
|
95 |
|
96 |
|
97 class IAssociationParagraph(IBaseParagraph): |
|
98 """Associations paragraph interface""" |
|
99 |
|
100 renderer = Choice(title=_("Associations template"), |
|
101 description=_("Presentation template used for associations"), |
|
102 vocabulary=ASSOCIATION_PARAGRAPH_RENDERERS, |
|
103 default='default') |