From 9a3b6dcbc3fb8983c09a9ed56497d8dbde27730d Mon Sep 17 00:00:00 2001 From: Santiago Lamora Date: Tue, 8 Jun 2021 10:23:04 +0200 Subject: [PATCH] Add 'exclude' attribute to TransactionSerializer Creating a ModelSerializer without either the 'fields' attribute or the 'exclude' attribute has been deprecated since 3.3.0 --- orchestra/contrib/payments/serializers.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/orchestra/contrib/payments/serializers.py b/orchestra/contrib/payments/serializers.py index e423abbb..93ae9f78 100644 --- a/orchestra/contrib/payments/serializers.py +++ b/orchestra/contrib/payments/serializers.py @@ -10,7 +10,7 @@ class PaymentSourceSerializer(AccountSerializerMixin, serializers.HyperlinkedMod class Meta: model = PaymentSource fields = ('url', 'id', 'method', 'data', 'is_active') - + def validate(self, data): """ validate data according to method """ data = super(PaymentSourceSerializer, self).validate(data) @@ -20,7 +20,7 @@ class PaymentSourceSerializer(AccountSerializerMixin, serializers.HyperlinkedMod if not serializer.is_valid(): raise serializers.ValidationError(serializer.errors) return data - + def transform_data(self, obj, value): if not obj: return {} @@ -29,7 +29,7 @@ class PaymentSourceSerializer(AccountSerializerMixin, serializers.HyperlinkedMod serializer_class = plugin().get_serializer() return serializer_class().to_native(obj.data) return obj.data - + # TODO def metadata(self): meta = super(PaymentSourceSerializer, self).metadata() @@ -43,3 +43,4 @@ class PaymentSourceSerializer(AccountSerializerMixin, serializers.HyperlinkedMod class TransactionSerializer(AccountSerializerMixin, serializers.HyperlinkedModelSerializer): class Meta: model = Transaction + exclude = ('process',)