From 54d8889ffa88484779efd346ad1519b3700d6f26 Mon Sep 17 00:00:00 2001 From: Egor fureunoir Gorbunov Date: Mon, 25 Aug 2025 00:41:02 +0300 Subject: [PATCH] Fixes: 1) Corrected products' filtering options on interfaces --- core/graphene/schema.py | 1 + core/managers.py | 10 ++++++++-- core/viewsets.py | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/core/graphene/schema.py b/core/graphene/schema.py index f7f6eab8..046f695d 100644 --- a/core/graphene/schema.py +++ b/core/graphene/schema.py @@ -155,6 +155,7 @@ class Query(ObjectType): is_active=True, brand__is_active=True, category__is_active=True, + stocks__isnull=False, stocks__vendor__is_active=True, ) .select_related("brand", "category") diff --git a/core/managers.py b/core/managers.py index 45f5385f..f120cad7 100644 --- a/core/managers.py +++ b/core/managers.py @@ -4,6 +4,7 @@ import requests from constance import config from django.contrib.gis.geos import Point from django.db import models +from modeltranslation.manager import MultilingualManager logger = logging.getLogger("django") @@ -64,10 +65,14 @@ class AddressManager(models.Manager): )[0] -class ProductManager(models.Manager): +class ProductManager(MultilingualManager): def available(self): return self.filter( - is_active=True, brand__is_active=True, category__is_active=True, stocks__vendor__is_active=True + is_active=True, + brand__is_active=True, + category__is_active=True, + stocks__isnull=False, + stocks__vendor__is_active=True, ) def available_in_stock(self): @@ -75,6 +80,7 @@ class ProductManager(models.Manager): is_active=True, brand__is_active=True, category__is_active=True, + stocks__isnull=False, stocks__vendor__is_active=True, stocks__quantity__gt=0, ) diff --git a/core/viewsets.py b/core/viewsets.py index d213b516..df27c738 100644 --- a/core/viewsets.py +++ b/core/viewsets.py @@ -544,6 +544,7 @@ class ProductViewSet(EvibesViewSet): is_active=True, brand__is_active=True, category__is_active=True, + stocks__isnull=False, stocks__vendor__is_active=True, )