From 9ad79f0c5e64bc3bdb02efda1025c0e30169acda Mon Sep 17 00:00:00 2001 From: Egor fureunoir Gorbunov Date: Fri, 3 Oct 2025 17:26:58 +0300 Subject: [PATCH] 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. --- core/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/models.py b/core/models.py index 8b889b6a..465f9868 100644 --- a/core/models.py +++ b/core/models.py @@ -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 ""