BillingAddress: make mget_preferred_address a classmethod
This commit is contained in:
parent
736fe27493
commit
4097c2ce13
1 changed files with 4 additions and 4 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue