Skip to content

Commit

Permalink
Merge branch 'master' into correct_fix_links_behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
luca-bellenghi committed Oct 11, 2023
2 parents d9fbe81 + f0f0771 commit 6270eb7
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
7 changes: 5 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@ Changelog
site, even when requesting replacement with a link from a different
website.
[lucabel].
- plone.app.redirector.FourOhFourView.search_for_similar patch to enable conditionally
the search for similar
[folix-01]


5.2.4 (2023-09-26)
------------------

- Fix the issue in the @translation GET endpoint: If this
endpoint is invoked, possibly by a bot, and plone.app.multilingual
is not installed, the call will result in an empty search query
endpoint is invoked, possibly by a bot, and plone.app.multilingual
is not installed, the call will result in an empty search query
on the catalog.
[lucabel]

Expand Down
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,12 @@ For details see the `pull-request <https://github.com/RedTurtle/redturtle.volto/

This patch is not enabled by default. You need to set an environment variable to `true`: *PROXY_BEARER_AUTH*.

Conditionally search for similar if nonexistent site path passed
----------------------------------------------------------------

plone.app.redirector.FourOhFourView.search_for_similar method patched to return an empty list if
the `REDTURTLE_VOLTO_ENABLE_SEARCH_FOR_SIMILAR` environment variable is set.

New Criteria
============

Expand Down
15 changes: 15 additions & 0 deletions src/redturtle/volto/monkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from zope.globalrequest import getRequest

import datetime
import os


def occurrences(self, range_start=None, range_end=None):
Expand Down Expand Up @@ -144,3 +145,17 @@ def plone_restapi_pam_translations_get(self, expand=False):
if not IPloneAppMultilingualInstalled.providedBy(self.request):
return {"translations": {"@id": f"{self.context.absolute_url()}/@translations"}}
return self._old___call__(expand=expand)


def search_for_similar(*args, **kwargs):
"""plone.app.redirector.browser.FourOhFourView.search_for_similar patch"""

original_obj = args and args[0] or None

if (
os.environ.get("REDTURTLE_VOLTO_ENABLE_SEARCH_FOR_SIMILAR", default=None)
and original_obj # noqa
):
return original_obj._old_search_for_similar()

return []
7 changes: 7 additions & 0 deletions src/redturtle/volto/monkey.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,12 @@
description="Fix long request in case pam is not installed"
preserveOriginal="True"
/>
<monkey:patch
original="search_for_similar"
replacement=".monkey.search_for_similar"
class="plone.app.redirector.browser.FourOhFourView"
description="Cancel the seach_for_similiar call when usin volto frontend"
preserveOriginal="True"
/>

</configure>

0 comments on commit 6270eb7

Please sign in to comment.