From eb088d63605184adcf434228dc890b4cfc43613f Mon Sep 17 00:00:00 2001 From: EEA Jenkins <2368628+eea-jenkins@users.noreply.github.com> Date: Thu, 5 Dec 2024 21:37:29 +0200 Subject: [PATCH 1/8] 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 fbc6861..72def36 100644 --- a/docs/HISTORY.txt +++ b/docs/HISTORY.txt @@ -1,6 +1,9 @@ Changelog ========= +6.1-dev0 - (unreleased) +--------------------------- + 6.0 - (2024-12-05) --------------------------- * Change: Fix plone.app.vocabularies.Users to work with Creators and Contributors Field diff --git a/eea/volto/policy/version.txt b/eea/volto/policy/version.txt index e0ea36f..f82415f 100644 --- a/eea/volto/policy/version.txt +++ b/eea/volto/policy/version.txt @@ -1 +1 @@ -6.0 +6.1-dev0 From 21f01d88d19fbaba5ba1e997d178f01475cfdfab Mon Sep 17 00:00:00 2001 From: David Ichim Date: Tue, 10 Dec 2024 17:06:22 +0200 Subject: [PATCH 2/8] fix(context-navigation): avoid querying nav on layout and add new content on additional files variation - Due to it's configuration we can increase the server load by adding a new report within a top level folder thus creating a large query even though it is not used by the object since you are just adding it then --- .../restapi/services/contextnavigation/get.py | 66 ++++++++++++++----- 1 file changed, 48 insertions(+), 18 deletions(-) diff --git a/eea/volto/policy/restapi/services/contextnavigation/get.py b/eea/volto/policy/restapi/services/contextnavigation/get.py index 6e28335..f646b9d 100644 --- a/eea/volto/policy/restapi/services/contextnavigation/get.py +++ b/eea/volto/policy/restapi/services/contextnavigation/get.py @@ -1,12 +1,16 @@ """EEA Context Navigation""" +from Acquisition import aq_inner from zope.component import getUtility from zope.component import adapter +from zope.globalrequest import getRequest from zope.schema.interfaces import IFromUnicode from zope.interface import implementer from zope.interface import Interface +from Products.CMFCore.interfaces import ISiteRoot from Products.CMFPlone.utils import normalizeString -from plone.app.layout.navigation.root import getNavigationRoot +from plone.app.layout.navigation.navtree import buildFolderTree +from plone.base.navigationroot import get_navigation_root from plone.app.dexterity import _ from plone.restapi.services.contextnavigation import get as original_get from plone.restapi.interfaces import IExpandableElement, IPloneRestapiLayer @@ -15,6 +19,7 @@ from plone.restapi.bbb import safe_hasattr from plone import schema from plone import api +from plone.memoize.instance import memoize class IEEANavigationPortlet(original_get.INavigationPortlet): @@ -87,11 +92,25 @@ def __init__(self, context, data): if depth == 0: depth = 999 + currentFolderOnly = data.currentFolderOnly + root = original_get.get_root(context, data.root_path) if root is not None: rootPath = "/".join(root.getPhysicalPath()) else: - rootPath = getNavigationRoot(context) + rootPath = get_navigation_root(context) if not currentFolderOnly \ + else "/".join(context.getPhysicalPath()) + + # avoid large queries on layout pages where context is site + if currentFolderOnly: + request = getRequest() + # don't query when we add a new page and we use report_navigation + is_site = ISiteRoot.providedBy(context) + if is_site or 'add?type' in request.get('HTTP_REFERER', '') and \ + request.form.get('expand.contextnavigation.variation', '') \ + == 'report_navigation': + self.query = {} + return None # EEA modification to always use the rootPath for query self.query["path"] = {"query": rootPath, "depth": depth, @@ -106,7 +125,15 @@ def __init__(self, context, data): self.query["path"]["navtree_start"] = depth -original_get.QueryBuilder = EEAContextNavigationQueryBuilder +class EEANavtreeStrategy(original_get.NavtreeStrategy): + """Custom NavtreeStrategy for context navigation""" + + def decoratorFactory(self, node): + """Decorate the navigation tree""" + new_node = super().decoratorFactory(node) + if getattr(new_node["item"], "side_nav_title", False): + new_node["side_nav_title"] = new_node["item"].side_nav_title + return new_node class EEANavigationPortletRenderer(original_get.NavigationPortletRenderer): @@ -180,6 +207,24 @@ def title(self): # handle bug where empty title is set to undefined from Volto return name if name != "undefined" else self.data.title + @memoize + def getNavTree(self, _marker=None): + """ Get the navigation tree """ + + if _marker is None: + _marker = [] + context = aq_inner(self.context) + queryBuilder = EEAContextNavigationQueryBuilder(context, self.data) + query_result = queryBuilder() + if not query_result: + return {"children": []} + strategy = EEANavtreeStrategy(context, self.data) + + tree = buildFolderTree( + context, obj=context, query=query_result, strategy=strategy + ) + return tree + def recurse(self, children, level, bottomLevel): """Recurse through the navigation tree""" res = [] @@ -289,18 +334,3 @@ def reply(self): return navigation(expand=True, prefix="expand.contextnavigation.")[ "contextnavigation" ] - - -class EEANavtreeStrategy(original_get.NavtreeStrategy): - """Custom NavtreeStrategy for context navigation""" - - def decoratorFactory(self, node): - """Decorate the navigation tree""" - new_node = super().decoratorFactory(node) - if getattr(new_node["item"], "side_nav_title", False): - new_node["side_nav_title"] = new_node["item"].side_nav_title - return new_node - - -# Monkey patch the original NavtreeStrategy -original_get.NavtreeStrategy = EEANavtreeStrategy From 00e5f14f6c7d8618a6ed3560c84e8a6f46d73d3a Mon Sep 17 00:00:00 2001 From: David Ichim Date: Tue, 10 Dec 2024 17:11:57 +0200 Subject: [PATCH 3/8] lint fixes --- eea/volto/policy/restapi/services/contextnavigation/get.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/eea/volto/policy/restapi/services/contextnavigation/get.py b/eea/volto/policy/restapi/services/contextnavigation/get.py index f646b9d..9feabeb 100644 --- a/eea/volto/policy/restapi/services/contextnavigation/get.py +++ b/eea/volto/policy/restapi/services/contextnavigation/get.py @@ -107,10 +107,10 @@ def __init__(self, context, data): # don't query when we add a new page and we use report_navigation is_site = ISiteRoot.providedBy(context) if is_site or 'add?type' in request.get('HTTP_REFERER', '') and \ - request.form.get('expand.contextnavigation.variation', '') \ - == 'report_navigation': + request.form.get('expand.contextnavigation.variation', '')\ + == 'report_navigation': self.query = {} - return None + return # EEA modification to always use the rootPath for query self.query["path"] = {"query": rootPath, "depth": depth, From 0c330b6b6b4179d9d4cef430bbc9c0a836540b92 Mon Sep 17 00:00:00 2001 From: David Ichim Date: Tue, 10 Dec 2024 17:39:28 +0200 Subject: [PATCH 4/8] change import for getNavigationRoot to please test although this import is seen as deprecated --- eea/volto/policy/restapi/services/contextnavigation/get.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eea/volto/policy/restapi/services/contextnavigation/get.py b/eea/volto/policy/restapi/services/contextnavigation/get.py index 9feabeb..2facbd3 100644 --- a/eea/volto/policy/restapi/services/contextnavigation/get.py +++ b/eea/volto/policy/restapi/services/contextnavigation/get.py @@ -10,7 +10,7 @@ from Products.CMFCore.interfaces import ISiteRoot from Products.CMFPlone.utils import normalizeString from plone.app.layout.navigation.navtree import buildFolderTree -from plone.base.navigationroot import get_navigation_root +from plone.app.layout.navigation.root import getNavigationRoot from plone.app.dexterity import _ from plone.restapi.services.contextnavigation import get as original_get from plone.restapi.interfaces import IExpandableElement, IPloneRestapiLayer @@ -98,7 +98,7 @@ def __init__(self, context, data): if root is not None: rootPath = "/".join(root.getPhysicalPath()) else: - rootPath = get_navigation_root(context) if not currentFolderOnly \ + rootPath = getNavigationRoot(context) if not currentFolderOnly \ else "/".join(context.getPhysicalPath()) # avoid large queries on layout pages where context is site From 1744ca5311e16fbb1d35eb19ba12d16ffa01c6b1 Mon Sep 17 00:00:00 2001 From: EEA Jenkins Date: Tue, 10 Dec 2024 17:42:55 +0200 Subject: [PATCH 5/8] Updated version to 6.1 --- 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 f82415f..a435f5a 100644 --- a/eea/volto/policy/version.txt +++ b/eea/volto/policy/version.txt @@ -1 +1 @@ -6.1-dev0 +6.1 From 34f82793badb6e55b17fa264d4e8eef5af64fecd Mon Sep 17 00:00:00 2001 From: EEA Jenkins Date: Tue, 10 Dec 2024 17:42:58 +0200 Subject: [PATCH 6/8] 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 72def36..9832404 100644 --- a/docs/HISTORY.txt +++ b/docs/HISTORY.txt @@ -1,8 +1,10 @@ Changelog ========= -6.1-dev0 - (unreleased) +6.1 - (2024-12-10) --------------------------- +* Change: Release + [ichim-david] 6.0 - (2024-12-05) --------------------------- From 0821ad5d44a28e66b7d74ab8ad392145848da306 Mon Sep 17 00:00:00 2001 From: David Ichim Date: Tue, 10 Dec 2024 17:46:43 +0200 Subject: [PATCH 7/8] Modified history entry --- docs/HISTORY.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/HISTORY.txt b/docs/HISTORY.txt index 9832404..8b73d26 100644 --- a/docs/HISTORY.txt +++ b/docs/HISTORY.txt @@ -3,8 +3,10 @@ Changelog 6.1 - (2024-12-10) --------------------------- -* Change: Release - [ichim-david] +* Fix: large query on context navigation when on layout or add new item. + We return no results when we have the `Additional files` variation set + since it has potential to have a very large number of items. + [ichim-david - refs #280463] 6.0 - (2024-12-05) --------------------------- From 3d2a4ae176fdd21c786e6e1b6f8220f56cecb202 Mon Sep 17 00:00:00 2001 From: alin Date: Wed, 11 Dec 2024 11:39:39 +0200 Subject: [PATCH 8/8] Add Language querystring field in order to be able to filter by language in Search block - refs #281503 --- docs/HISTORY.txt | 2 ++ eea/volto/policy/profiles.zcml | 9 +++++++++ eea/volto/policy/profiles/default/metadata.xml | 2 +- .../plone.app.querystring.field.Language.xml | 16 ++++++++++++++++ eea/volto/policy/setuphandlers.py | 1 + eea/volto/policy/upgrades/configure.zcml | 12 ++++++++++++ 6 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 eea/volto/policy/profiles/multilingual/registry/plone.app.querystring.field.Language.xml diff --git a/docs/HISTORY.txt b/docs/HISTORY.txt index 8b73d26..c6a10ed 100644 --- a/docs/HISTORY.txt +++ b/docs/HISTORY.txt @@ -7,6 +7,8 @@ Changelog We return no results when we have the `Additional files` variation set since it has potential to have a very large number of items. [ichim-david - refs #280463] +* Feature: Add `Language` querystring field in order to be able to filter by language in Search block + [avoinea - refs #281503] 6.0 - (2024-12-05) --------------------------- diff --git a/eea/volto/policy/profiles.zcml b/eea/volto/policy/profiles.zcml index 66ddd3f..853580d 100644 --- a/eea/volto/policy/profiles.zcml +++ b/eea/volto/policy/profiles.zcml @@ -16,6 +16,15 @@ post_handler=".setuphandlers.post_install" /> + + - 5.4 + 6.1 profile-plone.volto:default diff --git a/eea/volto/policy/profiles/multilingual/registry/plone.app.querystring.field.Language.xml b/eea/volto/policy/profiles/multilingual/registry/plone.app.querystring.field.Language.xml new file mode 100644 index 0000000..9c500bd --- /dev/null +++ b/eea/volto/policy/profiles/multilingual/registry/plone.app.querystring.field.Language.xml @@ -0,0 +1,16 @@ + + + + Language + The language of the content. + True + False + + plone.app.querystring.operation.selection.any + + plone.app.vocabularies.SupportedContentLanguages + Text + + diff --git a/eea/volto/policy/setuphandlers.py b/eea/volto/policy/setuphandlers.py index d211252..b4c0fb9 100644 --- a/eea/volto/policy/setuphandlers.py +++ b/eea/volto/policy/setuphandlers.py @@ -19,6 +19,7 @@ def getNonInstallableProfiles(self): """ Hide uninstall profile from site-creation and quickinstaller. """ return [ + 'eea.volto.policy:multilingual', 'eea.volto.policy:uninstall', ] diff --git a/eea/volto/policy/upgrades/configure.zcml b/eea/volto/policy/upgrades/configure.zcml index bda67d6..4cc1cf4 100644 --- a/eea/volto/policy/upgrades/configure.zcml +++ b/eea/volto/policy/upgrades/configure.zcml @@ -74,4 +74,16 @@ + + + + + +