Skip to content
Snippets Groups Projects
Commit 58be852a authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Merge branch '302-private-playlist-show-in-interface' into 'develop'

Resolve "Private playlists not shown in interface"

Closes #302

See merge request funkwhale/funkwhale!275
parents e093ff1c c371fe36
No related branches found
No related tags found
No related merge requests found
...@@ -17,13 +17,13 @@ def get_privacy_field(): ...@@ -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: if user.is_anonymous:
return models.Q(**{lookup_field: "everyone"}) return models.Q(**{lookup_field: "everyone"})
return models.Q( 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): class SearchFilter(django_filters.CharFilter):
......
...@@ -110,7 +110,9 @@ class PlaylistTrackViewSet( ...@@ -110,7 +110,9 @@ class PlaylistTrackViewSet(
def get_queryset(self): def get_queryset(self):
return self.queryset.filter( return self.queryset.filter(
fields.privacy_level_query( 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 ...@@ -12,7 +12,8 @@ from funkwhale_api.users.factories import UserFactory
(AnonymousUser(), Q(privacy_level="everyone")), (AnonymousUser(), Q(privacy_level="everyone")),
( (
UserFactory.build(pk=1), 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)
...@@ -71,6 +71,9 @@ export default { ...@@ -71,6 +71,9 @@ export default {
if (relativeUrl.startsWith('http')) { if (relativeUrl.startsWith('http')) {
return relativeUrl return relativeUrl
} }
if (state.instanceUrl.endsWith('/') && relativeUrl.startsWith('/')) {
relativeUrl = relativeUrl.slice(1)
}
return state.instanceUrl + relativeUrl return state.instanceUrl + relativeUrl
} }
}, },
......
...@@ -93,7 +93,7 @@ export default { ...@@ -93,7 +93,7 @@ export default {
let url = 'playlists/' + this.id + '/' let url = 'playlists/' + this.id + '/'
axios.get(url).then((response) => { axios.get(url).then((response) => {
self.playlist = response.data self.playlist = response.data
axios.get(url + 'tracks').then((response) => { axios.get(url + 'tracks/').then((response) => {
self.updatePlts(response.data.results) self.updatePlts(response.data.results)
}).then(() => { }).then(() => {
self.isLoading = false self.isLoading = false
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment