See #432: added /action endpoint to manage tags in batch

environments/review-docs-rate-jr6phc/deployments/2479
Eliot Berriot 2019-07-25 10:17:31 +02:00
rodzic 13f36beec3
commit aaced60ec1
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: DD6965E2476E5C27
3 zmienionych plików z 21 dodań i 0 usunięć

Wyświetl plik

@ -592,3 +592,13 @@ class ManageTagSerializer(ManageBaseAlbumSerializer):
def get_artists_count(self, obj):
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()

Wyświetl plik

@ -493,3 +493,13 @@ class ManageTagViewSet(
),
)
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)

Wyświetl plik

@ -487,6 +487,7 @@ def test_manage_upload_serializer(factories, now):
("music.Artist", serializers.ManageArtistActionSerializer),
("music.Library", serializers.ManageLibraryActionSerializer),
("music.Upload", serializers.ManageUploadActionSerializer),
("tags.Tag", serializers.ManageTagActionSerializer),
],
)
def test_action_serializer_delete(factory, serializer_class, factories):