"Enhance product filtering and permissions handling

Ensure inactive products without stock are excluded from queries by updating the filter. Add 'buy_unregistered' action to permissions for better access control."
This commit is contained in:
Egor Pavlovich Gorbunov 2025-05-07 15:07:48 +03:00
parent 50fe95e713
commit 80e1b0335b
2 changed files with 2 additions and 1 deletions

View file

@ -136,7 +136,7 @@ class Query(ObjectType):
Product.objects.all().select_related("brand", "category").prefetch_related("images", "stocks") Product.objects.all().select_related("brand", "category").prefetch_related("images", "stocks")
if info.context.user.has_perm("core.view_product") if info.context.user.has_perm("core.view_product")
else Product.objects.filter( else Product.objects.filter(
is_active=True, brand__is_active=True, category__is_active=True is_active=True, brand__is_active=True, category__is_active=True, stocks__isnull=False
).select_related("brand", "category").prefetch_related("images", "stocks") ).select_related("brand", "category").prefetch_related("images", "stocks")
) )

View file

@ -51,6 +51,7 @@ class EvibesPermission(permissions.BasePermission):
if action in [ if action in [
"buy", "buy",
"buy_unregistered",
"current", "current",
"add_order_product", "add_order_product",
"remove_order_product", "remove_order_product",