From 1961211ed62240441cc843343eca6532dbe079fe Mon Sep 17 00:00:00 2001 From: davisagli Date: Sat, 21 Sep 2024 09:08:30 -0700 Subject: [PATCH] [fc] Repository: plone.restapi MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Branch: refs/heads/main Date: 2024-09-21T09:08:30-07:00 Author: Steve Piercy (stevepiercy) Commit: https://github.com/plone/plone.restapi/commit/682567a86b9fc022fbad32e27906475c5410eee1 Revert duplication of pip install -r requirements-docs.txt in GitHub … (#1817) * Revert duplication of pip install -r requirements-docs.txt in GitHub workflow * news * Delete news/1817.internal --------- Co-authored-by: David Glick <david@glicksoftware.com> Files changed: M .github/workflows/tests.yml --- last_commit.txt | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/last_commit.txt b/last_commit.txt index fc30cc117c..8a6b9a94b4 100644 --- a/last_commit.txt +++ b/last_commit.txt @@ -2,38 +2,24 @@ Repository: plone.restapi Branch: refs/heads/main -Date: 2024-09-20T17:06:15-07:00 -Author: Mauro Amico (mamico) -Commit: https://github.com/plone/plone.restapi/commit/913f49b7e48f6e7dc3dbea5ea72428611d16e796 +Date: 2024-09-21T09:08:30-07:00 +Author: Steve Piercy (stevepiercy) +Commit: https://github.com/plone/plone.restapi/commit/682567a86b9fc022fbad32e27906475c5410eee1 -fix show_excluded_items in @navigation api (#1816) +Revert duplication of pip install -r requirements-docs.txt in GitHub … (#1817) -* fix show_excluded_items in @navigation api +* Revert duplication of pip install -r requirements-docs.txt in GitHub workflow -* changelog +* news -* black - -* revert pyenv - -* typo - -Co-authored-by: Steve Piercy <web@stevepiercy.com> - -* Update 1816.bugfix - -Co-authored-by: Steve Piercy <web@stevepiercy.com> - -* fix tests +* Delete news/1817.internal --------- -Co-authored-by: Steve Piercy <web@stevepiercy.com> +Co-authored-by: David Glick <david@glicksoftware.com> Files changed: -A news/1816.bugfix -M src/plone/restapi/services/navigation/get.py -M src/plone/restapi/tests/test_services_navigation.py +M .github/workflows/tests.yml -b'diff --git a/news/1816.bugfix b/news/1816.bugfix\nnew file mode 100644\nindex 000000000..2bb52fc58\n--- /dev/null\n+++ b/news/1816.bugfix\n@@ -0,0 +1,2 @@\n+Fix incorrect condition for ``show_excluded_items`` setting in the ``@navigation`` API.\n+[mamico]\ndiff --git a/src/plone/restapi/services/navigation/get.py b/src/plone/restapi/services/navigation/get.py\nindex 665f22da0..a21a52abe 100644\n--- a/src/plone/restapi/services/navigation/get.py\n+++ b/src/plone/restapi/services/navigation/get.py\n@@ -135,7 +135,9 @@ def navtree(self):\n if brain_parent_path == navtree_path:\n # This should be already provided by the portal_tabs_view\n continue\n- if brain.exclude_from_nav and not context_path.startswith(brain_path):\n+ if brain.exclude_from_nav and not f"{brain_path}/".startswith(\n+ f"{context_path}/"\n+ ):\n # skip excluded items if they\'re not in our context path\n continue\n url = brain.getURL()\ndiff --git a/src/plone/restapi/tests/test_services_navigation.py b/src/plone/restapi/tests/test_services_navigation.py\nindex dc466bc38..890c5c122 100644\n--- a/src/plone/restapi/tests/test_services_navigation.py\n+++ b/src/plone/restapi/tests/test_services_navigation.py\n@@ -124,6 +124,43 @@ def test_dont_broke_with_contents_without_review_state(self):\n )\n self.assertIsNone(response.json()["items"][1]["items"][3]["review_state"])\n \n+ def test_show_excluded_items(self):\n+ registry = getUtility(IRegistry)\n+ settings = registry.forInterface(INavigationSchema, prefix="plone")\n+\n+ # Plone 5.2 and Plone 6.0 have different default values:\n+ # False for Plone 6.0 and True for Plone 5.2\n+ # explicitly set the value to False to avoid test failures\n+ settings.show_excluded_items = False\n+ createContentInContainer(\n+ self.folder,\n+ "Folder",\n+ id="excluded-subfolder",\n+ title="Excluded SubFolder",\n+ exclude_from_nav=True,\n+ )\n+ transaction.commit()\n+ response = self.api_session.get(\n+ "/folder/@navigation", params={"expand.navigation.depth": 2}\n+ )\n+ self.assertNotIn(\n+ "Excluded SubFolder",\n+ [item["title"] for item in response.json()["items"][1]["items"]],\n+ )\n+\n+ # change setting to show excluded items\n+ registry = getUtility(IRegistry)\n+ settings = registry.forInterface(INavigationSchema, prefix="plone")\n+ settings.show_excluded_items = True\n+ transaction.commit()\n+ response = self.api_session.get(\n+ "/folder/@navigation", params={"expand.navigation.depth": 2}\n+ )\n+ self.assertIn(\n+ "Excluded SubFolder",\n+ [item["title"] for item in response.json()["items"][1]["items"]],\n+ )\n+\n def test_navigation_sorting(self):\n registry = getUtility(IRegistry)\n registry["plone.displayed_types"] = (\n' +b'diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml\nindex 64f7dc2ee..73447527b 100644\n--- a/.github/workflows/tests.yml\n+++ b/.github/workflows/tests.yml\n@@ -60,7 +60,7 @@ jobs:\n \n # build sphinx\n - name: sphinx\n- run: if [ "${{ matrix.plone-version }}" == "6.0" ] && [ ${{ matrix.python-version }} == \'3.12\' ]; then pip install -r requirements-docs.txt && make docs-html; fi\n+ run: if [ "${{ matrix.plone-version }}" == "6.0" ] && [ ${{ matrix.python-version }} == \'3.12\' ]; then make docs-html; fi\n \n # test\n - name: test\n'