kopia lustrzana https://dev.funkwhale.audio/funkwhale/funkwhale
Fix #1145: Support ordering=random for artists, albums, tracks and channels endpoints
rodzic
0ebd7c610d
commit
e6344338f9
|
@ -35,6 +35,7 @@ class ChannelFilter(moderation_filters.HiddenContentFilterSet):
|
|||
fields=(
|
||||
("creation_date", "creation_date"),
|
||||
("artist__modification_date", "modification_date"),
|
||||
("?", "random"),
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from django.db.models import Q
|
||||
|
||||
import django_filters
|
||||
from django_filters import rest_framework as filters
|
||||
|
||||
from funkwhale_api.audio import filters as audio_filters
|
||||
|
@ -80,6 +81,15 @@ class ArtistFilter(
|
|||
scope = common_filters.ActorScopeFilter(
|
||||
actor_field="tracks__uploads__library__actor", distinct=True
|
||||
)
|
||||
ordering = django_filters.OrderingFilter(
|
||||
fields=(
|
||||
("id", "id"),
|
||||
("name", "name"),
|
||||
("creation_date", "creation_date"),
|
||||
("modification_date", "modification_date"),
|
||||
("?", "random"),
|
||||
)
|
||||
)
|
||||
|
||||
class Meta:
|
||||
model = models.Artist
|
||||
|
@ -118,6 +128,21 @@ class TrackFilter(
|
|||
field_name="_", method="filter_artist", queryset=models.Artist.objects.all()
|
||||
)
|
||||
|
||||
ordering = django_filters.OrderingFilter(
|
||||
fields=(
|
||||
("creation_date", "creation_date"),
|
||||
("title", "title"),
|
||||
("album__title", "album__title"),
|
||||
("album__release_date", "album__release_date"),
|
||||
("size", "size"),
|
||||
("position", "position"),
|
||||
("disc_number", "disc_number"),
|
||||
("artist__name", "artist__name"),
|
||||
("artist__modification_date", "artist__modification_date"),
|
||||
("?", "random"),
|
||||
)
|
||||
)
|
||||
|
||||
class Meta:
|
||||
model = models.Track
|
||||
fields = {
|
||||
|
@ -207,6 +232,16 @@ class AlbumFilter(
|
|||
actor_field="tracks__uploads__library__actor", distinct=True
|
||||
)
|
||||
|
||||
ordering = django_filters.OrderingFilter(
|
||||
fields=(
|
||||
("creation_date", "creation_date"),
|
||||
("release_date", "release_date"),
|
||||
("title", "title"),
|
||||
("artist__modification_date", "artist__modification_date"),
|
||||
("?", "random"),
|
||||
)
|
||||
)
|
||||
|
||||
class Meta:
|
||||
model = models.Album
|
||||
fields = ["playable", "q", "artist", "scope", "mbid"]
|
||||
|
|
|
@ -130,7 +130,6 @@ class ArtistViewSet(
|
|||
required_scope = "libraries"
|
||||
anonymous_policy = "setting"
|
||||
filterset_class = filters.ArtistFilter
|
||||
ordering_fields = ("id", "name", "creation_date", "modification_date")
|
||||
|
||||
fetches = federation_decorators.fetches_route()
|
||||
mutations = common_decorators.mutations_route(types=["update"])
|
||||
|
@ -187,12 +186,6 @@ class AlbumViewSet(
|
|||
permission_classes = [oauth_permissions.ScopePermission]
|
||||
required_scope = "libraries"
|
||||
anonymous_policy = "setting"
|
||||
ordering_fields = (
|
||||
"creation_date",
|
||||
"release_date",
|
||||
"title",
|
||||
"artist__modification_date",
|
||||
)
|
||||
filterset_class = filters.AlbumFilter
|
||||
|
||||
fetches = federation_decorators.fetches_route()
|
||||
|
@ -345,17 +338,6 @@ class TrackViewSet(
|
|||
required_scope = "libraries"
|
||||
anonymous_policy = "setting"
|
||||
filterset_class = filters.TrackFilter
|
||||
ordering_fields = (
|
||||
"creation_date",
|
||||
"title",
|
||||
"album__title",
|
||||
"album__release_date",
|
||||
"size",
|
||||
"position",
|
||||
"disc_number",
|
||||
"artist__name",
|
||||
"artist__modification_date",
|
||||
)
|
||||
fetches = federation_decorators.fetches_route()
|
||||
mutations = common_decorators.mutations_route(types=["update"])
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue