# HG changeset patch
# User Damien Correia
# Date 1539096040 -7200
# Node ID f805794b2500a9695a354b00f697711a3dfb069e
# Parent 5276328160b3021703ccac1c382f1f3127deb5de
Created Association content provider;
Updated Association default renderer and template;
diff -r 5276328160b3 -r f805794b2500 src/pyams_default_theme/component/association/__init__.py
--- a/src/pyams_default_theme/component/association/__init__.py Tue Oct 09 16:37:24 2018 +0200
+++ b/src/pyams_default_theme/component/association/__init__.py Tue Oct 09 16:40:40 2018 +0200
@@ -24,7 +24,8 @@
# import interfaces
from pyams_content.component.association.interfaces import IAssociationParagraph, IAssociationInfo, \
IAssociationContainer
-from pyams_content.component.links.interfaces import IInternalLink
+from pyams_content.component.extfile import IExtFile
+from pyams_content.component.links.interfaces import IInternalLink, IBaseLink
from pyams_content.component.paragraph.interfaces import IParagraphContainerTarget, IParagraphContainer
from pyams_content.features.renderer.interfaces import IContentRenderer
from pyams_content.features.renderer.skin import BaseContentRenderer
@@ -45,16 +46,30 @@
"""Associations paragraph default renderer"""
label = _("Default associations renderer")
- associations = ()
+ i18n_context_attrs = ('title', )
+
+ links = None
+ attachments = None
- i18n_context_attrs = ('title', )
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.attachments = []
+ self.links = []
+
+ def get_associations(self):
+ yield from IAssociationContainer(self.context).get_visible_items(self.request)
+
+ @staticmethod
+ def get_link_info(link):
+ return IAssociationInfo(link)
def update(self):
- super(AssociationParagraphDefaultRenderer, self).update()
- self.associations = [{'url': item.get_url(self.request),
- 'title': IAssociationInfo(item).user_title}
- for item in IAssociationContainer(self.context).get_visible_items(self.request)]
-
+ super().update()
+ for item in self.get_associations():
+ if IExtFile.providedBy(item):
+ self.attachments.append(item)
+ elif IBaseLink.providedBy(item):
+ self.links.append(item)
#
# Associations paragraph remote content renderer
diff -r 5276328160b3 -r f805794b2500 src/pyams_default_theme/component/association/templates/association-default.pt
--- a/src/pyams_default_theme/component/association/templates/association-default.pt Tue Oct 09 16:37:24 2018 +0200
+++ b/src/pyams_default_theme/component/association/templates/association-default.pt Tue Oct 09 16:40:40 2018 +0200
@@ -1,9 +1,4 @@
ยง title
-
-
+ ${structure:provider:pyams.association}
${structure:tales:html(description)}
+ ${link_info.user_title}
+
${structure:tales:html(description)}
+ ${item_info.user_title}
+