Features: 1) Add setter method for personal_orders_only in core.models.py;
Fixes: 1) Correct exception handling by replacing `self.download.RelatedObjectDoesNotExist` with `DigitalAssetDownload.RelatedObjectDoesNotExist`; Extra: None;
This commit is contained in:
parent
40c86c7eef
commit
90d077fefd
1 changed files with 5 additions and 1 deletions
|
|
@ -601,6 +601,10 @@ class Product(ExportModelOperationsMixin("product"), NiceModel): # type: ignore
|
|||
def personal_orders_only(self) -> bool:
|
||||
return not (self.quantity > 0 and self.price > 0.0)
|
||||
|
||||
@personal_orders_only.setter
|
||||
def personal_orders_only(self, value):
|
||||
self.__dict__["personal_orders_only"] = value
|
||||
|
||||
|
||||
class Attribute(ExportModelOperationsMixin("attribute"), NiceModel): # type: ignore [misc, django-manager-missing]
|
||||
__doc__ = _(
|
||||
|
|
@ -1782,7 +1786,7 @@ class OrderProduct(ExportModelOperationsMixin("order_product"), NiceModel): # t
|
|||
if self.product.is_digital and self.product.stocks.first().digital_asset: # type: ignore [union-attr]
|
||||
try:
|
||||
return self.download.url
|
||||
except self.download.RelatedObjectDoesNotExist:
|
||||
except DigitalAssetDownload.RelatedObjectDoesNotExist:
|
||||
return DigitalAssetDownload.objects.create(order_product=self).url
|
||||
return ""
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue