Fixes: 1) Handle missing DigitalAssetDownload instance in download_url method with explicit conditional logic;
Extra: 1) Simplify exception handling by replacing it with clear branch logic.
This commit is contained in:
parent
90d077fefd
commit
9ad79f0c5e
1 changed files with 2 additions and 2 deletions
|
|
@ -1784,9 +1784,9 @@ class OrderProduct(ExportModelOperationsMixin("order_product"), NiceModel): # t
|
|||
def download_url(self: Self) -> str:
|
||||
if self.product and self.product.stocks:
|
||||
if self.product.is_digital and self.product.stocks.first().digital_asset: # type: ignore [union-attr]
|
||||
try:
|
||||
if self.download:
|
||||
return self.download.url
|
||||
except DigitalAssetDownload.RelatedObjectDoesNotExist:
|
||||
else:
|
||||
return DigitalAssetDownload.objects.create(order_product=self).url
|
||||
return ""
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue