mirror of
https://github.com/suitenumerique/docs.git
synced 2026-09-13 21:27:53 +02:00
🚚(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:
@@ -18,6 +18,7 @@ and this project adheres to
|
||||
### Changed
|
||||
|
||||
- ♿️(frontend) use semantic `<dl>` structure in document info card #2379
|
||||
- 🚚(global) move favorite documents API endpoint to `/documents/favorites/`
|
||||
|
||||
## [v5.4.1] - 2026-07-09
|
||||
|
||||
|
||||
@@ -484,7 +484,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.
|
||||
@@ -836,6 +836,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()
|
||||
|
||||
@@ -26,7 +26,7 @@ export const getDocsFavorite = async (
|
||||
}
|
||||
|
||||
const response = await fetchAPI(
|
||||
`documents/favorite_list/?${searchParams.toString()}`,
|
||||
`documents/favorites/?${searchParams.toString()}`,
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
|
||||
Reference in New Issue
Block a user