Skip to content
Open
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
6 changes: 5 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ CHANGELOG
- Fix path__starts. Add a slash when parsing the path of the query if
the context of the search is not the container, to avoid getting the
results of contexts that starts with the same path.
[nbacardit26]
[nilbacardit26]
- Adding render_options when registering a user.
[nilbacardit26]
- Adding @update-catalog endpoint and update_catalog init in catalog
and interfaces
[nilbacardit26]


6.4.2 (2022-08-25)
Expand Down
17 changes: 17 additions & 0 deletions guillotina/api/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,23 @@ async def catalog_post(context, request):
return {}


@configure.service(
context=IResource,
method="POST",
permission="guillotina.ManageCatalog",
name="@update-catalog",
summary="Update catalog",
responses={"200": {"description": "Successfully updated catalog"}},
)
async def update_catalog(context, request):
search = query_utility(ICatalogUtility)
data = await request.json() or {}
if search is None:
raise HTTPServiceUnavailable()
await search.update_catalog(context, data)
return {}


@configure.service(
context=IResource,
method="DELETE",
Expand Down
3 changes: 3 additions & 0 deletions guillotina/catalog/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ async def reindex_all_content(self, context: IBaseObject, security=False):
async def initialize_catalog(self, container: IContainer):
"""Creates an index"""

async def update_catalog(self, container: IContainer, datas):
"""Updates an index"""

async def remove_catalog(self, container: IContainer):
"""Deletes an index"""

Expand Down
3 changes: 3 additions & 0 deletions guillotina/interfaces/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ async def reindex_all_content(context: IBaseObject, security=False):
async def initialize_catalog(container: IContainer):
"""Creates an index"""

async def update_catalog(container: IContainer, datas):
"""Updates an index"""

async def remove_catalog(container: IContainer):
"""Deletes an index"""

Expand Down
2 changes: 2 additions & 0 deletions guillotina/tests/test_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,8 @@ async def test_create_catalog(container_requester):
async with container_requester as requester:
response, status = await requester("POST", "/db/guillotina/@catalog", data="{}")
assert status == 200
response, status = await requester("POST", "/db/guillotina/@update-catalog", data="{}")
assert status == 200
response, status = await requester("DELETE", "/db/guillotina/@catalog")
assert status == 200

Expand Down