From 602ccc6955eb066a989b24bfc0ac85b72da7cdc6 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Mon, 5 Aug 2024 12:01:03 -0700 Subject: [PATCH 1/8] Clean up contributing docs and use RTD for pull request previews (#1798) * Purge obsolete theme items and Netlify; Bump version * Add pre-requisites and references to contributing to Plone in general * Remove obsolete `make docs` and `bin/sphinxbuilder` * Simplify Contributing * news * Purge Netlify * Add RTD pull request preview workflow * Use RTD to build docs and pull request previews * Fix project slug * Attempt to trigger RTD PR preview * Override docutils pin from Zope * Attempt to get all tests to pass with a special config for Plone 6 on Python 3.8 * Compare against `origin/main` * Remove Python 3.7 section --- .github/workflows/rtd-pr-preview.yml | 22 ++++++++ .github/workflows/tests.yml | 2 +- .readthedocs.yaml | 36 ++++++------- Makefile | 11 ++-- docs/requirements.txt | 2 - docs/source/conf.py | 12 +---- docs/source/contributing/index.md | 80 ++++++++++++++-------------- netlify.toml | 5 -- news/1798.documentation | 1 + plone-6.0.x-python3.8.cfg | 17 ++++++ plone-6.0.x.cfg | 2 + plone-6.1.x.cfg | 4 +- 12 files changed, 108 insertions(+), 86 deletions(-) create mode 100644 .github/workflows/rtd-pr-preview.yml delete mode 100644 docs/requirements.txt delete mode 100644 netlify.toml create mode 100644 news/1798.documentation create mode 100644 plone-6.0.x-python3.8.cfg diff --git a/.github/workflows/rtd-pr-preview.yml b/.github/workflows/rtd-pr-preview.yml new file mode 100644 index 000000000..28e329ecf --- /dev/null +++ b/.github/workflows/rtd-pr-preview.yml @@ -0,0 +1,22 @@ +# .github/workflows/rtd-pr-preview.yml +name: readthedocs/actions +on: + pull_request_target: + types: + - opened + # Execute this action only on PRs that touch + # documentation files. + # paths: + # - "docs/**" + +permissions: + pull-requests: write + +jobs: + documentation-links: + runs-on: ubuntu-latest + steps: + - uses: readthedocs/actions/preview@v1 + with: + project-slug: "plonerestapi" + single-version: "true" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b93241b9d..b354a9e4d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -54,7 +54,7 @@ jobs: # buildout - name: buildout - run: buildout -t 10 -c plone-${{ matrix.plone-version }}.x.cfg + run: if [ "${{ matrix.plone-version }}" == "6.0" ] && [ ${{ matrix.python-version }} == '3.8' ]; then buildout -t 10 -c plone-6.0.x-python3.8.cfg; else buildout -t 10 -c plone-${{ matrix.plone-version }}.x.cfg; fi; env: CI: true diff --git a/.readthedocs.yaml b/.readthedocs.yaml index deeaa762f..0bf1b9ba8 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -5,25 +5,21 @@ # Required version: 2 -# Set the version of Python and other tools you might need +# Set the OS, Python version and other tools you might need build: - os: ubuntu-20.04 + os: ubuntu-22.04 tools: - python: "3.9" - # You can also specify other tool versions: - # nodejs: "16" - # rust: "1.55" - # golang: "1.17" - -# Build documentation in the docs/ directory with Sphinx -sphinx: - configuration: docs/source/conf.py - -# If using Sphinx, optionally build your docs in additional formats such as PDF -# formats: -# - pdf - -# Optionally declare the Python requirements required to build your docs -python: - install: - - requirements: requirements-docs.txt + python: "3.12" + commands: + # Cancel building pull requests when there aren't changes in the docs directory or YAML file. + # You can add any other files or directories that you'd like here as well, + # like your docs requirements file, or other files that will change your docs build. + # + # If there are no changes (git diff exits with 0) we force the command to return with 183. + # This is a special exit code on Read the Docs that will cancel the build immediately. + - | + if [ "$READTHEDOCS_VERSION_TYPE" = "external" ] && git diff --quiet origin/main -- docs/ .readthedocs.yaml requirements-docs.txt requirements.txt; + then + exit 183; + fi + - make rtd-pr-preview diff --git a/Makefile b/Makefile index eb379c7b7..71c500930 100644 --- a/Makefile +++ b/Makefile @@ -95,10 +95,6 @@ black: ## Black zpretty: ## zpretty if [ -f "bin/zpretty" ]; then zpretty -i ./**/*.zcml; fi -.PHONY: Build Docs -docs: ## Build Docs - bin/sphinxbuilder - .PHONY: docs-clean docs-clean: ## Clean current and legacy docs build directories, and Python virtual environment cd $(DOCS_DIR) && rm -rf $(BUILDDIR)/ @@ -138,10 +134,11 @@ docs-vale: ## Run Vale style, grammar, and spell checks @echo @echo "Vale is finished; look for any errors in the above output." -.PHONY: netlify -netlify: +.PHONY: rtd-pr-preview +rtd-pr-preview: ## Build pull request preview on Read the Docs + pip install -r requirements.txt pip install -r requirements-docs.txt - cd $(DOCS_DIR) && sphinx-build -b html $(ALLSPHINXOPTS) ../$(BUILDDIR)/html + cd $(DOCS_DIR) && sphinx-build -b html $(ALLSPHINXOPTS) ${READTHEDOCS_OUTPUT}/html/ .PHONY: Test Release test-release: ## Run Pyroma and Check Manifest diff --git a/docs/requirements.txt b/docs/requirements.txt deleted file mode 100644 index 82f259eac..000000000 --- a/docs/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -sphinxcontrib.httpdomain -sphinxcontrib.httpexample \ No newline at end of file diff --git a/docs/source/conf.py b/docs/source/conf.py index d8e125b8f..c1cb7ad6f 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -34,7 +34,7 @@ # built documents. # TODO: There must be a way to import this from `setup.py` so we don't have to # update it manually for each release. -version = "8.24.2.dev0" +version = "9.7.2.dev0" release = version # -- General configuration ---------------------------------------------------- @@ -176,15 +176,7 @@ def patch_pygments_to_highlight_jsonschema(): "use_repository_button": True, "use_issues_button": True, "use_edit_page_button": True, - "extra_navbar": """ - """, - "extra_footer": """

The text and illustrations in this website are licensed by the Plone Foundation under a Creative Commons Attribution 4.0 International license. Plone and the PloneĀ® logo are registered trademarks of the Plone Foundation, registered in the United States and other countries. For guidelines on the permitted uses of the Plone trademarks, see https://plone.org/foundation/logo. All other trademarks are owned by their respective owners.

-

- Deploys by Netlify -

""", + "extra_footer": """

The text and illustrations in this website are licensed by the Plone Foundation under a Creative Commons Attribution 4.0 International license. Plone and the PloneĀ® logo are registered trademarks of the Plone Foundation, registered in the United States and other countries. For guidelines on the permitted uses of the Plone trademarks, see https://plone.org/foundation/logo. All other trademarks are owned by their respective owners.

""", } # Theme options are theme-specific and customize the look and feel of a theme diff --git a/docs/source/contributing/index.md b/docs/source/contributing/index.md index 5654a396d..1c0c9ac61 100644 --- a/docs/source/contributing/index.md +++ b/docs/source/contributing/index.md @@ -1,13 +1,24 @@ --- myst: html_meta: - "description": "Contributing to plone.restapi" - "property=og:description": "Contributing to plone.restapi" - "property=og:title": "Contributing to plone.restapi" - "keywords": "Plone, plone.restapi, REST, API, Contributing, documentation" + "description": "Contribute to plone.restapi" + "property=og:description": "Contribute to plone.restapi" + "property=og:title": "Contribute to plone.restapi" + "keywords": "Plone, plone.restapi, REST, API, contribute, documentation" --- -# Contributing to `plone.restapi` +# Contribute to `plone.restapi` + +This section describes how to contribute to the `plone.restapi` project. +It extends {doc}`plone:contributing/index`. + + +## Pre-requisites + +Prepare your system by installing {ref}`plone:plone-pre-requisites-label`. + + +## Set up development environment We use GNU `make` when developing `plone.restapi`. To install this package, its dependencies, and its documentation, code formatting, and testing tools, run the following command in the root of the project. @@ -16,21 +27,27 @@ To install this package, its dependencies, and its documentation, code formattin make ``` -## Generating documentation examples +To see all the Makefile targets and help, use the following command. + +```shell +make help +``` + + +## Generate documentation examples -This documentation includes examples of requests and responses (http, curl, httpie, and python-requests). +This documentation includes examples of requests and responses, using each of http, curl, httpie, and python-requests. These examples are generated by the documentation tests in `test_documentation.py`. -To generate a new example, add a new test case to `test_documentation.py`, for example `test_documentation_search_fullobjects`, and run the test +To generate a new example, add a new test case to `test_documentation.py`, for example `test_documentation_search_fullobjects`, and run the test. ```shell ./bin/test -t test_documentation_search_fullobjects ``` -This generates the request and the response files in `tests/http-examples/`. +The above command also generates the request and the response files in `tests/http-examples/`. +Include them in the documentation using MyST syntax. -Include them in the documentation using MyST syntax: - -```` +````markdown ```{eval-rst} .. http:example:: curl httpie python-requests :request: ../../src/plone/restapi/tests/http-examples/search_fullobjects.req @@ -40,31 +57,14 @@ Include them in the documentation using MyST syntax: ``` ```` -Build the documentation locally to test the rendering by running `./bin/sphinxbuilder`. -Alternatively, you can use Makefile targets: - -`docs-clean` -: Clean current and legacy docs build directories, and Python virtual environment - -`docs-html` -: Build HTML - -`docs-linkcheck` -: Run linkcheck - -`docs-linkcheckbroken` -: Run linkcheck and show only broken links +Build the documentation locally to test the rendering. -`docs-livehtml` -: Rebuild Sphinx documentation on changes, with live-reload in the browser - -`docs-vale` -: Run spell, grammar, and style checks +```shell +make docs-html +``` -`docs` -: Build Docs +Add and commit the generated files in `src/plone/restapi/tests/http-examples/`. -Make sure you add and commit the generated files in `http-examples`. ## Conventions @@ -76,18 +76,18 @@ conventions ## Code formatting and testing -To ensure consistent code formatting, we use [Black](https://black.readthedocs.io/en/stable/index.html). -All pull requests must pass code formatting checks. -We recommend that you run Black locally. -You can use the following command to automatically format the code. +All changes must pass code formatting and tests. +Run these checks locally before creating a pull request. + +Use the following command to automatically format the code with [Black](https://black.readthedocs.io/en/stable/index.html). ```shell make black ``` -To run tests locally and ensure your changes don't introduce any issues, use the following command. -This will execute the test suite and provide test feedback. +Use the following command to run tests. ```shell make test ``` + diff --git a/netlify.toml b/netlify.toml deleted file mode 100644 index 9d440d0eb..000000000 --- a/netlify.toml +++ /dev/null @@ -1,5 +0,0 @@ -[build.environment] - PYTHON_VERSION = "3.8" - -[build] - ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF ./docs/" diff --git a/news/1798.documentation b/news/1798.documentation new file mode 100644 index 000000000..b56db9553 --- /dev/null +++ b/news/1798.documentation @@ -0,0 +1 @@ +Update contributing docs for Plone 6, and switch from Netlify to Read the Docs for pull request previews. @stevepiercy diff --git a/plone-6.0.x-python3.8.cfg b/plone-6.0.x-python3.8.cfg new file mode 100644 index 000000000..9fca1a2f0 --- /dev/null +++ b/plone-6.0.x-python3.8.cfg @@ -0,0 +1,17 @@ +[buildout] +extends = + https://dist.plone.org/release/6.0.11.1/versions.cfg + base.cfg + +[instance] +recipe = plone.recipe.zope2instance +zodb-temporary-storage = off + +[versions] +pygments = 2.14.0 +plone.app.linkintegrity = 4.0.3 +robotframework-browser = 17.5.2 +robotframework-assertion-engine = 2.0.0 +robotframework-debuglibrary = 2.3.0 +robotframework-pythonlibcore = 4.2.0 +grpcio-tools = 1.59.0 diff --git a/plone-6.0.x.cfg b/plone-6.0.x.cfg index 5c418ddfe..5172c9dda 100644 --- a/plone-6.0.x.cfg +++ b/plone-6.0.x.cfg @@ -13,6 +13,8 @@ recipe = plone.recipe.zope2instance zodb-temporary-storage = off [versions] +# Override pin from Zope. https://github.com/zopefoundation/Zope/issues/1220 +docutils = 0.21.2 pygments = 2.14.0 plone.app.linkintegrity = 4.0.3 robotframework-browser = 17.5.2 diff --git a/plone-6.1.x.cfg b/plone-6.1.x.cfg index 2ac1f2b5a..54716fa95 100644 --- a/plone-6.1.x.cfg +++ b/plone-6.1.x.cfg @@ -12,4 +12,6 @@ parts = recipe = plone.recipe.zope2instance zodb-temporary-storage = off -[versions] \ No newline at end of file +[versions] +# Override pin from Zope. https://github.com/zopefoundation/Zope/issues/1220 +docutils = 0.21.2 From 37d02e7772b1b402ef74b8e55bc7ea4ad786d014 Mon Sep 17 00:00:00 2001 From: Jefferson Bledsoe Date: Mon, 26 Aug 2024 18:44:48 +0000 Subject: [PATCH 2/8] Include next/previous only if enabled (#1799) * Add failing test for next/ previous behaviour * Return empty dict if behaviour or toggle is disabled * Fix missing import in test * Remove bad part of test * Fix some git weirdness? * Fix implementation * changelog * skip tests that require DX site root in Plone 5.2 --------- Co-authored-by: David Glick --- news/1799.bugfix | 4 ++ plone-6.0.x-python3.8.cfg | 2 +- plone-6.0.x.cfg | 2 +- requirements-6.0.txt | 2 +- src/plone/restapi/serializer/nextprev.py | 28 +++----- .../tests/http-examples/collection.resp | 16 +---- .../http-examples/collection_fullobjects.resp | 48 ++------------ .../tests/http-examples/content_get.resp | 8 +-- .../http-examples/content_get_folder.resp | 8 +-- .../content_patch_representation.resp | 8 +-- .../tests/http-examples/content_post.resp | 8 +-- .../restapi/tests/http-examples/event.resp | 8 +-- .../restapi/tests/http-examples/file.resp | 8 +-- .../restapi/tests/http-examples/folder.resp | 8 +-- .../restapi/tests/http-examples/image.resp | 8 +-- .../restapi/tests/http-examples/link.resp | 8 +-- .../navroot_lang_content_get.resp | 8 +-- .../navroot_lang_folder_get.resp | 8 +-- .../restapi/tests/http-examples/newsitem.resp | 8 +-- .../http-examples/search_fullobjects.resp | 8 +-- .../site_get_expand_lang_folder.resp | 16 +---- .../site_get_expand_lang_folder_content.resp | 16 +---- .../translated_messages_types_folder.resp | 4 +- .../translations_expand_get.resp | 8 +-- .../translations_link_on_post.resp | 8 +-- .../translations_unexpanded_get.resp | 8 +-- .../workingcopy_baseline_get.resp | 8 +-- .../http-examples/workingcopy_wc_get.resp | 8 +-- .../tests/test_dxcontent_serializer.py | 66 +++++++++++++++++++ 29 files changed, 114 insertions(+), 234 deletions(-) create mode 100644 news/1799.bugfix diff --git a/news/1799.bugfix b/news/1799.bugfix new file mode 100644 index 000000000..171db7f10 --- /dev/null +++ b/news/1799.bugfix @@ -0,0 +1,4 @@ +Fixed Dexterity content serializer: +Return an empty object for `next_item` and `previous_item` +unless the parent has next/previous support enabled. +@JeffersonBledsoe, @davisagli diff --git a/plone-6.0.x-python3.8.cfg b/plone-6.0.x-python3.8.cfg index 9fca1a2f0..2bd12daf3 100644 --- a/plone-6.0.x-python3.8.cfg +++ b/plone-6.0.x-python3.8.cfg @@ -1,6 +1,6 @@ [buildout] extends = - https://dist.plone.org/release/6.0.11.1/versions.cfg + https://dist.plone.org/release/6.0.12/versions.cfg base.cfg [instance] diff --git a/plone-6.0.x.cfg b/plone-6.0.x.cfg index 5172c9dda..26373fac8 100644 --- a/plone-6.0.x.cfg +++ b/plone-6.0.x.cfg @@ -1,6 +1,6 @@ [buildout] extends = - https://dist.plone.org/release/6.0.11.1/versions.cfg + https://dist.plone.org/release/6.0.12/versions.cfg base.cfg [buildout:python37] diff --git a/requirements-6.0.txt b/requirements-6.0.txt index 2f870811b..b654a46a9 100644 --- a/requirements-6.0.txt +++ b/requirements-6.0.txt @@ -1 +1 @@ --r https://dist.plone.org/release/6.0.11.1/requirements.txt +-r https://dist.plone.org/release/6.0.12/requirements.txt diff --git a/src/plone/restapi/serializer/nextprev.py b/src/plone/restapi/serializer/nextprev.py index ffcd0e29f..6d11ef323 100644 --- a/src/plone/restapi/serializer/nextprev.py +++ b/src/plone/restapi/serializer/nextprev.py @@ -1,24 +1,9 @@ -from AccessControl import getSecurityManager from Acquisition import aq_inner from Acquisition import aq_parent -from plone.app.dexterity.behaviors.nextprevious import NextPreviousBase -from plone.registry.interfaces import IRegistry +from plone.app.dexterity.behaviors.nextprevious import ( + INextPreviousProvider, +) from plone.restapi.serializer.utils import get_portal_type_title -from zope.component import getUtility - - -class NextPreviousFixed(NextPreviousBase): - """ - Based on plone.app.dexterity.behaviors.nextprevious.NextPreviousBase - but works for IPloneSite object - """ - - def __init__(self, context): - self.context = context - registry = getUtility(IRegistry) - self.vat = registry.get("plone.types_use_view_action_in_listings", []) - self.security = getSecurityManager() - self.order = self.context.objectIds() class NextPrevious: @@ -27,11 +12,14 @@ class NextPrevious: def __init__(self, context): self.context = context self.parent = aq_parent(aq_inner(context)) - self.nextprev = NextPreviousFixed(self.parent) + self.nextprev = INextPreviousProvider(self.parent, None) + self.enabled = self.nextprev is not None and self.nextprev.enabled @property def next(self): """return info about the next item in the container""" + if not self.enabled: + return {} if getattr(self.parent, "_ordering", "") == "unordered": # Unordered folder return {} @@ -49,6 +37,8 @@ def next(self): @property def previous(self): """return info about the previous item in the container""" + if not self.enabled: + return {} if getattr(self.parent, "_ordering", "") == "unordered": # Unordered folder return {} diff --git a/src/plone/restapi/tests/http-examples/collection.resp b/src/plone/restapi/tests/http-examples/collection.resp index 036a0bfd2..5a839d300 100644 --- a/src/plone/restapi/tests/http-examples/collection.resp +++ b/src/plone/restapi/tests/http-examples/collection.resp @@ -97,13 +97,7 @@ Content-Type: application/json "stealable": true }, "modified": "1995-07-31T17:30:00+00:00", - "next_item": { - "@id": "http://localhost:55001/plone/doc1", - "@type": "Document", - "description": "", - "title": "Document 1", - "type_title": "Page" - }, + "next_item": {}, "parent": { "@id": "http://localhost:55001/plone", "@type": "Plone Site", @@ -111,13 +105,7 @@ Content-Type: application/json "title": "Plone site", "type_title": "Plone Site" }, - "previous_item": { - "@id": "http://localhost:55001/plone/front-page", - "@type": "Document", - "description": "Congratulations! You have successfully installed Plone.", - "title": "Welcome to Plone", - "type_title": "Page" - }, + "previous_item": {}, "query": [ { "i": "portal_type", diff --git a/src/plone/restapi/tests/http-examples/collection_fullobjects.resp b/src/plone/restapi/tests/http-examples/collection_fullobjects.resp index 04b573bff..3836845d8 100644 --- a/src/plone/restapi/tests/http-examples/collection_fullobjects.resp +++ b/src/plone/restapi/tests/http-examples/collection_fullobjects.resp @@ -113,13 +113,7 @@ Content-Type: application/json "stealable": true }, "modified": "1995-07-31T17:30:00+00:00", - "next_item": { - "@id": "http://localhost:55001/plone/collection", - "@type": "Collection", - "description": "This is a collection with two documents", - "title": "My Collection", - "type_title": "Collection" - }, + "next_item": {}, "parent": { "@id": "http://localhost:55001/plone", "@type": "Plone Site", @@ -195,13 +189,7 @@ Content-Type: application/json "stealable": true }, "modified": "1995-07-31T17:30:00+00:00", - "next_item": { - "@id": "http://localhost:55001/plone/doc2", - "@type": "Document", - "description": "", - "title": "Document 2", - "type_title": "Page" - }, + "next_item": {}, "parent": { "@id": "http://localhost:55001/plone", "@type": "Plone Site", @@ -209,13 +197,7 @@ Content-Type: application/json "title": "Plone site", "type_title": "Plone Site" }, - "previous_item": { - "@id": "http://localhost:55001/plone/collection", - "@type": "Collection", - "description": "This is a collection with two documents", - "title": "My Collection", - "type_title": "Collection" - }, + "previous_item": {}, "relatedItems": [], "review_state": "private", "rights": "", @@ -287,13 +269,7 @@ Content-Type: application/json "title": "Plone site", "type_title": "Plone Site" }, - "previous_item": { - "@id": "http://localhost:55001/plone/doc1", - "@type": "Document", - "description": "", - "title": "Document 1", - "type_title": "Page" - }, + "previous_item": {}, "relatedItems": [], "review_state": "private", "rights": "", @@ -317,13 +293,7 @@ Content-Type: application/json "stealable": true }, "modified": "1995-07-31T17:30:00+00:00", - "next_item": { - "@id": "http://localhost:55001/plone/doc1", - "@type": "Document", - "description": "", - "title": "Document 1", - "type_title": "Page" - }, + "next_item": {}, "parent": { "@id": "http://localhost:55001/plone", "@type": "Plone Site", @@ -331,13 +301,7 @@ Content-Type: application/json "title": "Plone site", "type_title": "Plone Site" }, - "previous_item": { - "@id": "http://localhost:55001/plone/front-page", - "@type": "Document", - "description": "Congratulations! You have successfully installed Plone.", - "title": "Welcome to Plone", - "type_title": "Page" - }, + "previous_item": {}, "query": [ { "i": "portal_type", diff --git a/src/plone/restapi/tests/http-examples/content_get.resp b/src/plone/restapi/tests/http-examples/content_get.resp index 9d876dccf..ad574ee2f 100644 --- a/src/plone/restapi/tests/http-examples/content_get.resp +++ b/src/plone/restapi/tests/http-examples/content_get.resp @@ -60,13 +60,7 @@ Content-Type: application/json "title": "My Folder", "type_title": "Folder" }, - "previous_item": { - "@id": "http://localhost:55001/plone/folder/doc2", - "@type": "Document", - "description": "", - "title": "A document within a folder", - "type_title": "Page" - }, + "previous_item": {}, "relatedItems": [], "review_state": "private", "rights": "", diff --git a/src/plone/restapi/tests/http-examples/content_get_folder.resp b/src/plone/restapi/tests/http-examples/content_get_folder.resp index c7e9f35e7..7c2915f48 100644 --- a/src/plone/restapi/tests/http-examples/content_get_folder.resp +++ b/src/plone/restapi/tests/http-examples/content_get_folder.resp @@ -89,13 +89,7 @@ Content-Type: application/json "title": "Plone site", "type_title": "Plone Site" }, - "previous_item": { - "@id": "http://localhost:55001/plone/front-page", - "@type": "Document", - "description": "Congratulations! You have successfully installed Plone.", - "title": "Welcome to Plone", - "type_title": "Page" - }, + "previous_item": {}, "relatedItems": [], "review_state": "private", "rights": "", diff --git a/src/plone/restapi/tests/http-examples/content_patch_representation.resp b/src/plone/restapi/tests/http-examples/content_patch_representation.resp index 0003cae47..bbc788a94 100644 --- a/src/plone/restapi/tests/http-examples/content_patch_representation.resp +++ b/src/plone/restapi/tests/http-examples/content_patch_representation.resp @@ -60,13 +60,7 @@ Content-Type: application/json "title": "My Folder", "type_title": "Folder" }, - "previous_item": { - "@id": "http://localhost:55001/plone/folder/doc2", - "@type": "Document", - "description": "", - "title": "A document within a folder", - "type_title": "Page" - }, + "previous_item": {}, "relatedItems": [], "review_state": "private", "rights": "", diff --git a/src/plone/restapi/tests/http-examples/content_post.resp b/src/plone/restapi/tests/http-examples/content_post.resp index 9cd542a49..99c1f3c4b 100644 --- a/src/plone/restapi/tests/http-examples/content_post.resp +++ b/src/plone/restapi/tests/http-examples/content_post.resp @@ -61,13 +61,7 @@ Location: http://localhost:55001/plone/folder/my-document "title": "My Folder", "type_title": "Folder" }, - "previous_item": { - "@id": "http://localhost:55001/plone/folder/doc2", - "@type": "Document", - "description": "", - "title": "A document within a folder", - "type_title": "Page" - }, + "previous_item": {}, "relatedItems": [], "review_state": "private", "rights": "", diff --git a/src/plone/restapi/tests/http-examples/event.resp b/src/plone/restapi/tests/http-examples/event.resp index 2591e6180..7cf0051a3 100644 --- a/src/plone/restapi/tests/http-examples/event.resp +++ b/src/plone/restapi/tests/http-examples/event.resp @@ -67,13 +67,7 @@ Content-Type: application/json "title": "Plone site", "type_title": "Plone Site" }, - "previous_item": { - "@id": "http://localhost:55001/plone/front-page", - "@type": "Document", - "description": "Congratulations! You have successfully installed Plone.", - "title": "Welcome to Plone", - "type_title": "Page" - }, + "previous_item": {}, "recurrence": null, "relatedItems": [], "review_state": "private", diff --git a/src/plone/restapi/tests/http-examples/file.resp b/src/plone/restapi/tests/http-examples/file.resp index 4b463c60f..1f2f7ad12 100644 --- a/src/plone/restapi/tests/http-examples/file.resp +++ b/src/plone/restapi/tests/http-examples/file.resp @@ -61,13 +61,7 @@ Content-Type: application/json "title": "Plone site", "type_title": "Plone Site" }, - "previous_item": { - "@id": "http://localhost:55001/plone/front-page", - "@type": "Document", - "description": "Congratulations! You have successfully installed Plone.", - "title": "Welcome to Plone", - "type_title": "Page" - }, + "previous_item": {}, "relatedItems": [], "review_state": null, "rights": "", diff --git a/src/plone/restapi/tests/http-examples/folder.resp b/src/plone/restapi/tests/http-examples/folder.resp index 7a41f8227..ad3dd229b 100644 --- a/src/plone/restapi/tests/http-examples/folder.resp +++ b/src/plone/restapi/tests/http-examples/folder.resp @@ -75,13 +75,7 @@ Content-Type: application/json "title": "Plone site", "type_title": "Plone Site" }, - "previous_item": { - "@id": "http://localhost:55001/plone/front-page", - "@type": "Document", - "description": "Congratulations! You have successfully installed Plone.", - "title": "Welcome to Plone", - "type_title": "Page" - }, + "previous_item": {}, "relatedItems": [], "review_state": "private", "rights": "", diff --git a/src/plone/restapi/tests/http-examples/image.resp b/src/plone/restapi/tests/http-examples/image.resp index c2e13cbd1..e459b587c 100644 --- a/src/plone/restapi/tests/http-examples/image.resp +++ b/src/plone/restapi/tests/http-examples/image.resp @@ -120,13 +120,7 @@ Content-Type: application/json "title": "Plone site", "type_title": "Plone Site" }, - "previous_item": { - "@id": "http://localhost:55001/plone/front-page", - "@type": "Document", - "description": "Congratulations! You have successfully installed Plone.", - "title": "Welcome to Plone", - "type_title": "Page" - }, + "previous_item": {}, "relatedItems": [], "review_state": null, "rights": "", diff --git a/src/plone/restapi/tests/http-examples/link.resp b/src/plone/restapi/tests/http-examples/link.resp index 76d990359..64ac54490 100644 --- a/src/plone/restapi/tests/http-examples/link.resp +++ b/src/plone/restapi/tests/http-examples/link.resp @@ -56,13 +56,7 @@ Content-Type: application/json "title": "Plone site", "type_title": "Plone Site" }, - "previous_item": { - "@id": "http://localhost:55001/plone/front-page", - "@type": "Document", - "description": "Congratulations! You have successfully installed Plone.", - "title": "Welcome to Plone", - "type_title": "Page" - }, + "previous_item": {}, "remoteUrl": "http://localhost:55001/plone", "review_state": "private", "rights": "", diff --git a/src/plone/restapi/tests/http-examples/navroot_lang_content_get.resp b/src/plone/restapi/tests/http-examples/navroot_lang_content_get.resp index d537815af..cfbf9e1cf 100644 --- a/src/plone/restapi/tests/http-examples/navroot_lang_content_get.resp +++ b/src/plone/restapi/tests/http-examples/navroot_lang_content_get.resp @@ -74,13 +74,7 @@ Content-Type: application/json "layout": "folder_listing", "lock": {}, "modified": "1995-07-31T17:30:00+00:00", - "next_item": { - "@id": "http://localhost:55001/plone/de", - "@type": "LRF", - "description": "", - "title": "Deutsch", - "type_title": "Language Root Folder" - }, + "next_item": {}, "parent": { "@id": "http://localhost:55001/plone", "@type": "Plone Site", diff --git a/src/plone/restapi/tests/http-examples/navroot_lang_folder_get.resp b/src/plone/restapi/tests/http-examples/navroot_lang_folder_get.resp index 801625f6d..3932a805e 100644 --- a/src/plone/restapi/tests/http-examples/navroot_lang_folder_get.resp +++ b/src/plone/restapi/tests/http-examples/navroot_lang_folder_get.resp @@ -74,13 +74,7 @@ Content-Type: application/json "layout": "folder_listing", "lock": {}, "modified": "1995-07-31T17:30:00+00:00", - "next_item": { - "@id": "http://localhost:55001/plone/de", - "@type": "LRF", - "description": "", - "title": "Deutsch", - "type_title": "Language Root Folder" - }, + "next_item": {}, "parent": { "@id": "http://localhost:55001/plone", "@type": "Plone Site", diff --git a/src/plone/restapi/tests/http-examples/newsitem.resp b/src/plone/restapi/tests/http-examples/newsitem.resp index e1dab847d..cab5656ca 100644 --- a/src/plone/restapi/tests/http-examples/newsitem.resp +++ b/src/plone/restapi/tests/http-examples/newsitem.resp @@ -125,13 +125,7 @@ Content-Type: application/json "title": "Plone site", "type_title": "Plone Site" }, - "previous_item": { - "@id": "http://localhost:55001/plone/front-page", - "@type": "Document", - "description": "Congratulations! You have successfully installed Plone.", - "title": "Welcome to Plone", - "type_title": "Page" - }, + "previous_item": {}, "relatedItems": [], "review_state": "private", "rights": "", diff --git a/src/plone/restapi/tests/http-examples/search_fullobjects.resp b/src/plone/restapi/tests/http-examples/search_fullobjects.resp index 5c9fe7ebf..e74567105 100644 --- a/src/plone/restapi/tests/http-examples/search_fullobjects.resp +++ b/src/plone/restapi/tests/http-examples/search_fullobjects.resp @@ -62,13 +62,7 @@ Content-Type: application/json "title": "Plone site", "type_title": "Plone Site" }, - "previous_item": { - "@id": "http://localhost:55001/plone/front-page", - "@type": "Document", - "description": "Congratulations! You have successfully installed Plone.", - "title": "Welcome to Plone", - "type_title": "Page" - }, + "previous_item": {}, "relatedItems": [], "review_state": "private", "rights": "", diff --git a/src/plone/restapi/tests/http-examples/site_get_expand_lang_folder.resp b/src/plone/restapi/tests/http-examples/site_get_expand_lang_folder.resp index 4d636bc25..705960dde 100644 --- a/src/plone/restapi/tests/http-examples/site_get_expand_lang_folder.resp +++ b/src/plone/restapi/tests/http-examples/site_get_expand_lang_folder.resp @@ -91,13 +91,7 @@ Content-Type: application/json "layout": "folder_listing", "lock": {}, "modified": "1995-07-31T17:30:00+00:00", - "next_item": { - "@id": "http://localhost:55001/plone/de", - "@type": "LRF", - "description": "", - "title": "Deutsch", - "type_title": "Language Root Folder" - }, + "next_item": {}, "parent": { "@id": "http://localhost:55001/plone", "@type": "Plone Site", @@ -167,13 +161,7 @@ Content-Type: application/json "layout": "folder_listing", "lock": {}, "modified": "1995-07-31T17:30:00+00:00", - "next_item": { - "@id": "http://localhost:55001/plone/de", - "@type": "LRF", - "description": "", - "title": "Deutsch", - "type_title": "Language Root Folder" - }, + "next_item": {}, "parent": { "@id": "http://localhost:55001/plone", "@type": "Plone Site", diff --git a/src/plone/restapi/tests/http-examples/site_get_expand_lang_folder_content.resp b/src/plone/restapi/tests/http-examples/site_get_expand_lang_folder_content.resp index 9d4058231..443f2014b 100644 --- a/src/plone/restapi/tests/http-examples/site_get_expand_lang_folder_content.resp +++ b/src/plone/restapi/tests/http-examples/site_get_expand_lang_folder_content.resp @@ -91,13 +91,7 @@ Content-Type: application/json "layout": "folder_listing", "lock": {}, "modified": "1995-07-31T17:30:00+00:00", - "next_item": { - "@id": "http://localhost:55001/plone/de", - "@type": "LRF", - "description": "", - "title": "Deutsch", - "type_title": "Language Root Folder" - }, + "next_item": {}, "parent": { "@id": "http://localhost:55001/plone", "@type": "Plone Site", @@ -161,13 +155,7 @@ Content-Type: application/json "title": "English", "type_title": "Language Root Folder" }, - "previous_item": { - "@id": "http://localhost:55001/plone/en/assets", - "@type": "LIF", - "description": "", - "title": "Assets", - "type_title": "Language Independent Folder" - }, + "previous_item": {}, "relatedItems": [], "review_state": "private", "rights": "", diff --git a/src/plone/restapi/tests/http-examples/translated_messages_types_folder.resp b/src/plone/restapi/tests/http-examples/translated_messages_types_folder.resp index 3bdf1d009..ab0702c56 100644 --- a/src/plone/restapi/tests/http-examples/translated_messages_types_folder.resp +++ b/src/plone/restapi/tests/http-examples/translated_messages_types_folder.resp @@ -59,11 +59,11 @@ Content-Type: application/json+schema ], "layouts": [ "album_view", + "event_listing", "full_view", "listing_view", "summary_view", - "tabular_view", - "event_listing" + "tabular_view" ], "properties": { "allow_discussion": { diff --git a/src/plone/restapi/tests/http-examples/translations_expand_get.resp b/src/plone/restapi/tests/http-examples/translations_expand_get.resp index 010dce733..fc5e677b1 100644 --- a/src/plone/restapi/tests/http-examples/translations_expand_get.resp +++ b/src/plone/restapi/tests/http-examples/translations_expand_get.resp @@ -78,13 +78,7 @@ Content-Type: application/json "title": "English", "type_title": "Language Root Folder" }, - "previous_item": { - "@id": "http://localhost:55001/plone/en/assets", - "@type": "LIF", - "description": "", - "title": "Assets", - "type_title": "Language Independent Folder" - }, + "previous_item": {}, "relatedItems": [], "review_state": "private", "rights": "", diff --git a/src/plone/restapi/tests/http-examples/translations_link_on_post.resp b/src/plone/restapi/tests/http-examples/translations_link_on_post.resp index 798d35219..699d57edd 100644 --- a/src/plone/restapi/tests/http-examples/translations_link_on_post.resp +++ b/src/plone/restapi/tests/http-examples/translations_link_on_post.resp @@ -67,13 +67,7 @@ Location: http://localhost:55001/plone/de/mydocument "title": "Deutsch", "type_title": "Basisordner einer Sprache" }, - "previous_item": { - "@id": "http://localhost:55001/plone/de/assets", - "@type": "LIF", - "description": "", - "title": "Assets", - "type_title": "Sprachunabh\u00e4ngiger Ordner" - }, + "previous_item": {}, "relatedItems": [], "review_state": "private", "rights": "", diff --git a/src/plone/restapi/tests/http-examples/translations_unexpanded_get.resp b/src/plone/restapi/tests/http-examples/translations_unexpanded_get.resp index 7b0e67424..f266e4dc1 100644 --- a/src/plone/restapi/tests/http-examples/translations_unexpanded_get.resp +++ b/src/plone/restapi/tests/http-examples/translations_unexpanded_get.resp @@ -66,13 +66,7 @@ Content-Type: application/json "title": "English", "type_title": "Language Root Folder" }, - "previous_item": { - "@id": "http://localhost:55001/plone/en/assets", - "@type": "LIF", - "description": "", - "title": "Assets", - "type_title": "Language Independent Folder" - }, + "previous_item": {}, "relatedItems": [], "review_state": "private", "rights": "", diff --git a/src/plone/restapi/tests/http-examples/workingcopy_baseline_get.resp b/src/plone/restapi/tests/http-examples/workingcopy_baseline_get.resp index 32a97febf..aea5b625d 100644 --- a/src/plone/restapi/tests/http-examples/workingcopy_baseline_get.resp +++ b/src/plone/restapi/tests/http-examples/workingcopy_baseline_get.resp @@ -58,13 +58,7 @@ Content-Type: application/json "token": "0.12345678901234567-0.98765432109876543-00105A989226:1630609830.249" }, "modified": "1995-07-31T17:30:00+00:00", - "next_item": { - "@id": "http://localhost:55001/plone/copy_of_document", - "@type": "Document", - "description": "", - "title": "Test document", - "type_title": "Page" - }, + "next_item": {}, "parent": { "@id": "http://localhost:55001/plone", "@type": "Plone Site", diff --git a/src/plone/restapi/tests/http-examples/workingcopy_wc_get.resp b/src/plone/restapi/tests/http-examples/workingcopy_wc_get.resp index 08598e4e2..2db877143 100644 --- a/src/plone/restapi/tests/http-examples/workingcopy_wc_get.resp +++ b/src/plone/restapi/tests/http-examples/workingcopy_wc_get.resp @@ -58,13 +58,7 @@ Content-Type: application/json "title": "Plone site", "type_title": "Plone Site" }, - "previous_item": { - "@id": "http://localhost:55001/plone/document", - "@type": "Document", - "description": "", - "title": "Test document", - "type_title": "Page" - }, + "previous_item": {}, "relatedItems": [], "review_state": "private", "rights": "", diff --git a/src/plone/restapi/tests/test_dxcontent_serializer.py b/src/plone/restapi/tests/test_dxcontent_serializer.py index 18d41cb95..789cf865f 100644 --- a/src/plone/restapi/tests/test_dxcontent_serializer.py +++ b/src/plone/restapi/tests/test_dxcontent_serializer.py @@ -11,6 +11,8 @@ from plone.app.testing import TEST_USER_ID from plone.app.textfield.interfaces import ITransformer from plone.app.textfield.value import RichTextValue +from plone.dexterity.interfaces import IDexterityFTI +from plone.dexterity.schema import SCHEMA_CACHE from plone.namedfile.file import NamedFile from plone.registry.interfaces import IRegistry from plone.restapi.interfaces import IExpandableElement @@ -31,6 +33,9 @@ import json import unittest +HAS_PLONE_6 = getattr( + import_module("Products.CMFPlone.factory"), "PLONE60MARKER", False +) HAS_PLONE_61 = getattr( import_module("Products.CMFPlone.factory"), "PLONE61MARKER", False ) @@ -200,12 +205,42 @@ def test_get_is_folderish_in_folder(self): self.assertIn("is_folderish", obj) self.assertEqual(True, obj["is_folderish"]) + def test_enable_disable_nextprev(self): + folder = api.content.create( + container=self.portal, + type="Folder", + title="Folder with items", + description="This is a folder with some documents", + nextPreviousEnabled=False, + ) + api.content.create( + container=folder, + type="Document", + title="Item 1", + description="Previous item", + ) + doc = api.content.create( + container=folder, + type="Document", + title="Item 2", + description="Current item", + ) + api.content.create( + container=folder, type="Document", title="Item 2", description="Next item" + ) + + data = self.serialize(doc) + + self.assertEqual({}, data["previous_item"]) + self.assertEqual({}, data["next_item"]) + def test_nextprev_no_nextprev(self): folder = api.content.create( container=self.portal, type="Folder", title="Folder with items", description="This is a folder with some documents", + nextPreviousEnabled=True, ) doc = api.content.create( container=folder, @@ -223,6 +258,7 @@ def test_nextprev_has_prev(self): type="Folder", title="Folder with items", description="This is a folder with some documents", + nextPreviousEnabled=True, ) api.content.create( container=folder, @@ -255,6 +291,7 @@ def test_nextprev_has_next(self): type="Folder", title="Folder with items", description="This is a folder with some documents", + nextPreviousEnabled=True, ) doc = api.content.create( container=folder, @@ -284,6 +321,7 @@ def test_nextprev_has_nextprev(self): type="Folder", title="Folder with items", description="This is a folder with some documents", + nextPreviousEnabled=True, ) api.content.create( container=folder, @@ -327,7 +365,16 @@ def test_nextprev_root_no_nextprev(self): self.assertEqual({}, data["previous_item"]) self.assertEqual({}, data["next_item"]) + @unittest.skipUnless(HAS_PLONE_6, "Requires Dexterity-based site root") def test_nextprev_root_has_prev(self): + fti = queryUtility(IDexterityFTI, name="Plone Site") + behavior_list = [a for a in fti.behaviors] + behavior_list.append("plone.nextpreviousenabled") + fti.behaviors = tuple(behavior_list) + # Invalidating the cache is required for the FTI to be applied + # on the existing object + SCHEMA_CACHE.invalidate("Plone Site") + doc = api.content.create( container=self.portal, type="Document", @@ -347,7 +394,16 @@ def test_nextprev_root_has_prev(self): ) self.assertEqual({}, data["next_item"]) + @unittest.skipUnless(HAS_PLONE_6, "Requires Dexterity-based site root") def test_nextprev_root_has_next(self): + fti = queryUtility(IDexterityFTI, name="Plone Site") + behavior_list = [a for a in fti.behaviors] + behavior_list.append("plone.nextpreviousenabled") + fti.behaviors = tuple(behavior_list) + # Invalidating the cache is required for the FTI to be applied + # on the existing object + SCHEMA_CACHE.invalidate("Plone Site") + api.content.create( container=self.portal, type="Document", @@ -367,7 +423,16 @@ def test_nextprev_root_has_next(self): data["next_item"], ) + @unittest.skipUnless(HAS_PLONE_6, "Requires Dexterity-based site root") def test_nextprev_root_has_nextprev(self): + fti = queryUtility(IDexterityFTI, name="Plone Site") + behavior_list = [a for a in fti.behaviors] + behavior_list.append("plone.nextpreviousenabled") + fti.behaviors = tuple(behavior_list) + # Invalidating the cache is required for the FTI to be applied + # on the existing object + SCHEMA_CACHE.invalidate("Plone Site") + api.content.create( container=self.portal, type="Document", @@ -414,6 +479,7 @@ def test_nextprev_unordered_folder(self): type="Folder", title="Folder with items", description="This is a folder with some documents", + nextPreviousEnabled=True, ) folder.setOrdering("unordered") doc = api.content.create( From aec08ce8f9d787694142a76b16f3147fef5d628c Mon Sep 17 00:00:00 2001 From: Alessandro Ceglie Date: Wed, 4 Sep 2024 04:18:12 +0200 Subject: [PATCH 3/8] fix #1802 and #1803 (#1804) * fix #1802 and #1803 * changelog * accepted stevepiercy suggestion on changelog --- news/1802.bugfix | 1 + src/plone/restapi/pas/add_plugin.zpt | 2 +- src/plone/restapi/pas/config.zpt | 20 ++++++++++---------- 3 files changed, 12 insertions(+), 11 deletions(-) create mode 100644 news/1802.bugfix diff --git a/news/1802.bugfix b/news/1802.bugfix new file mode 100644 index 000000000..347ab28a2 --- /dev/null +++ b/news/1802.bugfix @@ -0,0 +1 @@ +Fixed implementation of the `jwt_auth` plugin. It now can be added, and its properties, `use_keyring` and `store_tokens`, can be updated. @sauzher diff --git a/src/plone/restapi/pas/add_plugin.zpt b/src/plone/restapi/pas/add_plugin.zpt index b7e8c3636..74ef44710 100644 --- a/src/plone/restapi/pas/add_plugin.zpt +++ b/src/plone/restapi/pas/add_plugin.zpt @@ -14,7 +14,7 @@
- +
diff --git a/src/plone/restapi/pas/config.zpt b/src/plone/restapi/pas/config.zpt index bfe372989..ecb3859a8 100644 --- a/src/plone/restapi/pas/config.zpt +++ b/src/plone/restapi/pas/config.zpt @@ -10,19 +10,19 @@
- After this, the token is invalid and the user must login again. Set to 0 for the token to remain valid indefinitely.
- +
- If enabled, tokens are signed with a secret from Plone's keyring. If you want tokens that remain valid indefinitely you should disable this. @@ -31,10 +31,10 @@
- By default tokens are not stored on the server and thus can't be invalidated. If enabled, tokens that don't expire can be invalidated. From 7b1f0f4c4bff5cba26cf7925e306cfa12fc2c3b3 Mon Sep 17 00:00:00 2001 From: Maurits van Rees Date: Wed, 4 Sep 2024 21:43:29 +0200 Subject: [PATCH 4/8] Explicitly globally disable comments in the tests that need it. (#1805) In Plone 6.1, when you actively activate plone.app.discussion, we may globally enable comments by default. This is when https://github.com/plone/plone.app.discussion/pull/244 gets merged. We already had eight or so tests that explicitly globally enable comments. Now we explicitly globally disable them in two others. Then the tests work in Plone 6.0 and 6.1. See two test failures here for the plone.app.discussion PR: https://jenkins.plone.org/job/pull-request-6.1-3.10/311/ --- news/244.tests | 2 ++ src/plone/restapi/tests/test_dxcontent_serializer.py | 6 ++++++ 2 files changed, 8 insertions(+) create mode 100644 news/244.tests diff --git a/news/244.tests b/news/244.tests new file mode 100644 index 000000000..0ee4acc1f --- /dev/null +++ b/news/244.tests @@ -0,0 +1,2 @@ +Explicitly globally disable comments in the tests that need it. +[maurits] \ No newline at end of file diff --git a/src/plone/restapi/tests/test_dxcontent_serializer.py b/src/plone/restapi/tests/test_dxcontent_serializer.py index 789cf865f..6fd514956 100644 --- a/src/plone/restapi/tests/test_dxcontent_serializer.py +++ b/src/plone/restapi/tests/test_dxcontent_serializer.py @@ -527,6 +527,9 @@ def test_allow_discussion_by_default(self): self.assertEqual(False, obj["allow_discussion"]) def test_allow_discussion_obj_instance_allows_but_not_global_enabled(self): + registry = queryUtility(IRegistry) + settings = registry.forInterface(IDiscussionSettings, check=False) + settings.globally_enabled = False self.portal.invokeFactory("Document", id="doc2") self.portal.doc2.allow_discussion = True serializer = getMultiAdapter((self.portal.doc2, self.request), ISerializeToJson) @@ -536,6 +539,9 @@ def test_allow_discussion_obj_instance_allows_but_not_global_enabled(self): self.assertEqual(False, obj["allow_discussion"]) def test_allow_discussion_fti_allows_not_global_enabled(self): + registry = queryUtility(IRegistry) + settings = registry.forInterface(IDiscussionSettings, check=False) + settings.globally_enabled = False self.portal.invokeFactory("Document", id="doc2") portal_types = getToolByName(self.portal, "portal_types") document_fti = getattr(portal_types, self.portal.doc2.portal_type) From d60ef2ac7a3d8b026106c7c76cbdca4eb79fcffd Mon Sep 17 00:00:00 2001 From: David Glick Date: Thu, 5 Sep 2024 10:23:25 -0700 Subject: [PATCH 5/8] fix extension for towncrier --- news/{244.tests => 244.internal} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename news/{244.tests => 244.internal} (100%) diff --git a/news/244.tests b/news/244.internal similarity index 100% rename from news/244.tests rename to news/244.internal From 4ea8bf8659527b7e40ec680b136694eb344277e3 Mon Sep 17 00:00:00 2001 From: David Glick Date: Thu, 5 Sep 2024 10:24:34 -0700 Subject: [PATCH 6/8] Preparing release 9.7.2 --- CHANGES.rst | 26 ++++++++++++++++++++++++++ news/1798.documentation | 1 - news/1799.bugfix | 4 ---- news/1802.bugfix | 1 - news/244.internal | 2 -- setup.py | 2 +- 6 files changed, 27 insertions(+), 9 deletions(-) delete mode 100644 news/1798.documentation delete mode 100644 news/1799.bugfix delete mode 100644 news/1802.bugfix delete mode 100644 news/244.internal diff --git a/CHANGES.rst b/CHANGES.rst index f049a42e0..7d5323edb 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -8,6 +8,32 @@ Changelog .. towncrier release notes start +9.7.2 (2024-09-05) +------------------ + +Bug fixes: + + +- Fixed Dexterity content serializer: + Return an empty object for `next_item` and `previous_item` + unless the parent has next/previous support enabled. + @JeffersonBledsoe, @davisagli (#1799) +- Fixed implementation of the `jwt_auth` plugin. It now can be added, and its properties, `use_keyring` and `store_tokens`, can be updated. @sauzher (#1802) + + +Internal: + + +- Explicitly globally disable comments in the tests that need it. + [maurits] (#244) + + +Documentation: + + +- Update contributing docs for Plone 6, and switch from Netlify to Read the Docs for pull request previews. @stevepiercy (#1798) + + 9.7.1 (2024-06-29) ------------------ diff --git a/news/1798.documentation b/news/1798.documentation deleted file mode 100644 index b56db9553..000000000 --- a/news/1798.documentation +++ /dev/null @@ -1 +0,0 @@ -Update contributing docs for Plone 6, and switch from Netlify to Read the Docs for pull request previews. @stevepiercy diff --git a/news/1799.bugfix b/news/1799.bugfix deleted file mode 100644 index 171db7f10..000000000 --- a/news/1799.bugfix +++ /dev/null @@ -1,4 +0,0 @@ -Fixed Dexterity content serializer: -Return an empty object for `next_item` and `previous_item` -unless the parent has next/previous support enabled. -@JeffersonBledsoe, @davisagli diff --git a/news/1802.bugfix b/news/1802.bugfix deleted file mode 100644 index 347ab28a2..000000000 --- a/news/1802.bugfix +++ /dev/null @@ -1 +0,0 @@ -Fixed implementation of the `jwt_auth` plugin. It now can be added, and its properties, `use_keyring` and `store_tokens`, can be updated. @sauzher diff --git a/news/244.internal b/news/244.internal deleted file mode 100644 index 0ee4acc1f..000000000 --- a/news/244.internal +++ /dev/null @@ -1,2 +0,0 @@ -Explicitly globally disable comments in the tests that need it. -[maurits] \ No newline at end of file diff --git a/setup.py b/setup.py index 50235c983..3befc7008 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ import sys -version = "9.7.2.dev0" +version = "9.7.2" if sys.version_info.major == 2: raise ValueError( From 5dd4bef6399dc954094f28e547f092a41259e409 Mon Sep 17 00:00:00 2001 From: David Glick Date: Thu, 5 Sep 2024 10:27:58 -0700 Subject: [PATCH 7/8] Back to development: 9.7.3 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 3befc7008..c9b76e910 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ import sys -version = "9.7.2" +version = "9.7.3.dev0" if sys.version_info.major == 2: raise ValueError( From 057c59a04d4cb2e5d51e83cdab41b7e921aaae88 Mon Sep 17 00:00:00 2001 From: Maurits van Rees Date: Thu, 12 Sep 2024 05:06:13 +0200 Subject: [PATCH 8/8] Fix error getting allow_discussion when p.a.discussion is not activated. (#1808) * Fix error getting allow_discussion value when p.a.discussion is not activated. This fixes an error in Plone 6.1 when the `plone.app.discussion` package is available but not activated in the Add-ons. Problem is that the `conversation_view` is only defined when the browser layer of `plone.app.discussion` is found. Sample error: ``` Traceback (innermost last): Module ZPublisher.WSGIPublisher, line 181, in transaction_pubevents Module ZPublisher.WSGIPublisher, line 391, in publish_module Module ZPublisher.WSGIPublisher, line 285, in publish Module ZPublisher.mapply, line 98, in mapply Module ZPublisher.WSGIPublisher, line 68, in call_object Module plone.rest.service, line 21, in __call__ Module plone.restapi.services, line 19, in render Module plone.restapi.services.content.get, line 16, in reply Module plone.restapi.serializer.dxcontent, line 179, in __call__ Module plone.restapi.serializer.dxcontent, line 142, in __call__ Module plone.restapi.serializer.dxcontent, line 48, in get_allow_discussion_value Module zope.component._api, line 113, in getMultiAdapter zope.interface.interfaces.ComponentLookupError: ((, ), , 'conversation_view') ``` * Fix tests: Plone Site now gets allow_discussion false instead of null. --- news/1808.bugfix | 2 ++ src/plone/restapi/serializer/dxcontent.py | 20 ++++++++++--------- .../tests/http-examples/jwt_logged_in.resp | 2 +- .../tests/http-examples/navroot_site_get.resp | 2 +- .../navroot_standard_site_content_get.resp | 2 +- ...t_standard_site_content_get_expansion.resp | 2 +- .../navroot_standard_site_get.resp | 2 +- .../navroot_standard_site_get_expansion.resp | 4 ++-- .../site_get_expand_navroot.resp | 4 ++-- .../restapi/tests/http-examples/siteroot.resp | 2 +- 10 files changed, 23 insertions(+), 19 deletions(-) create mode 100644 news/1808.bugfix diff --git a/news/1808.bugfix b/news/1808.bugfix new file mode 100644 index 000000000..7a8ab1df8 --- /dev/null +++ b/news/1808.bugfix @@ -0,0 +1,2 @@ +Fix error getting allow_discussion value when p.a.discussion is not activated. +[maurits] diff --git a/src/plone/restapi/serializer/dxcontent.py b/src/plone/restapi/serializer/dxcontent.py index 0154f1c91..1c546d091 100644 --- a/src/plone/restapi/serializer/dxcontent.py +++ b/src/plone/restapi/serializer/dxcontent.py @@ -23,6 +23,7 @@ from Products.CMFPlone.utils import base_hasattr from Products.CMFCore.interfaces import IContentish from zope.component import adapter +from zope.component import ComponentLookupError from zope.component import getMultiAdapter from zope.component import queryMultiAdapter from zope.component import queryUtility @@ -41,15 +42,16 @@ def get_allow_discussion_value(context, request, result): - # This test is to handle the plone.app.discussion not being installed situation - if "allow_discussion" in result: - # Check if the content item implements the IContentish interface - if IContentish.providedBy(context): - result["allow_discussion"] = getMultiAdapter( - (context, request), name="conversation_view" - ).enabled() - else: - result["allow_discussion"] = False + # This test is to handle the situation of plone.app.discussion not being installed + # or not being activated. + if "allow_discussion" in result and IContentish.providedBy(context): + try: + view = getMultiAdapter((context, request), name="conversation_view") + result["allow_discussion"] = view.enabled() + return + except ComponentLookupError: + pass + result["allow_discussion"] = False @implementer(ISerializeToJson) diff --git a/src/plone/restapi/tests/http-examples/jwt_logged_in.resp b/src/plone/restapi/tests/http-examples/jwt_logged_in.resp index 51b29477f..df8437977 100644 --- a/src/plone/restapi/tests/http-examples/jwt_logged_in.resp +++ b/src/plone/restapi/tests/http-examples/jwt_logged_in.resp @@ -31,7 +31,7 @@ Content-Type: application/json "@id": "http://localhost:55001/plone", "@type": "Plone Site", "UID": "55c25ebc220d400393574f37d648727c", - "allow_discussion": null, + "allow_discussion": false, "contributors": [], "creators": [ "admin" diff --git a/src/plone/restapi/tests/http-examples/navroot_site_get.resp b/src/plone/restapi/tests/http-examples/navroot_site_get.resp index 877325002..1f5d023ab 100644 --- a/src/plone/restapi/tests/http-examples/navroot_site_get.resp +++ b/src/plone/restapi/tests/http-examples/navroot_site_get.resp @@ -33,7 +33,7 @@ Content-Type: application/json "@id": "http://localhost:55001/plone", "@type": "Plone Site", "UID": "55c25ebc220d400393574f37d648727c", - "allow_discussion": null, + "allow_discussion": false, "contributors": [], "creators": [ "admin" diff --git a/src/plone/restapi/tests/http-examples/navroot_standard_site_content_get.resp b/src/plone/restapi/tests/http-examples/navroot_standard_site_content_get.resp index 0c374d538..300b31186 100644 --- a/src/plone/restapi/tests/http-examples/navroot_standard_site_content_get.resp +++ b/src/plone/restapi/tests/http-examples/navroot_standard_site_content_get.resp @@ -33,7 +33,7 @@ Content-Type: application/json "@id": "http://localhost:55001/plone", "@type": "Plone Site", "UID": "55c25ebc220d400393574f37d648727c", - "allow_discussion": null, + "allow_discussion": false, "contributors": [], "creators": [ "admin" diff --git a/src/plone/restapi/tests/http-examples/navroot_standard_site_content_get_expansion.resp b/src/plone/restapi/tests/http-examples/navroot_standard_site_content_get_expansion.resp index a421c0b00..ccaeb686d 100644 --- a/src/plone/restapi/tests/http-examples/navroot_standard_site_content_get_expansion.resp +++ b/src/plone/restapi/tests/http-examples/navroot_standard_site_content_get_expansion.resp @@ -50,7 +50,7 @@ Content-Type: application/json "@id": "http://localhost:55001/plone", "@type": "Plone Site", "UID": "55c25ebc220d400393574f37d648727c", - "allow_discussion": null, + "allow_discussion": false, "contributors": [], "creators": [ "admin" diff --git a/src/plone/restapi/tests/http-examples/navroot_standard_site_get.resp b/src/plone/restapi/tests/http-examples/navroot_standard_site_get.resp index 532ec7d6c..abc42909a 100644 --- a/src/plone/restapi/tests/http-examples/navroot_standard_site_get.resp +++ b/src/plone/restapi/tests/http-examples/navroot_standard_site_get.resp @@ -33,7 +33,7 @@ Content-Type: application/json "@id": "http://localhost:55001/plone", "@type": "Plone Site", "UID": "55c25ebc220d400393574f37d648727c", - "allow_discussion": null, + "allow_discussion": false, "contributors": [], "creators": [ "admin" diff --git a/src/plone/restapi/tests/http-examples/navroot_standard_site_get_expansion.resp b/src/plone/restapi/tests/http-examples/navroot_standard_site_get_expansion.resp index 0a33c7475..b3391b831 100644 --- a/src/plone/restapi/tests/http-examples/navroot_standard_site_get_expansion.resp +++ b/src/plone/restapi/tests/http-examples/navroot_standard_site_get_expansion.resp @@ -50,7 +50,7 @@ Content-Type: application/json "@id": "http://localhost:55001/plone", "@type": "Plone Site", "UID": "55c25ebc220d400393574f37d648727c", - "allow_discussion": null, + "allow_discussion": false, "contributors": [], "creators": [ "admin" @@ -101,7 +101,7 @@ Content-Type: application/json "@id": "http://localhost:55001/plone", "@type": "Plone Site", "UID": "55c25ebc220d400393574f37d648727c", - "allow_discussion": null, + "allow_discussion": false, "contributors": [], "creators": [ "admin" diff --git a/src/plone/restapi/tests/http-examples/site_get_expand_navroot.resp b/src/plone/restapi/tests/http-examples/site_get_expand_navroot.resp index 00a8775fa..d92a212bd 100644 --- a/src/plone/restapi/tests/http-examples/site_get_expand_navroot.resp +++ b/src/plone/restapi/tests/http-examples/site_get_expand_navroot.resp @@ -50,7 +50,7 @@ Content-Type: application/json "@id": "http://localhost:55001/plone", "@type": "Plone Site", "UID": "55c25ebc220d400393574f37d648727c", - "allow_discussion": null, + "allow_discussion": false, "contributors": [], "creators": [ "admin" @@ -125,7 +125,7 @@ Content-Type: application/json "@id": "http://localhost:55001/plone", "@type": "Plone Site", "UID": "55c25ebc220d400393574f37d648727c", - "allow_discussion": null, + "allow_discussion": false, "contributors": [], "creators": [ "admin" diff --git a/src/plone/restapi/tests/http-examples/siteroot.resp b/src/plone/restapi/tests/http-examples/siteroot.resp index 51b29477f..df8437977 100644 --- a/src/plone/restapi/tests/http-examples/siteroot.resp +++ b/src/plone/restapi/tests/http-examples/siteroot.resp @@ -31,7 +31,7 @@ Content-Type: application/json "@id": "http://localhost:55001/plone", "@type": "Plone Site", "UID": "55c25ebc220d400393574f37d648727c", - "allow_discussion": null, + "allow_discussion": false, "contributors": [], "creators": [ "admin"