✨(backend) allow forcing page size within limits
We want to be able to increase the page size with by passing the query string parameter "page_size".
This commit is contained in:
committed by
Manuel Raynaud
parent
757d7f35cd
commit
fcf8b38021
@@ -32,6 +32,7 @@ and this project adheres to
|
|||||||
|
|
||||||
## Added
|
## Added
|
||||||
|
|
||||||
|
- ✨(backend) allow forcing page size within limits
|
||||||
- 💄(frontend) add error pages #643
|
- 💄(frontend) add error pages #643
|
||||||
- 🔒️ Manage unsafe attachments #663
|
- 🔒️ Manage unsafe attachments #663
|
||||||
- ✨(frontend) Custom block quote with export #646
|
- ✨(frontend) Custom block quote with export #646
|
||||||
|
|||||||
@@ -418,6 +418,7 @@ class DocumentViewSet(
|
|||||||
metadata_class = DocumentMetadata
|
metadata_class = DocumentMetadata
|
||||||
ordering = ["-updated_at"]
|
ordering = ["-updated_at"]
|
||||||
ordering_fields = ["created_at", "updated_at", "title"]
|
ordering_fields = ["created_at", "updated_at", "title"]
|
||||||
|
pagination_class = Pagination
|
||||||
permission_classes = [
|
permission_classes = [
|
||||||
permissions.DocumentAccessPermission,
|
permissions.DocumentAccessPermission,
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -328,6 +328,35 @@ def test_api_documents_list_pagination(
|
|||||||
assert document_ids == []
|
assert document_ids == []
|
||||||
|
|
||||||
|
|
||||||
|
def test_api_documents_list_pagination_force_page_size():
|
||||||
|
"""Page size can be set via querystring."""
|
||||||
|
user = factories.UserFactory()
|
||||||
|
|
||||||
|
client = APIClient()
|
||||||
|
client.force_login(user)
|
||||||
|
|
||||||
|
document_ids = [
|
||||||
|
str(access.document_id)
|
||||||
|
for access in factories.UserDocumentAccessFactory.create_batch(3, user=user)
|
||||||
|
]
|
||||||
|
|
||||||
|
# Force page size
|
||||||
|
response = client.get(
|
||||||
|
"/api/v1.0/documents/?page_size=2",
|
||||||
|
)
|
||||||
|
|
||||||
|
assert response.status_code == 200
|
||||||
|
content = response.json()
|
||||||
|
|
||||||
|
assert content["count"] == 3
|
||||||
|
assert content["next"] == "http://testserver/api/v1.0/documents/?page=2&page_size=2"
|
||||||
|
assert content["previous"] is None
|
||||||
|
|
||||||
|
assert len(content["results"]) == 2
|
||||||
|
for item in content["results"]:
|
||||||
|
document_ids.remove(item["id"])
|
||||||
|
|
||||||
|
|
||||||
def test_api_documents_list_authenticated_distinct():
|
def test_api_documents_list_authenticated_distinct():
|
||||||
"""A document with several related users should only be listed once."""
|
"""A document with several related users should only be listed once."""
|
||||||
user = factories.UserFactory()
|
user = factories.UserFactory()
|
||||||
|
|||||||
Reference in New Issue
Block a user