🔥(teams) remove pagination of teams listing
For frontend pagination is useless for teams, so we remove it.
This commit is contained in:
committed by
Nathan Panchout
parent
a42e7a10db
commit
7d695ab81c
@@ -8,14 +8,15 @@ and this project adheres to
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
### Added
|
|
||||||
|
|
||||||
- ✨(teams) register contacts on admin views
|
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
- 🔥(teams) remove pagination of teams listing
|
||||||
- 🔥(teams) remove search users by trigram
|
- 🔥(teams) remove search users by trigram
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- ✨(teams) register contacts on admin views
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- 💚(ci) improve E2E tests #492
|
- 💚(ci) improve E2E tests #492
|
||||||
|
|||||||
@@ -246,6 +246,7 @@ class TeamViewSet(
|
|||||||
ordering_fields = ["created_at"]
|
ordering_fields = ["created_at"]
|
||||||
ordering = ["-created_at"]
|
ordering = ["-created_at"]
|
||||||
queryset = models.Team.objects.all()
|
queryset = models.Team.objects.all()
|
||||||
|
pagination_class = None
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
"""Custom queryset to get user related teams."""
|
"""Custom queryset to get user related teams."""
|
||||||
|
|||||||
@@ -47,60 +47,13 @@ def test_api_teams_list_authenticated():
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert response.status_code == HTTP_200_OK
|
assert response.status_code == HTTP_200_OK
|
||||||
results = response.json()["results"]
|
results = response.json()
|
||||||
|
|
||||||
assert len(results) == 5
|
assert len(results) == 5
|
||||||
results_id = {result["id"] for result in results}
|
results_id = {result["id"] for result in results}
|
||||||
assert expected_ids == results_id
|
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():
|
def test_api_teams_list_authenticated_distinct():
|
||||||
"""A team with several related users should only be listed once."""
|
"""A team with several related users should only be listed once."""
|
||||||
user = factories.UserFactory()
|
user = factories.UserFactory()
|
||||||
@@ -118,8 +71,8 @@ def test_api_teams_list_authenticated_distinct():
|
|||||||
|
|
||||||
assert response.status_code == HTTP_200_OK
|
assert response.status_code == HTTP_200_OK
|
||||||
content = response.json()
|
content = response.json()
|
||||||
assert len(content["results"]) == 1
|
assert len(content) == 1
|
||||||
assert content["results"][0]["id"] == str(team.id)
|
assert content[0]["id"] == str(team.id)
|
||||||
|
|
||||||
|
|
||||||
def test_api_teams_order():
|
def test_api_teams_order():
|
||||||
@@ -142,7 +95,7 @@ def test_api_teams_order():
|
|||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
|
|
||||||
response_data = response.json()
|
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()
|
team_ids.reverse()
|
||||||
assert (
|
assert (
|
||||||
@@ -171,7 +124,7 @@ def test_api_teams_order_param():
|
|||||||
|
|
||||||
response_data = response.json()
|
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 (
|
assert (
|
||||||
response_team_ids == team_ids
|
response_team_ids == team_ids
|
||||||
|
|||||||
Reference in New Issue
Block a user