Resolve "Hide an artist in the UI"
This commit is contained in:
parent
d4d4e60e39
commit
bdf83bd8ff
50 changed files with 1051 additions and 49 deletions
|
|
@ -13,6 +13,7 @@ import funkwhale_api
|
|||
from funkwhale_api.activity import record
|
||||
from funkwhale_api.common import fields, preferences, utils as common_utils
|
||||
from funkwhale_api.favorites.models import TrackFavorite
|
||||
from funkwhale_api.moderation import filters as moderation_filters
|
||||
from funkwhale_api.music import models as music_models
|
||||
from funkwhale_api.music import utils
|
||||
from funkwhale_api.music import views as music_views
|
||||
|
|
@ -152,8 +153,14 @@ class SubsonicViewSet(viewsets.GenericViewSet):
|
|||
url_path="getArtists",
|
||||
)
|
||||
def get_artists(self, request, *args, **kwargs):
|
||||
artists = music_models.Artist.objects.all().playable_by(
|
||||
utils.get_actor_from_request(request)
|
||||
artists = (
|
||||
music_models.Artist.objects.all()
|
||||
.exclude(
|
||||
moderation_filters.get_filtered_content_query(
|
||||
moderation_filters.USER_FILTER_CONFIG["ARTIST"], request.user
|
||||
)
|
||||
)
|
||||
.playable_by(utils.get_actor_from_request(request))
|
||||
)
|
||||
data = serializers.GetArtistsSerializer(artists).data
|
||||
payload = {"artists": data}
|
||||
|
|
@ -167,8 +174,14 @@ class SubsonicViewSet(viewsets.GenericViewSet):
|
|||
url_path="getIndexes",
|
||||
)
|
||||
def get_indexes(self, request, *args, **kwargs):
|
||||
artists = music_models.Artist.objects.all().playable_by(
|
||||
utils.get_actor_from_request(request)
|
||||
artists = (
|
||||
music_models.Artist.objects.all()
|
||||
.exclude(
|
||||
moderation_filters.get_filtered_content_query(
|
||||
moderation_filters.USER_FILTER_CONFIG["ARTIST"], request.user
|
||||
)
|
||||
)
|
||||
.playable_by(utils.get_actor_from_request(request))
|
||||
)
|
||||
data = serializers.GetArtistsSerializer(artists).data
|
||||
payload = {"indexes": data}
|
||||
|
|
@ -273,7 +286,11 @@ class SubsonicViewSet(viewsets.GenericViewSet):
|
|||
def get_random_songs(self, request, *args, **kwargs):
|
||||
data = request.GET or request.POST
|
||||
actor = utils.get_actor_from_request(request)
|
||||
queryset = music_models.Track.objects.all()
|
||||
queryset = music_models.Track.objects.all().exclude(
|
||||
moderation_filters.get_filtered_content_query(
|
||||
moderation_filters.USER_FILTER_CONFIG["TRACK"], request.user
|
||||
)
|
||||
)
|
||||
queryset = queryset.playable_by(actor)
|
||||
try:
|
||||
size = int(data["size"])
|
||||
|
|
@ -308,8 +325,14 @@ class SubsonicViewSet(viewsets.GenericViewSet):
|
|||
url_path="getAlbumList2",
|
||||
)
|
||||
def get_album_list2(self, request, *args, **kwargs):
|
||||
queryset = music_models.Album.objects.with_tracks_count().order_by(
|
||||
"artist__name"
|
||||
queryset = (
|
||||
music_models.Album.objects.exclude(
|
||||
moderation_filters.get_filtered_content_query(
|
||||
moderation_filters.USER_FILTER_CONFIG["ALBUM"], request.user
|
||||
)
|
||||
)
|
||||
.with_tracks_count()
|
||||
.order_by("artist__name")
|
||||
)
|
||||
data = request.GET or request.POST
|
||||
filterset = filters.AlbumList2FilterSet(data, queryset=queryset)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue