Added actions and tasks to purge domains and actors
This commit is contained in:
parent
833daa242c
commit
233ac870be
10 changed files with 251 additions and 14 deletions
14
api/funkwhale_api/common/decorators.py
Normal file
14
api/funkwhale_api/common/decorators.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
from rest_framework import response
|
||||
from rest_framework.decorators import list_route
|
||||
|
||||
|
||||
def action_route(serializer_class):
|
||||
@list_route(methods=["post"])
|
||||
def action(self, request, *args, **kwargs):
|
||||
queryset = self.get_queryset()
|
||||
serializer = serializer_class(request.data, queryset=queryset)
|
||||
serializer.is_valid(raise_exception=True)
|
||||
result = serializer.save()
|
||||
return response.Response(result, status=200)
|
||||
|
||||
return action
|
||||
|
|
@ -123,7 +123,7 @@ class ActionSerializer(serializers.Serializer):
|
|||
if type(value) in [list, tuple]:
|
||||
return self.queryset.filter(
|
||||
**{"{}__in".format(self.pk_field): value}
|
||||
).order_by("id")
|
||||
).order_by(self.pk_field)
|
||||
|
||||
raise serializers.ValidationError(
|
||||
"{} is not a valid value for objects. You must provide either a "
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue