# HG changeset patch # User Thierry Florac # Date 1569400039 -7200 # Node ID 6a70ef009b651ca4028add9a16f53184b5038acc # Parent 7475b50516c8eb28bd63a4142470545f9ee7a81b Added view items portlet renderer diff -r 7475b50516c8 -r 6a70ef009b65 src/pyams_default_theme/shared/view/portlet/__init__.py --- a/src/pyams_default_theme/shared/view/portlet/__init__.py Wed Sep 25 10:10:16 2019 +0200 +++ b/src/pyams_default_theme/shared/view/portlet/__init__.py Wed Sep 25 10:27:19 2019 +0200 @@ -10,16 +10,14 @@ # FOR A PARTICULAR PURPOSE. # -__docformat__ = 'restructuredtext' - from persistent import Persistent from zope.container.contained import Contained from zope.interface import Interface from zope.schema.fieldproperty import FieldProperty from pyams_content.shared.view.portlet.interfaces import IViewItemsPortletSettings -from pyams_default_theme import _ -from pyams_default_theme.shared.view.portlet.interfaces import IViewItemsPortletHorizontalRendererSettings, \ +from pyams_default_theme.shared.view.portlet.interfaces import \ + IViewItemsPortletHorizontalRendererSettings, IViewItemsPortletSummaryRendererSettings, \ IViewItemsPortletVerticalRendererSettings from pyams_portal.interfaces import IPortalContext, IPortletRenderer from pyams_portal.portlet import PortletRenderer @@ -30,6 +28,11 @@ from pyams_utils.url import canonical_url, relative_url +__docformat__ = 'restructuredtext' + +from pyams_default_theme import _ + + class BaseViewItemsPortletRenderer(PortletRenderer): """Base view items portlet renderer""" @@ -56,9 +59,12 @@ class ViewItemsPortletVerticalRendererSettings(Persistent, Contained): """View items portlet vertical renderer settings""" - display_illustrations = FieldProperty(IViewItemsPortletVerticalRendererSettings['display_illustrations']) - thumbnails_selection = FieldProperty(IViewItemsPortletVerticalRendererSettings['thumbnails_selection']) - display_breadcrumbs = FieldProperty(IViewItemsPortletVerticalRendererSettings['display_breadcrumbs']) + display_illustrations = FieldProperty( + IViewItemsPortletVerticalRendererSettings['display_illustrations']) + thumbnails_selection = FieldProperty( + IViewItemsPortletVerticalRendererSettings['thumbnails_selection']) + display_breadcrumbs = FieldProperty( + IViewItemsPortletVerticalRendererSettings['display_breadcrumbs']) display_tags = FieldProperty(IViewItemsPortletVerticalRendererSettings['display_tags']) paginate = FieldProperty(IViewItemsPortletVerticalRendererSettings['paginate']) page_size = FieldProperty(IViewItemsPortletVerticalRendererSettings['page_size']) @@ -71,7 +77,7 @@ """View items portlet vertical renderer""" label = _("Simple vertical view") - weight = 0 + weight = 1 settings_interface = IViewItemsPortletVerticalRendererSettings @@ -84,7 +90,8 @@ class ViewItemsPortletHorizontalRendererSettings(Persistent, Contained): """View items portlet horizontal renderer settings""" - thumbnails_selection = FieldProperty(IViewItemsPortletHorizontalRendererSettings['thumbnails_selection']) + thumbnails_selection = FieldProperty( + IViewItemsPortletHorizontalRendererSettings['thumbnails_selection']) @adapter_config(name='horizontal', @@ -95,6 +102,35 @@ """View items portlet horizontal renderer""" label = _("Simple horizontal thumbnails view") - weight = 1 + weight = 2 settings_interface = IViewItemsPortletHorizontalRendererSettings + + +# +# Summary-like portlet renderer +# + +@factory_config(provided=IViewItemsPortletSummaryRendererSettings) +class ViewItemsPortletSummaryRendererSettings(Persistent, Contained): + """View items portlet renderer summary renderer settings""" + + display_illustrations = FieldProperty( + IViewItemsPortletSummaryRendererSettings['display_illustrations']) + thumbnails_selection = FieldProperty( + IViewItemsPortletSummaryRendererSettings['thumbnails_selection']) + paginate = FieldProperty(IViewItemsPortletSummaryRendererSettings['paginate']) + page_size = FieldProperty(IViewItemsPortletSummaryRendererSettings['page_size']) + + +@adapter_config(name='summary', + context=(IPortalContext, IPyAMSLayer, Interface, IViewItemsPortletSettings), + provides=IPortletRenderer) +@template_config(template='templates/view-items-summary.pt', layer=IPyAMSLayer) +class ViewItemsPortletSummaryRenderer(BaseViewItemsPortletRenderer): + """View items portlet summary renderer""" + + label = _("Vertical panels view") + weight = 3 + + settings_interface = IViewItemsPortletSummaryRendererSettings diff -r 7475b50516c8 -r 6a70ef009b65 src/pyams_default_theme/shared/view/portlet/interfaces.py --- a/src/pyams_default_theme/shared/view/portlet/interfaces.py Wed Sep 25 10:10:16 2019 +0200 +++ b/src/pyams_default_theme/shared/view/portlet/interfaces.py Wed Sep 25 10:27:19 2019 +0200 @@ -10,11 +10,12 @@ # FOR A PARTICULAR PURPOSE. # -__docformat__ = 'restructuredtext' +from zope.interface import Interface +from zope.schema import Bool, Choice, Int +from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary -from zope.interface import Interface -from zope.schema import Bool, Int, Choice -from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm + +__docformat__ = 'restructuredtext' from pyams_default_theme import _ @@ -33,7 +34,8 @@ """View items portlet vertical renderer settings interface""" display_illustrations = Bool(title=_("Display illustrations?"), - description=_("If 'no', view contents will not display illustrations"), + description=_("If 'no', view contents will not display " + "illustrations"), required=True, default=True) @@ -44,7 +46,8 @@ default='pano') display_breadcrumbs = Bool(title=_("Display breadcrumbs?"), - description=_("If 'no', view items breadcrumbs will not be displayed"), + description=_("If 'no', view items breadcrumbs will not be " + "displayed"), required=True, default=True) @@ -72,3 +75,29 @@ vocabulary=VIEW_ITEMS_THUMBNAILS_VOCABULARY, required=True, default='portrait') + + +class IViewItemsPortletSummaryRendererSettings(Interface): + """View items portlet summary renderer settings interface""" + + display_illustrations = Bool(title=_("Display illustrations?"), + description=_("If 'no', view contents will not display " + "illustrations"), + required=True, + default=True) + + thumbnails_selection = Choice(title=_("Thumbnails selection"), + description=_("Selection used to display images thumbnails"), + vocabulary=VIEW_ITEMS_THUMBNAILS_VOCABULARY, + required=True, + default='pano') + + paginate = Bool(title=_("Paginate?"), + description=_("If 'no', results pagination will be disabled"), + required=True, + default=True) + + page_size = Int(title=_("Page size"), + description=_("Number of items per page, if pagination is enabled"), + required=False, + default=9) diff -r 7475b50516c8 -r 6a70ef009b65 src/pyams_default_theme/shared/view/portlet/templates/view-items-summary.pt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_default_theme/shared/view/portlet/templates/view-items-summary.pt Wed Sep 25 10:27:19 2019 +0200 @@ -0,0 +1,61 @@ +
+

${i18n:settings.title}

+ +