# HG changeset patch # User Thierry Florac # Date 1535620037 -7200 # Node ID d83485dee19aff66872d33e6df6294617f0c72bd # Parent 81cd2db6df7a30e4b81420e0fed8b36906e4e04a Refactored keynumber paragraph diff -r 81cd2db6df7a -r d83485dee19a src/pyams_default_theme/component/keynumber/__init__.py --- a/src/pyams_default_theme/component/keynumber/__init__.py Mon Aug 27 11:31:27 2018 +0200 +++ b/src/pyams_default_theme/component/keynumber/__init__.py Thu Aug 30 11:07:17 2018 +0200 @@ -1,5 +1,5 @@ # -# Copyright (c) 2008-2018 Thierry Florac +# Copyright (c) 2008-2015 Thierry Florac # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, @@ -12,9 +12,43 @@ __docformat__ = 'restructuredtext' - # import standard library # import interfaces +from pyams_content.component.keynumber.interfaces import IKeyNumberContainer, IKeyNumberParagraph +from pyams_content.features.renderer.interfaces import IContentRenderer +from pyams_skin.layer import IPyAMSLayer # import packages +from pyams_content.features.renderer.skin import BaseContentRenderer +from pyams_template.template import template_config +from pyams_utils.adapter import adapter_config + +from pyams_default_theme import _ + + +# +# Base Key numbers paragraph renderer +# + +class BaseKeyNumberParagraphRenderer(BaseContentRenderer): + """Default Key Numbers renderer""" + + i18n_context_attrs = ('title', ) + + @property + def keynumbers(self): + return IKeyNumberContainer(self.context) + + +# +# Key numbers paragraph default renderer +# + +@adapter_config(name='default', context=(IKeyNumberParagraph, IPyAMSLayer), provides=IContentRenderer) +@template_config(template='templates/keynumber-default.pt', layer=IPyAMSLayer) +class DefaultKeyNumberParagraphRenderer(BaseKeyNumberParagraphRenderer): + """Default Key Numbers renderer""" + + label = _("Default key numbers renderer") + weight = 1 diff -r 81cd2db6df7a -r d83485dee19a src/pyams_default_theme/component/keynumber/templates/keynumber-default.pt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_default_theme/component/keynumber/templates/keynumber-default.pt Thu Aug 30 11:07:17 2018 +0200 @@ -0,0 +1,19 @@ + +

${i18n:view.title}

+
+
+
+ ${i18n:number.label} +
+
+ ${i18n:number.number} + ${i18n:number.unit} +
+ +
+
+
diff -r 81cd2db6df7a -r d83485dee19a src/pyams_default_theme/component/paragraph/keynumber.py --- a/src/pyams_default_theme/component/paragraph/keynumber.py Mon Aug 27 11:31:27 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -# -# Copyright (c) 2008-2015 Thierry Florac -# All Rights Reserved. -# -# This software is subject to the provisions of the Zope Public License, -# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. -# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED -# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS -# FOR A PARTICULAR PURPOSE. -# - -__docformat__ = 'restructuredtext' - -# import standard library - -# import interfaces -from pyams_content.component.paragraph.interfaces.keynumber import IKeyNumberParagraph -from pyams_content.component.keynumber.interfaces import IKeyNumberContainer -from pyams_content.features.renderer.interfaces import IContentRenderer -from pyams_skin.layer import IPyAMSLayer - -# import packages -from pyams_content.features.renderer.skin import BaseContentRenderer -from pyams_template.template import template_config -from pyams_utils.adapter import adapter_config - -from pyams_default_theme import _ - - -# -# Base Key numbers paragraph renderer -# - -class BaseKeyNumberParagraphRenderer(BaseContentRenderer): - """Default Key Numbers renderer""" - - i18n_context_attrs = ('title', ) - - @property - def keynumbers(self): - return IKeyNumberContainer(self.context) - - -# -# Key numbers paragraph default renderer -# - -@adapter_config(name='default', context=(IKeyNumberParagraph, IPyAMSLayer), provides=IContentRenderer) -@template_config(template='templates/keynumber-default.pt', layer=IPyAMSLayer) -class DefaultKeyNumberParagraphRenderer(BaseKeyNumberParagraphRenderer): - """Default Key Numbers renderer""" - - label = _("Default key numbers renderer") - weight = 1 diff -r 81cd2db6df7a -r d83485dee19a src/pyams_default_theme/component/paragraph/templates/keynumber-default.pt --- a/src/pyams_default_theme/component/paragraph/templates/keynumber-default.pt Mon Aug 27 11:31:27 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ - -

${i18n:view.title}

-
-
-
- ${i18n:number.label} -
-
- ${i18n:number.number} - ${i18n:number.unit} -
- -
-
-