From f21800b16c90ba233d9dc5fabf05e21a847e159a Mon Sep 17 00:00:00 2001 From: EEA Jenkins <2368628+eea-jenkins@users.noreply.github.com> Date: Thu, 31 Aug 2023 14:36:45 +0300 Subject: [PATCH 1/7] Back to devel --- docs/HISTORY.txt | 3 +++ eea/volto/policy/version.txt | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/HISTORY.txt b/docs/HISTORY.txt index 220d60a..36995fd 100644 --- a/docs/HISTORY.txt +++ b/docs/HISTORY.txt @@ -1,6 +1,9 @@ Changelog ========= +3.2-dev0 - (unreleased) +--------------------------- + 3.1 - (2023-08-31) --------------------------- * Change: Feature: Add content rule to unset publication date when private [dobri1408 - refs #147278] diff --git a/eea/volto/policy/version.txt b/eea/volto/policy/version.txt index 8c50098..098417e 100644 --- a/eea/volto/policy/version.txt +++ b/eea/volto/policy/version.txt @@ -1 +1 @@ -3.1 +3.2-dev0 From d8534777bedba6003e539ec6bfaf33b102de8cbb Mon Sep 17 00:00:00 2001 From: nileshgulia1 Date: Wed, 28 Feb 2024 16:15:08 +0530 Subject: [PATCH 2/7] fix: use remoteUrl if its in catalog brain --- eea/volto/policy/restapi/configure.zcml | 17 +++++++- eea/volto/policy/restapi/navigation.py | 54 +++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 eea/volto/policy/restapi/navigation.py diff --git a/eea/volto/policy/restapi/configure.zcml b/eea/volto/policy/restapi/configure.zcml index 1ac45af..deec741 100644 --- a/eea/volto/policy/restapi/configure.zcml +++ b/eea/volto/policy/restapi/configure.zcml @@ -1,5 +1,20 @@ - + + + + + + diff --git a/eea/volto/policy/restapi/navigation.py b/eea/volto/policy/restapi/navigation.py new file mode 100644 index 0000000..372c89d --- /dev/null +++ b/eea/volto/policy/restapi/navigation.py @@ -0,0 +1,54 @@ +from plone.restapi.interfaces import IExpandableElement, IPloneRestapiLayer +from plone.restapi.services.navigation.get import Navigation as BaseNavigation +from plone.restapi.services.navigation.get import ( + NavigationGet as BaseNavigationGet, +) +from urllib.parse import urlparse +from zope.component import adapter +from zope.interface import Interface, implementer + + +@implementer(IExpandableElement) +@adapter(Interface, IPloneRestapiLayer) +class Navigation(BaseNavigation): + def __call__(self, expand=False): + if self.request.form.get("expand.navigation.depth", False): + self.depth = int(self.request.form["expand.navigation.depth"]) + else: + self.depth = 1 + + result = { + "navigation": {"@id": self.context.absolute_url() + "/@navigation"} + } + if not expand: + return result + + result["navigation"]["items"] = self.build_tree(self.navtree_path) + return result + + def customize_entry(self, entry, brain): + entry["brain"] = brain + if hasattr(brain, "getRemoteUrl") and brain.getRemoteUrl: + entry["path"] = urlparse(brain.getRemoteUrl).path + entry["@id"] = brain.getRemoteUrl + + return entry + + def render_item(self, item, path): + sub = self.build_tree(item["path"], first_run=False) + + item.update({"items": sub}) + + if "path" in item: + del item["path"] + + if "brain" in item: + del item["brain"] + + return item + + +class NavigationGet(BaseNavigationGet): + def reply(self): + navigation = Navigation(self.context, self.request) + return navigation(expand=True)["navigation"] From 9c3f96b31cc9f9378d5a961b8d3939813644c5ee Mon Sep 17 00:00:00 2001 From: nileshgulia1 Date: Wed, 28 Feb 2024 16:25:20 +0530 Subject: [PATCH 3/7] chore: apply pylint --- eea/volto/policy/restapi/navigation.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/eea/volto/policy/restapi/navigation.py b/eea/volto/policy/restapi/navigation.py index 372c89d..e1b2cda 100644 --- a/eea/volto/policy/restapi/navigation.py +++ b/eea/volto/policy/restapi/navigation.py @@ -1,9 +1,12 @@ +""" Navigation +""" + +from urllib.parse import urlparse from plone.restapi.interfaces import IExpandableElement, IPloneRestapiLayer from plone.restapi.services.navigation.get import Navigation as BaseNavigation from plone.restapi.services.navigation.get import ( NavigationGet as BaseNavigationGet, ) -from urllib.parse import urlparse from zope.component import adapter from zope.interface import Interface, implementer @@ -11,6 +14,8 @@ @implementer(IExpandableElement) @adapter(Interface, IPloneRestapiLayer) class Navigation(BaseNavigation): + """Navigation adapter""" + def __call__(self, expand=False): if self.request.form.get("expand.navigation.depth", False): self.depth = int(self.request.form["expand.navigation.depth"]) @@ -27,6 +32,7 @@ def __call__(self, expand=False): return result def customize_entry(self, entry, brain): + """append custom entries""" entry["brain"] = brain if hasattr(brain, "getRemoteUrl") and brain.getRemoteUrl: entry["path"] = urlparse(brain.getRemoteUrl).path @@ -35,6 +41,7 @@ def customize_entry(self, entry, brain): return entry def render_item(self, item, path): + """build navtree from item helper""" sub = self.build_tree(item["path"], first_run=False) item.update({"items": sub}) @@ -49,6 +56,9 @@ def render_item(self, item, path): class NavigationGet(BaseNavigationGet): + """Navigation get service""" + def reply(self): + """reply""" navigation = Navigation(self.context, self.request) return navigation(expand=True)["navigation"] From 7031a67993dd8123e8245a22706dc3f29ed9813d Mon Sep 17 00:00:00 2001 From: nileshgulia1 Date: Wed, 28 Feb 2024 16:34:41 +0530 Subject: [PATCH 4/7] refactor: more code to navigation folder --- eea/volto/policy/restapi/configure.zcml | 18 ++---------------- .../policy/restapi/navigation/configure.zcml | 17 +++++++++++++++++ .../restapi/{ => navigation}/navigation.py | 15 --------------- 3 files changed, 19 insertions(+), 31 deletions(-) create mode 100644 eea/volto/policy/restapi/navigation/configure.zcml rename eea/volto/policy/restapi/{ => navigation}/navigation.py (74%) diff --git a/eea/volto/policy/restapi/configure.zcml b/eea/volto/policy/restapi/configure.zcml index deec741..dc85631 100644 --- a/eea/volto/policy/restapi/configure.zcml +++ b/eea/volto/policy/restapi/configure.zcml @@ -1,20 +1,6 @@ - + - - - - - + diff --git a/eea/volto/policy/restapi/navigation/configure.zcml b/eea/volto/policy/restapi/navigation/configure.zcml new file mode 100644 index 0000000..549aa1d --- /dev/null +++ b/eea/volto/policy/restapi/navigation/configure.zcml @@ -0,0 +1,17 @@ + + + + + + + diff --git a/eea/volto/policy/restapi/navigation.py b/eea/volto/policy/restapi/navigation/navigation.py similarity index 74% rename from eea/volto/policy/restapi/navigation.py rename to eea/volto/policy/restapi/navigation/navigation.py index e1b2cda..0c93d1b 100644 --- a/eea/volto/policy/restapi/navigation.py +++ b/eea/volto/policy/restapi/navigation/navigation.py @@ -16,21 +16,6 @@ class Navigation(BaseNavigation): """Navigation adapter""" - def __call__(self, expand=False): - if self.request.form.get("expand.navigation.depth", False): - self.depth = int(self.request.form["expand.navigation.depth"]) - else: - self.depth = 1 - - result = { - "navigation": {"@id": self.context.absolute_url() + "/@navigation"} - } - if not expand: - return result - - result["navigation"]["items"] = self.build_tree(self.navtree_path) - return result - def customize_entry(self, entry, brain): """append custom entries""" entry["brain"] = brain From e8e5b8926b526c1f362553b02faa4378c8592f2a Mon Sep 17 00:00:00 2001 From: nileshgulia1 Date: Wed, 28 Feb 2024 16:41:10 +0530 Subject: [PATCH 5/7] refactor: only re-assign `@id` when anonymous --- eea/volto/policy/restapi/navigation/navigation.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/eea/volto/policy/restapi/navigation/navigation.py b/eea/volto/policy/restapi/navigation/navigation.py index 0c93d1b..2b38001 100644 --- a/eea/volto/policy/restapi/navigation/navigation.py +++ b/eea/volto/policy/restapi/navigation/navigation.py @@ -7,6 +7,7 @@ from plone.restapi.services.navigation.get import ( NavigationGet as BaseNavigationGet, ) +from Products.CMFCore.utils import getToolByName from zope.component import adapter from zope.interface import Interface, implementer @@ -21,7 +22,9 @@ def customize_entry(self, entry, brain): entry["brain"] = brain if hasattr(brain, "getRemoteUrl") and brain.getRemoteUrl: entry["path"] = urlparse(brain.getRemoteUrl).path - entry["@id"] = brain.getRemoteUrl + pm = getToolByName(self.context, "portal_membership") + if bool(pm.isAnonymousUser()): + entry["@id"] = brain.getRemoteUrl return entry From 9956dd2e1b057203fe0f9865d724d9639e2eed32 Mon Sep 17 00:00:00 2001 From: EEA Jenkins Date: Wed, 28 Feb 2024 13:40:55 +0200 Subject: [PATCH 6/7] Updated version to 3.2 --- eea/volto/policy/version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eea/volto/policy/version.txt b/eea/volto/policy/version.txt index 098417e..a3ec5a4 100644 --- a/eea/volto/policy/version.txt +++ b/eea/volto/policy/version.txt @@ -1 +1 @@ -3.2-dev0 +3.2 From 15323dfa087bdea69a991c604ddbd9d1cd9e1a50 Mon Sep 17 00:00:00 2001 From: EEA Jenkins Date: Wed, 28 Feb 2024 13:40:57 +0200 Subject: [PATCH 7/7] Updated changelog - removed develop information --- docs/HISTORY.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/HISTORY.txt b/docs/HISTORY.txt index 36995fd..a9c5415 100644 --- a/docs/HISTORY.txt +++ b/docs/HISTORY.txt @@ -1,8 +1,10 @@ Changelog ========= -3.2-dev0 - (unreleased) +3.2 - (2024-02-28) --------------------------- +* Change: Release + [nileshgulia1] 3.1 - (2023-08-31) ---------------------------