kopia lustrzana https://dev.funkwhale.audio/funkwhale/funkwhale
See #432: added /action endpoint to manage tags in batch
rodzic
13f36beec3
commit
aaced60ec1
|
@ -592,3 +592,13 @@ class ManageTagSerializer(ManageBaseAlbumSerializer):
|
||||||
|
|
||||||
def get_artists_count(self, obj):
|
def get_artists_count(self, obj):
|
||||||
return getattr(obj, "_artists_count", None)
|
return getattr(obj, "_artists_count", None)
|
||||||
|
|
||||||
|
|
||||||
|
class ManageTagActionSerializer(common_serializers.ActionSerializer):
|
||||||
|
actions = [common_serializers.Action("delete", allow_all=False)]
|
||||||
|
filterset_class = filters.ManageTagFilterSet
|
||||||
|
pk_field = "name"
|
||||||
|
|
||||||
|
@transaction.atomic
|
||||||
|
def handle_delete(self, objects):
|
||||||
|
return objects.delete()
|
||||||
|
|
|
@ -493,3 +493,13 @@ class ManageTagViewSet(
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
|
@rest_decorators.action(methods=["post"], detail=False)
|
||||||
|
def action(self, request, *args, **kwargs):
|
||||||
|
queryset = self.get_queryset()
|
||||||
|
serializer = serializers.ManageTagActionSerializer(
|
||||||
|
request.data, queryset=queryset
|
||||||
|
)
|
||||||
|
serializer.is_valid(raise_exception=True)
|
||||||
|
result = serializer.save()
|
||||||
|
return response.Response(result, status=200)
|
||||||
|
|
|
@ -487,6 +487,7 @@ def test_manage_upload_serializer(factories, now):
|
||||||
("music.Artist", serializers.ManageArtistActionSerializer),
|
("music.Artist", serializers.ManageArtistActionSerializer),
|
||||||
("music.Library", serializers.ManageLibraryActionSerializer),
|
("music.Library", serializers.ManageLibraryActionSerializer),
|
||||||
("music.Upload", serializers.ManageUploadActionSerializer),
|
("music.Upload", serializers.ManageUploadActionSerializer),
|
||||||
|
("tags.Tag", serializers.ManageTagActionSerializer),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_action_serializer_delete(factory, serializer_class, factories):
|
def test_action_serializer_delete(factory, serializer_class, factories):
|
||||||
|
|
Ładowanie…
Reference in New Issue