Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mamico committed Jun 27, 2024
1 parent 35aa849 commit 29f75d1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 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 @@ -59,7 +59,7 @@ def reply(self):
(section, self.request),
ISerializeToJsonSummary,
)()
if setting.get("expandItems", True):
if section_settings.get("expandItems", True):
children = section.listFolderContents(
contentFilter={"portal_type": utils.getUserFriendlyTypes()}
)
Expand Down
7 changes: 5 additions & 2 deletions src/design/plone/policy/tests/test_search_filters_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,19 +132,22 @@ 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"][1]["items"]), 15)

# change expandItems to False for the first section
settings = json.loads(
api.portal.get_registry_record(
"search_sections", interface=IDesignPloneSettings
)
)
settings[0]["expandItems"] = False
settings[0]["items"][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()
# first item now has only 1 child
self.assertEqual(len(response["sections"][0]["items"][0]["items"]), 1)
# second item still has 15 children
self.assertEqual(len(response["sections"][0]["items"][1]["items"]), 15)

0 comments on commit 29f75d1

Please sign in to comment.