# HG changeset patch # User Thierry Florac # Date 1547821764 -3600 # Node ID 1ab0b78f048039d96e7cf83665aafc405c4b7588 # Parent f549a5cd47819cc7cd0a28b085a8948f172d8be4 Added duration and date range attributes diff -r f549a5cd4781 -r 1ab0b78f0480 src/pyams_default_theme/shared/resource/__init__.py --- a/src/pyams_default_theme/shared/resource/__init__.py Thu Jan 17 11:15:20 2019 +0100 +++ b/src/pyams_default_theme/shared/resource/__init__.py Fri Jan 18 15:29:24 2019 +0100 @@ -14,7 +14,8 @@ from zope.interface import Interface -from pyams_content.shared.resource import IResourceInfo, IWfResource +from pyams_content.shared.resource import IAgeRange, IResourceInfo, IWfResource +from pyams_default_theme import _ from pyams_default_theme import lightbox from pyams_default_theme.features.search.portlet import ISearchResultRenderer, WfSharedContentSearchResultRenderer from pyams_default_theme.interfaces import ISearchResultsView @@ -42,6 +43,16 @@ def resource_info(self): return IResourceInfo(self.context) + def get_age_range(self, value: IAgeRange): + translate = self.request.localizer.translate + if value.min_value and value.max_value: + result = _("from {0.min_value} to {0.max_value}") + elif value.min_value: + result = _("from {0.min_value}") + else: + result = _("up to {0.max_value}") + return translate(result).format(value) + @adapter_config(context=(IWfResource, IPyAMSUserLayer, ISearchResultsView), provides=ISearchResultRenderer) @template_config(template='templates/search-result.pt', layer=IPyAMSUserLayer) diff -r f549a5cd4781 -r 1ab0b78f0480 src/pyams_default_theme/shared/resource/templates/specificities.pt --- a/src/pyams_default_theme/shared/resource/templates/specificities.pt Thu Jan 17 11:15:20 2019 +0100 +++ b/src/pyams_default_theme/shared/resource/templates/specificities.pt Fri Jan 18 15:29:24 2019 +0100 @@ -19,6 +19,8 @@ release_year resource_info.release_year; awards i18n:resource_info.awards; nb_pages resource_info.nb_pages; + duration resource_info.duration; + age_range resource_info.age_range; editor_reference resource_info.editor_reference; isbn_number resource_info.isbn_number; source_url resource_info.source_url; @@ -115,6 +117,14 @@
Number of pages:
${nb_pages}
+ +
Duration:
+
${duration}
+
+ +
Age range:
+
${view.get_age_range(age_range)}
+
Release year:
${release_year}