Features: 1) Add "Stock.DoesNotExist" and "ProductImage.DoesNotExist" to ignored exceptions in base settings;
Fixes: 1) Ensure auto_resolver_helper returns only the created or fetched instance by accessing tuple index [0]; Extra: None;
This commit is contained in:
parent
2e9659a562
commit
ea0d14bfc8
2 changed files with 3 additions and 1 deletions
2
core/vendors/__init__.py
vendored
2
core/vendors/__init__.py
vendored
|
|
@ -102,7 +102,7 @@ class AbstractVendor:
|
|||
def auto_resolver_helper(model: type[Brand] | type[Category], resolving_name: str):
|
||||
queryset = model.objects.filter(name=resolving_name)
|
||||
if not queryset.exists():
|
||||
return model.objects.get_or_create(name=resolving_name, defaults={"is_active": False})
|
||||
return model.objects.get_or_create(name=resolving_name, defaults={"is_active": False})[0]
|
||||
elif queryset.filter(is_active=True).count() > 1:
|
||||
queryset = queryset.filter(is_active=True)
|
||||
elif queryset.filter(is_active=False).count() > 1:
|
||||
|
|
|
|||
|
|
@ -301,6 +301,8 @@ if getenv("SENTRY_DSN"):
|
|||
"core.models.Product.DoesNotExist",
|
||||
"core.models.Category.DoesNotExist",
|
||||
"core.models.Brand.DoesNotExist",
|
||||
"core.models.Stock.DoesNotExist",
|
||||
"core.models.ProductImage.DoesNotExist",
|
||||
"blog.models.Post.DoesNotExist",
|
||||
]
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue