fix: show private/draft maps in team maps for members (#2373)

This commit is contained in:
Yohan Boniface 2024-12-17 18:16:55 +01:00 committed by GitHub
commit 1be00ed8ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 4 deletions

View file

@ -15,9 +15,12 @@ def test_can_see_team_maps(client, map, team):
assert map.name in response.content.decode()
def test_others_cannot_see_team_private_maps_in_team_page(client, map, team, user):
@pytest.mark.parametrize("share_status", [Map.PRIVATE, Map.DRAFT])
def test_others_cannot_see_team_private_maps_in_team_page(
client, map, team, user, share_status
):
map.team = team
map.share_status = Map.PRIVATE
map.share_status = share_status
map.save()
url = reverse("team_maps", args=(team.pk,))
response = client.get(url)
@ -43,7 +46,7 @@ def test_members_can_see_private_maps_in_team_page(
client.login(username=user.username, password="123123")
response = client.get(url)
assert response.status_code == 200
assert map.name not in response.content.decode()
assert map.name in response.content.decode()
def test_user_can_see_their_teams(client, team, user):

View file

@ -317,7 +317,11 @@ class TeamMaps(PaginatorMixin, DetailView):
context_object_name = "current_team"
def get_maps(self):
return Map.public.filter(team=self.object).order_by("-modified_at")
qs = Map.public
user = self.request.user
if user.is_authenticated and user in self.object.users.all():
qs = Map.objects
return qs.filter(team=self.object).order_by("-modified_at")
def get_context_data(self, **kwargs):
kwargs.update(