# HG changeset patch # User Thierry Florac # Date 1543502231 -3600 # Node ID 588256bd26ee71fa57a6e4be51f30e768b169fc0 # Parent 914dd6e8cf6de5c45774a2f6456decc3ee87e944 Updated paragraphs container portlet renderer diff -r 914dd6e8cf6d -r 588256bd26ee src/pyams_default_theme/component/paragraph/portlet/__init__.py --- a/src/pyams_default_theme/component/paragraph/portlet/__init__.py Thu Nov 29 11:19:23 2018 +0100 +++ b/src/pyams_default_theme/component/paragraph/portlet/__init__.py Thu Nov 29 15:37:11 2018 +0100 @@ -12,24 +12,23 @@ __docformat__ = 'restructuredtext' - -# import standard library - from zope.interface import Interface -# import interfaces from pyams_content.component.paragraph.interfaces import IParagraphContainer from pyams_content.component.paragraph.portlet.interfaces import IParagraphContainerPortletSettings, \ IParagraphNavigationPortletSettings from pyams_content.features.renderer.interfaces import ISharedContentRenderer -from pyams_default_theme import _ +from pyams_content.shared.site.interfaces import ISiteContainer +from pyams_default_theme.interfaces import IContentSummaryInfo from pyams_portal.interfaces import IPortalContext, IPortletRenderer -# import packages from pyams_portal.portlet import PortletRenderer +from pyams_sequence.interfaces import IInternalReference, ISequentialIdInfo from pyams_skin.layer import IPyAMSLayer from pyams_template.template import template_config from pyams_utils.adapter import adapter_config +from pyams_default_theme import _ + @adapter_config(context=(IPortalContext, IPyAMSLayer, Interface, IParagraphContainerPortletSettings), provides=IPortletRenderer) @@ -57,6 +56,36 @@ self.renderers = list(filter(lambda x: x is not None, renderers)) [renderer.update() for renderer in self.renderers] + def get_navigation_links(self): + + def test_item(nav_item): + item_sequence = ISequentialIdInfo(nav_item, None) + if (item_sequence is not None) and (item_sequence.oid == context_sequence.oid): + return True + if IInternalReference.providedBy(nav_item) and (nav_item.reference == context_sequence.hex_oid): + return True + + prev_nav, next_nav = None, None + context_sequence = ISequentialIdInfo(self.context, None) + if context_sequence is not None: + display_context = self.request.display_context + if ISiteContainer.providedBy(display_context): + registry = self.request.registry + previous_item = None + items = display_context.get_visible_items(self.request) + for item in items: + if test_item(item): + prev_nav = registry.queryMultiAdapter((previous_item, self.request), IContentSummaryInfo) + break + previous_item = item + try: + next_item = next(items) + except StopIteration: + pass + else: + next_nav = registry.queryMultiAdapter((next_item, self.request), IContentSummaryInfo) + return prev_nav, next_nav + @adapter_config(context=(IPortalContext, IPyAMSLayer, Interface, IParagraphNavigationPortletSettings), provides=IPortletRenderer) diff -r 914dd6e8cf6d -r 588256bd26ee src/pyams_default_theme/component/paragraph/portlet/templates/content.pt --- a/src/pyams_default_theme/component/paragraph/portlet/templates/content.pt Thu Nov 29 11:19:23 2018 +0100 +++ b/src/pyams_default_theme/component/paragraph/portlet/templates/content.pt Thu Nov 29 15:37:11 2018 +0100 @@ -6,4 +6,28 @@ ${structure:renderer.render()} + + + + +