mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-04 13:09:16 +02:00
Attribute artist
This commit is contained in:
parent
8687a64873
commit
4e44e4e4b6
31 changed files with 1741 additions and 46 deletions
|
@ -2,7 +2,7 @@ import persisting_theory
|
|||
|
||||
from rest_framework import serializers
|
||||
|
||||
from django.db import models
|
||||
from django.db import models, transaction
|
||||
|
||||
|
||||
class ConfNotFound(KeyError):
|
||||
|
@ -23,6 +23,7 @@ class Registry(persisting_theory.Registry):
|
|||
|
||||
return decorator
|
||||
|
||||
@transaction.atomic
|
||||
def apply(self, type, obj, payload):
|
||||
conf = self.get_conf(type, obj)
|
||||
serializer = conf["serializer_class"](obj, data=payload)
|
||||
|
@ -73,6 +74,9 @@ class MutationSerializer(serializers.Serializer):
|
|||
def apply(self, obj, validated_data):
|
||||
raise NotImplementedError()
|
||||
|
||||
def post_apply(self, obj, validated_data):
|
||||
pass
|
||||
|
||||
def get_previous_state(self, obj, validated_data):
|
||||
return
|
||||
|
||||
|
@ -88,8 +92,11 @@ class UpdateMutationSerializer(serializers.ModelSerializer, MutationSerializer):
|
|||
kwargs.setdefault("partial", True)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
@transaction.atomic
|
||||
def apply(self, obj, validated_data):
|
||||
return self.update(obj, validated_data)
|
||||
r = self.update(obj, validated_data)
|
||||
self.post_apply(r, validated_data)
|
||||
return r
|
||||
|
||||
def validate(self, validated_data):
|
||||
if not validated_data:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue