Skip to content

Commit

Permalink
search_sections in IDesignPloneSettings has a new filed in each sec…
Browse files Browse the repository at this point in the history
…tion:

  `expandItems` that is a boolean to decide if the items of the section should
  be expanded or not (default is True).
  • Loading branch information
mamico committed Jun 27, 2024
1 parent e26eef2 commit 35aa849
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/design/plone/policy/restapi/search_filters/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def reply(self):
"search_sections", interface=IDesignPloneSettings, default="[]"
)
utils = getToolByName(self.context, "plone_utils")

sections = []
for setting in json.loads(settings or "[]"):
items = []
Expand Down
16 changes: 11 additions & 5 deletions src/design/plone/policy/tests/test_search_filters_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,20 @@ def test_endpoint_do_not_return_contents_that_are_not_searchable(self):
def test_not_expand_items(self):
# first section has 7 children
response = self.api_session.get("/@search-filters").json()
self.assertEqual(len(response['sections'][0]['items'][0]['items']), 7)
self.assertEqual(len(response["sections"][0]["items"][0]["items"]), 7)

# change expandItems to False for the first section
settings = json.loads(api.portal.get_registry_record("search_sections",interface=IDesignPloneSettings))
settings[0]['expandItems'] = False
api.portal.set_registry_record('search_sections', json.dumps(settings), interface=IDesignPloneSettings)
settings = json.loads(
api.portal.get_registry_record(
"search_sections", interface=IDesignPloneSettings
)
)
settings[0]["expandItems"] = False
api.portal.set_registry_record(
"search_sections", json.dumps(settings), interface=IDesignPloneSettings
)
commit()

# first section now has only 1 child
response = self.api_session.get("/@search-filters").json()
self.assertEqual(len(response['sections'][0]['items'][0]['items']), 1)
self.assertEqual(len(response["sections"][0]["items"][0]["items"]), 1)

0 comments on commit 35aa849

Please sign in to comment.