From 80e1b0335b9e424a13055bf62554d966bae43d19 Mon Sep 17 00:00:00 2001 From: Egor fureunoir Gorbunov Date: Wed, 7 May 2025 15:07:48 +0300 Subject: [PATCH] "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." --- core/graphene/schema.py | 2 +- core/permissions.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/core/graphene/schema.py b/core/graphene/schema.py index 39db3442..f8c8d920 100644 --- a/core/graphene/schema.py +++ b/core/graphene/schema.py @@ -136,7 +136,7 @@ class Query(ObjectType): Product.objects.all().select_related("brand", "category").prefetch_related("images", "stocks") if info.context.user.has_perm("core.view_product") 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") ) diff --git a/core/permissions.py b/core/permissions.py index 8ccdee87..258d87b0 100644 --- a/core/permissions.py +++ b/core/permissions.py @@ -51,6 +51,7 @@ class EvibesPermission(permissions.BasePermission): if action in [ "buy", + "buy_unregistered", "current", "add_order_product", "remove_order_product",