Products can not be handed out if order is not paid. Fix #284.
This commit is contained in:
parent
a5e67fcb8c
commit
512be60da5
|
@ -405,6 +405,7 @@ class Product(CreatedUpdatedModel, UUIDModel):
|
||||||
# If there is no stock defined the product is generally available.
|
# If there is no stock defined the product is generally available.
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
class OrderProductRelation(CreatedUpdatedModel):
|
class OrderProductRelation(CreatedUpdatedModel):
|
||||||
order = models.ForeignKey('shop.Order', on_delete=models.PROTECT)
|
order = models.ForeignKey('shop.Order', on_delete=models.PROTECT)
|
||||||
product = models.ForeignKey('shop.Product', on_delete=models.PROTECT)
|
product = models.ForeignKey('shop.Product', on_delete=models.PROTECT)
|
||||||
|
@ -415,6 +416,12 @@ class OrderProductRelation(CreatedUpdatedModel):
|
||||||
def total(self):
|
def total(self):
|
||||||
return Decimal(self.product.price * self.quantity)
|
return Decimal(self.product.price * self.quantity)
|
||||||
|
|
||||||
|
def clean(self):
|
||||||
|
if self.handed_out and not self.order.paid:
|
||||||
|
raise ValidationError(
|
||||||
|
'Product can not be handed out when order is not paid.'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class EpayCallback(CreatedUpdatedModel, UUIDModel):
|
class EpayCallback(CreatedUpdatedModel, UUIDModel):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
Loading…
Reference in a new issue