# HG changeset patch # User Thierry Florac # Date 1542019189 -3600 # Node ID 03d87dee4723a0a167d7585060137c6ce1047e78 # Parent 13da52c39ccca7c610234498f31c1c0bfe56e6bd Updated banner viewlet diff -r 13da52c39ccc -r 03d87dee4723 src/pyams_default_theme/viewlet/banner/__init__.py --- a/src/pyams_default_theme/viewlet/banner/__init__.py Mon Nov 12 11:37:45 2018 +0100 +++ b/src/pyams_default_theme/viewlet/banner/__init__.py Mon Nov 12 11:39:49 2018 +0100 @@ -12,19 +12,17 @@ __docformat__ = 'restructuredtext' +from pyramid.decorator import reify +from zope.interface import Interface -# import standard library - -# import interfaces from pyams_content.features.header.interfaces import IHeaderTarget, IHeaderSettings from pyams_default_theme.features.header.interfaces import ISimpleHeaderRendererSettings +from pyams_default_theme.interfaces import IContentBannerIllustration +from pyams_i18n.interfaces import II18n from pyams_skin.layer import IPyAMSUserLayer - -# import packages from pyams_template.template import template_config from pyams_utils.traversing import get_parent from pyams_viewlet.viewlet import contentprovider_config, ViewContentProvider -from zope.interface import Interface @contentprovider_config(name='pyams.banner', layer=IPyAMSUserLayer, view=Interface) @@ -32,10 +30,23 @@ class Banner(ViewContentProvider): """Banner content provider""" - @property + @reify def settings(self): target = get_parent(self.context, IHeaderTarget) settings = IHeaderSettings(target) while settings.inherit: settings = IHeaderSettings(settings.parent) return ISimpleHeaderRendererSettings(settings.settings, None) + + @property + def banner(self): + settings = self.settings + if settings is not None: + banner = settings.banner + if banner is not None: + return banner + registry = self.request.registry + illustration = registry.queryMultiAdapter((self.context, self.request), + IContentBannerIllustration) + if illustration is not None: + return II18n(illustration).query_attribute('data', request=self.request) diff -r 13da52c39ccc -r 03d87dee4723 src/pyams_default_theme/viewlet/banner/templates/banner.pt --- a/src/pyams_default_theme/viewlet/banner/templates/banner.pt Mon Nov 12 11:37:45 2018 +0100 +++ b/src/pyams_default_theme/viewlet/banner/templates/banner.pt Mon Nov 12 11:39:49 2018 +0100 @@ -1,12 +1,14 @@ -
+
-
- -
+
+ ${structure:tales:picture(banner, lg_thumb='banner', md_thumb='banner', + sm_thumb='banner', xs_thumb='banner', css_class='regularbanner__media')} + +
-
-
+ + + +