return only wine-color tags

This commit is contained in:
Kuroshini 2019-11-27 13:57:12 +03:00
parent b6b1d8ab2a
commit ca7d7f0fa8
2 changed files with 5 additions and 2 deletions

View File

@ -43,8 +43,8 @@ class TagCategoryFilterSet(TagsBaseFilterSet):
'product_type', )
def by_product_type(self, queryset, name, value):
# if value == product_models.ProductType.WINE:
# queryset = queryset.filter(index_name='wine-color').filter(tags__products__isnull=False)
if value == product_models.ProductType.WINE:
return queryset.wine_tags_category().filter(tags__products__isnull=False)
queryset = queryset.by_product_type(value)
return queryset

View File

@ -111,6 +111,9 @@ class TagCategoryQuerySet(models.QuerySet):
"""Filter by product type index name."""
return self.filter(tags__products__product_type__index_name=index_name)
def wine_tags_category(self):
return self.filter(index_name='wine-color')
def with_tags(self, switcher=True):
"""Filter by existing tags."""
return self.exclude(tags__isnull=switcher)