🚚(global) move favorite documents API endpoint to /documents/favorites/

To respect the globally used pattern, we can safely switch to a simpler
path
This commit is contained in:
Julien Maupetit
2026-09-14 10:01:36 +00:00
committed by GitHub
parent bd4d54983a
commit 31cff890b8
5 changed files with 12 additions and 9 deletions
+2
View File
@@ -16,6 +16,8 @@ and this project adheres to
- ⬆️(backend) upgrade celery to version 5.6.3
- ⚡️(backend) stop using LEFT(value, LENGTH(path)) in sql queries
- 🚚(project) switch docspec image to ghcr.io/docspec/api #2553
- 🚚(global) move favorite documents API endpoint
to `/documents/favorites/` #2540
### Fixed
+2 -1
View File
@@ -486,7 +486,7 @@ class DocumentViewSet(
8. **Favorite**: Get list of favorite documents for a user. Mark or unmark
a document as favorite.
Examples:
- GET /documents/favorite_list/
- GET /documents/favorites/
- POST, DELETE /documents/{id}/favorite/
9. **Create for Owner**: Create a document via server-to-server on behalf of a user.
@@ -843,6 +843,7 @@ class DocumentViewSet(
detail=False,
methods=["get"],
permission_classes=[permissions.IsAuthenticated],
url_path="favorites",
)
def favorite_list(self, request, *args, **kwargs):
"""Get list of favorite documents for the current user."""
@@ -16,7 +16,7 @@ def test_api_document_favorite_list_anonymous():
"""Anonymous users should receive a 401 error."""
client = APIClient()
response = client.get("/api/v1.0/documents/favorite_list/")
response = client.get("/api/v1.0/documents/favorites/")
assert response.status_code == 401
@@ -27,7 +27,7 @@ def test_api_document_favorite_list_authenticated_no_favorite():
client = APIClient()
client.force_login(user)
response = client.get("/api/v1.0/documents/favorite_list/")
response = client.get("/api/v1.0/documents/favorites/")
assert response.status_code == 200
assert response.json() == {
@@ -53,7 +53,7 @@ def test_api_document_favorite_list_authenticated_with_favorite():
user=user, role=models.RoleChoices.READER, document__favorited_by=[user]
).document
response = client.get("/api/v1.0/documents/favorite_list/")
response = client.get("/api/v1.0/documents/favorites/")
assert response.status_code == 200
assert response.json() == {
@@ -107,7 +107,7 @@ def test_api_document_favorite_list_with_favorite_children():
other_root = factories.DocumentFactory(creator=user, users=[user])
factories.DocumentFactory.create_batch(2, parent=other_root)
response = client.get("/api/v1.0/documents/favorite_list/")
response = client.get("/api/v1.0/documents/favorites/")
assert response.status_code == 200
assert response.json()["count"] == 3
@@ -149,7 +149,7 @@ def test_api_document_favorite_list_sorted_by_updated_at():
updated_at=now + timedelta(seconds=3)
)
response = client.get("/api/v1.0/documents/favorite_list/")
response = client.get("/api/v1.0/documents/favorites/")
assert response.status_code == 200
assert response.json()["count"] == 3
@@ -176,7 +176,7 @@ def test_api_document_favorite_list_with_deleted_child():
child1.delete()
response = client.get("/api/v1.0/documents/favorite_list/")
response = client.get("/api/v1.0/documents/favorites/")
assert response.status_code == 200
assert response.json()["count"] == 2
@@ -35,7 +35,7 @@ def test_external_api_documents_favorites_list_allowed(
document__favorited_by=[user_specific_sub],
).document
response = client.get("/external_api/v1.0/documents/favorite_list/")
response = client.get("/external_api/v1.0/documents/favorites/")
assert response.status_code == 200
data = response.json()
@@ -29,7 +29,7 @@ export const getDocsFavorite = async (
searchParams.set('ordering', params.ordering);
}
const response = await fetchAPI(
`documents/favorite_list/?${searchParams.toString()}`,
`documents/favorites/?${searchParams.toString()}`,
);
if (!response.ok) {