🔥(teams) remove pagination of teams listing

For frontend pagination is useless for teams,
so we remove it.
This commit is contained in:
Sabrina Demagny
2024-10-29 10:51:13 +01:00
committed by Nathan Panchout
parent a42e7a10db
commit 7d695ab81c
3 changed files with 12 additions and 57 deletions

View File

@@ -8,14 +8,15 @@ and this project adheres to
## [Unreleased]
### Added
- ✨(teams) register contacts on admin views
### Changed
- 🔥(teams) remove pagination of teams listing
- 🔥(teams) remove search users by trigram
### Added
- ✨(teams) register contacts on admin views
### Fixed
- 💚(ci) improve E2E tests #492

View File

@@ -246,6 +246,7 @@ class TeamViewSet(
ordering_fields = ["created_at"]
ordering = ["-created_at"]
queryset = models.Team.objects.all()
pagination_class = None
def get_queryset(self):
"""Custom queryset to get user related teams."""

View File

@@ -47,60 +47,13 @@ def test_api_teams_list_authenticated():
)
assert response.status_code == HTTP_200_OK
results = response.json()["results"]
results = response.json()
assert len(results) == 5
results_id = {result["id"] for result in results}
assert expected_ids == results_id
@mock.patch.object(PageNumberPagination, "get_page_size", return_value=2)
def test_api_teams_list_pagination(
_mock_page_size,
):
"""Pagination should work as expected."""
user = factories.UserFactory()
client = APIClient()
client.force_login(user)
team_ids = [
str(access.team.id)
for access in factories.TeamAccessFactory.create_batch(3, user=user)
]
# Get page 1
response = client.get(
"/api/v1.0/teams/",
)
assert response.status_code == HTTP_200_OK
content = response.json()
assert content["count"] == 3
assert content["next"] == "http://testserver/api/v1.0/teams/?page=2"
assert content["previous"] is None
assert len(content["results"]) == 2
for item in content["results"]:
team_ids.remove(item["id"])
# Get page 2
response = client.get(
"/api/v1.0/teams/?page=2",
)
assert response.status_code == HTTP_200_OK
content = response.json()
assert content["count"] == 3
assert content["next"] is None
assert content["previous"] == "http://testserver/api/v1.0/teams/"
assert len(content["results"]) == 1
team_ids.remove(content["results"][0]["id"])
assert team_ids == []
def test_api_teams_list_authenticated_distinct():
"""A team with several related users should only be listed once."""
user = factories.UserFactory()
@@ -118,8 +71,8 @@ def test_api_teams_list_authenticated_distinct():
assert response.status_code == HTTP_200_OK
content = response.json()
assert len(content["results"]) == 1
assert content["results"][0]["id"] == str(team.id)
assert len(content) == 1
assert content[0]["id"] == str(team.id)
def test_api_teams_order():
@@ -142,7 +95,7 @@ def test_api_teams_order():
assert response.status_code == 200
response_data = response.json()
response_team_ids = [team["id"] for team in response_data["results"]]
response_team_ids = [team["id"] for team in response_data]
team_ids.reverse()
assert (
@@ -171,7 +124,7 @@ def test_api_teams_order_param():
response_data = response.json()
response_team_ids = [team["id"] for team in response_data["results"]]
response_team_ids = [team["id"] for team in response_data]
assert (
response_team_ids == team_ids