Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Changelog
5.5.10 (2025-05-09)
-------------------

- Fix Searches with "not" in a KeywordIndex do not return records that do not contain a value for the index
[mamico]
- Fix issue with event search in @querystring-search override:
converting a timezone-aware DateTime to utcdatetime causes a problem when searching for
"today", as it shifts start=day x at 00:00 to start=day x-1 at 22:00 in GMT+2 timezone.
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools>=42"]
build-backend = "setuptools.build_meta"
22 changes: 17 additions & 5 deletions src/redturtle/volto/monkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,22 @@ def search_for_similar(*args, **kwargs):

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()
if os.environ.get("REDTURTLE_VOLTO_ENABLE_SEARCH_FOR_SIMILAR"):
if original_obj:
return original_obj._old_search_for_similar()

return []


def _get_object_keywords(self, obj, attr):
"""Products.PluginIndexes.KeywordIndex.KeywordIndex.KeywordIndex._get_object_keywords patch

See: https://github.com/zopefoundation/Products.ZCatalog/issues/148
https://github.com/zopefoundation/Products.ZCatalog/pull/158
"""
# indexes that we want to use with not queries
keywords = self._old__get_object_keywords(obj, attr)
if attr in ("Subject",):
if not keywords and hasattr(obj, attr):
return ("__empty__",)
return keywords
10 changes: 9 additions & 1 deletion src/redturtle/volto/monkey.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,15 @@
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"
description="Cancel the search_for_similiar call when using volto frontend"
preserveOriginal="True"
/>

<monkey:patch
original="_get_object_keywords"
replacement=".monkey._get_object_keywords"
class="Products.PluginIndexes.KeywordIndex.KeywordIndex.KeywordIndex"
description="Manage empty keywords for not queries"
preserveOriginal="True"
/>

Expand Down
16 changes: 10 additions & 6 deletions src/redturtle/volto/tests/test_vocabulary_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,11 @@ def test_anonymous_can_get_allowed_vocabularies(self):
response = api_session.get("/@vocabularies/plone.app.vocabularies.Keywords")

self.assertEqual(response.status_code, 200)
self.assertEqual(response.json()["items_total"], 2)
self.assertEqual(response.json()["items"][0]["title"], "bar")
self.assertEqual(response.json()["items"][1]["title"], "foo")
self.assertEqual(response.json()["items_total"], 3)
# we patch the catalog to deal with not operator so we have the "empty" sjb keyword
self.assertEqual(response.json()["items"][0]["title"], "__empty__")
self.assertEqual(response.json()["items"][1]["title"], "bar")
self.assertEqual(response.json()["items"][2]["title"], "foo")

api_session.close()

Expand All @@ -103,9 +105,11 @@ def test_authenticated_can_get_allowed_vocabularies(self):
api_session.auth = (username, "secret!!!")
response = api_session.get("/@vocabularies/plone.app.vocabularies.Keywords")
self.assertEqual(response.status_code, 200)
self.assertEqual(response.json()["items_total"], 2)
self.assertEqual(response.json()["items"][0]["title"], "bar")
self.assertEqual(response.json()["items"][1]["title"], "foo")
self.assertEqual(response.json()["items_total"], 3)
# we patch the catalog to deal with not operator so we have the "empty" sjb keyword
self.assertEqual(response.json()["items"][0]["title"], "__empty__")
self.assertEqual(response.json()["items"][1]["title"], "bar")
self.assertEqual(response.json()["items"][2]["title"], "foo")

api_session.close()

Expand Down
1 change: 1 addition & 0 deletions test_plone60.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
extends =
https://raw.github.com/collective/buildout.plonetest/master/test-6.0.x.cfg
https://raw.githubusercontent.com/collective/buildout.plonetest/master/qa.cfg
https://raw.githubusercontent.com/RedTurtle/iocomune-backend/main/versions.cfg
base.cfg

[versions]
Expand Down