From 4097c2ce13bfe862a5312ff9952ae625a33c05b2 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 2 May 2020 21:20:14 +0200 Subject: [PATCH] BillingAddress: make mget_preferred_address a classmethod --- uncloud_django_based/uncloud/uncloud_pay/models.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/uncloud_django_based/uncloud/uncloud_pay/models.py b/uncloud_django_based/uncloud/uncloud_pay/models.py index b06473e..3b4535c 100644 --- a/uncloud_django_based/uncloud/uncloud_pay/models.py +++ b/uncloud_django_based/uncloud/uncloud_pay/models.py @@ -455,9 +455,9 @@ class BillingAddress(models.Model): def get_addresses_for(user): return BillingAddress.objects.filter(owner=user) - @staticmethod - def get_preferred_address_for(user): - addresses = get_addresses_for(user) + @classmethod + def get_preferred_address_for(cls, user): + addresses = cls.get_addresses_for(user) if len(addresses) == 0: return None else: @@ -927,7 +927,7 @@ class Product(UncloudModel): billing_address = BillingAddress.get_preferred_address_for(self.owner) if not billing_address: - raise ValidationError("Cannot create order without a billing address") + raise ValidationError("Cannot order without a billing address") self.order = Order(owner=self.owner, billing_address=billing_address)