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
|
||||
interfaces = (relay.Node,)
|
||||
fields = ("uuid", "categories", "name")
|
||||
filter_fields = ["uuid"]
|
||||
filter_fields = ["uuid", "name"]
|
||||
description = _("brands")
|
||||
|
||||
def resolve_categories(self, info):
|
||||
|
|
@ -101,7 +101,6 @@ class MinMaxPriceType(ObjectType):
|
|||
class CategoryType(DjangoObjectType):
|
||||
children = List(
|
||||
lambda: CategoryType,
|
||||
depth=Int(default_value=None),
|
||||
description=_("categories"),
|
||||
)
|
||||
image = String(description=_("category image url"))
|
||||
|
|
@ -132,15 +131,7 @@ class CategoryType(DjangoObjectType):
|
|||
filter_fields = ["uuid"]
|
||||
description = _("categories")
|
||||
|
||||
def resolve_children(self, info, depth=None) -> TreeQuerySet:
|
||||
max_depth = self.get_tree_depth()
|
||||
|
||||
if depth is None:
|
||||
depth = max_depth
|
||||
|
||||
if depth <= 0:
|
||||
return Category.objects.none()
|
||||
|
||||
def resolve_children(self, info) -> TreeQuerySet:
|
||||
categories = Category.objects.filter(parent=self)
|
||||
if info.context.user.has_perm("core.view_category"):
|
||||
return categories
|
||||
|
|
|
|||
Loading…
Reference in a new issue