--- 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)
--- 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 @@
<dt i18n:translate="">Number of pages:</dt>
<dd>${nb_pages}</dd>
</tal:if>
+ <tal:if case="'duration'" condition="duration">
+ <dt i18n:translate="">Duration:</dt>
+ <dd>${duration}</dd>
+ </tal:if>
+ <tal:if case="'age_range'" condition="age_range">
+ <dt i18n:translate="">Age range:</dt>
+ <dd>${view.get_age_range(age_range)}</dd>
+ </tal:if>
<tal:if case="'release_year'" condition="release_year">
<dt i18n:translate="">Release year:</dt>
<dd>${release_year}</dd>