Add 'exclude' attribute to TransactionSerializer

Creating a ModelSerializer without either the 'fields' attribute or the
'exclude' attribute has been deprecated since 3.3.0
This commit is contained in:
Santiago L 2021-06-08 10:23:04 +02:00
parent 5e7a823205
commit 9a3b6dcbc3
1 changed files with 4 additions and 3 deletions

View File

@ -10,7 +10,7 @@ class PaymentSourceSerializer(AccountSerializerMixin, serializers.HyperlinkedMod
class Meta: class Meta:
model = PaymentSource model = PaymentSource
fields = ('url', 'id', 'method', 'data', 'is_active') fields = ('url', 'id', 'method', 'data', 'is_active')
def validate(self, data): def validate(self, data):
""" validate data according to method """ """ validate data according to method """
data = super(PaymentSourceSerializer, self).validate(data) data = super(PaymentSourceSerializer, self).validate(data)
@ -20,7 +20,7 @@ class PaymentSourceSerializer(AccountSerializerMixin, serializers.HyperlinkedMod
if not serializer.is_valid(): if not serializer.is_valid():
raise serializers.ValidationError(serializer.errors) raise serializers.ValidationError(serializer.errors)
return data return data
def transform_data(self, obj, value): def transform_data(self, obj, value):
if not obj: if not obj:
return {} return {}
@ -29,7 +29,7 @@ class PaymentSourceSerializer(AccountSerializerMixin, serializers.HyperlinkedMod
serializer_class = plugin().get_serializer() serializer_class = plugin().get_serializer()
return serializer_class().to_native(obj.data) return serializer_class().to_native(obj.data)
return obj.data return obj.data
# TODO # TODO
def metadata(self): def metadata(self):
meta = super(PaymentSourceSerializer, self).metadata() meta = super(PaymentSourceSerializer, self).metadata()
@ -43,3 +43,4 @@ class PaymentSourceSerializer(AccountSerializerMixin, serializers.HyperlinkedMod
class TransactionSerializer(AccountSerializerMixin, serializers.HyperlinkedModelSerializer): class TransactionSerializer(AccountSerializerMixin, serializers.HyperlinkedModelSerializer):
class Meta: class Meta:
model = Transaction model = Transaction
exclude = ('process',)