Commit 697ea24b authored by Eliot Berriot's avatar Eliot Berriot 💬

Fix #302: Include user's current private playlists on playlist list

parent e068f4c1
......@@ -17,13 +17,13 @@ def get_privacy_field():
)
def privacy_level_query(user, lookup_field="privacy_level"):
def privacy_level_query(user, lookup_field="privacy_level", user_field="user"):
if user.is_anonymous:
return models.Q(**{lookup_field: "everyone"})
return models.Q(
**{"{}__in".format(lookup_field): ["followers", "instance", "everyone"]}
)
**{"{}__in".format(lookup_field): ["instance", "everyone"]}
) | models.Q(**{lookup_field: "me", user_field: user})
class SearchFilter(django_filters.CharFilter):
......
......@@ -110,7 +110,9 @@ class PlaylistTrackViewSet(
def get_queryset(self):
return self.queryset.filter(
fields.privacy_level_query(
self.request.user, lookup_field="playlist__privacy_level"
self.request.user,
lookup_field="playlist__privacy_level",
user_field="playlist__user",
)
)
......
......@@ -12,7 +12,8 @@ from funkwhale_api.users.factories import UserFactory
(AnonymousUser(), Q(privacy_level="everyone")),
(
UserFactory.build(pk=1),
Q(privacy_level__in=["followers", "instance", "everyone"]),
Q(privacy_level__in=["instance", "everyone"])
| Q(privacy_level="me", user=UserFactory.build(pk=1)),
),
],
)
......
Include user's current private playlists on playlist list (#302)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment