Features: 1) Add validation to ensure category_uuid is present when using include_subcategories flag;

Fixes: 1) Add missing import for `BadRequest` from `django.core.exceptions`;

Extra: 1) Update placeholder method `filter_include_flag` with proper implementation;
This commit is contained in:
Egor Pavlovich Gorbunov 2025-06-16 09:42:41 +03:00
parent ea552fc3ba
commit 98993a721e

View file

@ -2,6 +2,7 @@ import json
import logging import logging
import uuid import uuid
from django.core.exceptions import BadRequest
from django.db.models import Avg, FloatField, OuterRef, Q, Subquery, Value from django.db.models import Avg, FloatField, OuterRef, Q, Subquery, Value
from django.db.models.functions import Coalesce from django.db.models.functions import Coalesce
from django.utils.http import urlsafe_base64_decode from django.utils.http import urlsafe_base64_decode
@ -121,7 +122,8 @@ class ProductFilter(FilterSet):
) )
def filter_include_flag(self, queryset, name, value): def filter_include_flag(self, queryset, name, value):
# just a placeholder method if not self.data.get("category_uuid"):
raise BadRequest(_("there must be a category_uuid to use include_subcategories flag"))
return queryset return queryset
def filter_attributes(self, queryset, _name, value): def filter_attributes(self, queryset, _name, value):