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:
Egor Pavlovich Gorbunov 2025-10-03 17:16:52 +03:00
parent 40c86c7eef
commit 90d077fefd

View file

@ -601,6 +601,10 @@ class Product(ExportModelOperationsMixin("product"), NiceModel): # type: ignore
def personal_orders_only(self) -> bool: def personal_orders_only(self) -> bool:
return not (self.quantity > 0 and self.price > 0.0) 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] class Attribute(ExportModelOperationsMixin("attribute"), NiceModel): # type: ignore [misc, django-manager-missing]
__doc__ = _( __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] if self.product.is_digital and self.product.stocks.first().digital_asset: # type: ignore [union-attr]
try: try:
return self.download.url return self.download.url
except self.download.RelatedObjectDoesNotExist: except DigitalAssetDownload.RelatedObjectDoesNotExist:
return DigitalAssetDownload.objects.create(order_product=self).url return DigitalAssetDownload.objects.create(order_product=self).url
return "" return ""