Features: 1) Add "name" to filter_fields in BrandType.
Fixes: 1) Simplify resolve_children method in CategoryType by removing unused depth argument. Extra: 1) Remove redundant depth parameter declaration; 2) General code cleanup in CategoryType.
This commit is contained in:
parent
03c9874f63
commit
eb59f9c96e
1 changed files with 2 additions and 11 deletions
|
|
@ -79,7 +79,7 @@ class BrandType(DjangoObjectType):
|
||||||
model = Brand
|
model = Brand
|
||||||
interfaces = (relay.Node,)
|
interfaces = (relay.Node,)
|
||||||
fields = ("uuid", "categories", "name")
|
fields = ("uuid", "categories", "name")
|
||||||
filter_fields = ["uuid"]
|
filter_fields = ["uuid", "name"]
|
||||||
description = _("brands")
|
description = _("brands")
|
||||||
|
|
||||||
def resolve_categories(self, info):
|
def resolve_categories(self, info):
|
||||||
|
|
@ -101,7 +101,6 @@ class MinMaxPriceType(ObjectType):
|
||||||
class CategoryType(DjangoObjectType):
|
class CategoryType(DjangoObjectType):
|
||||||
children = List(
|
children = List(
|
||||||
lambda: CategoryType,
|
lambda: CategoryType,
|
||||||
depth=Int(default_value=None),
|
|
||||||
description=_("categories"),
|
description=_("categories"),
|
||||||
)
|
)
|
||||||
image = String(description=_("category image url"))
|
image = String(description=_("category image url"))
|
||||||
|
|
@ -132,15 +131,7 @@ class CategoryType(DjangoObjectType):
|
||||||
filter_fields = ["uuid"]
|
filter_fields = ["uuid"]
|
||||||
description = _("categories")
|
description = _("categories")
|
||||||
|
|
||||||
def resolve_children(self, info, depth=None) -> TreeQuerySet:
|
def resolve_children(self, info) -> TreeQuerySet:
|
||||||
max_depth = self.get_tree_depth()
|
|
||||||
|
|
||||||
if depth is None:
|
|
||||||
depth = max_depth
|
|
||||||
|
|
||||||
if depth <= 0:
|
|
||||||
return Category.objects.none()
|
|
||||||
|
|
||||||
categories = Category.objects.filter(parent=self)
|
categories = Category.objects.filter(parent=self)
|
||||||
if info.context.user.has_perm("core.view_category"):
|
if info.context.user.has_perm("core.view_category"):
|
||||||
return categories
|
return categories
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue