diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 7b483d1ad..1cf76fa04 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -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) diff --git a/guillotina/api/search.py b/guillotina/api/search.py index 0ca38f019..5ba94fd30 100644 --- a/guillotina/api/search.py +++ b/guillotina/api/search.py @@ -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", diff --git a/guillotina/catalog/catalog.py b/guillotina/catalog/catalog.py index a84597bf7..d86f104f3 100644 --- a/guillotina/catalog/catalog.py +++ b/guillotina/catalog/catalog.py @@ -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""" diff --git a/guillotina/interfaces/catalog.py b/guillotina/interfaces/catalog.py index 3638dfa46..90c5a55fd 100644 --- a/guillotina/interfaces/catalog.py +++ b/guillotina/interfaces/catalog.py @@ -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""" diff --git a/guillotina/tests/test_catalog.py b/guillotina/tests/test_catalog.py index abcea7712..456aeb327 100644 --- a/guillotina/tests/test_catalog.py +++ b/guillotina/tests/test_catalog.py @@ -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