Skip to content

Commit

Permalink
Fixed small bug
Browse files Browse the repository at this point in the history
  • Loading branch information
crisingulani committed Oct 15, 2024
1 parent cffc304 commit 238972c
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions backend/core/views/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,23 @@ def filter_name(self, queryset, name, value):
return queryset.filter(query)

def filter_type_name(self, queryset, name, value):
query = format_query_to_char(name, value, ["product_type__display_name", "product_type__name"])
query = format_query_to_char(
name, value, ["product_type__display_name", "product_type__name"]
)

return queryset.filter(query)

def filter_release(self, queryset, name, value):
query = format_query_to_char(name, value, ["release__display_name", "release__name"])
query = format_query_to_char(
name, value, ["release__display_name", "release__name"]
)
return queryset.filter(query)


class ProductSpeczViewSet(viewsets.ReadOnlyModelViewSet):
""" Esse endpoint retorna apenas os produtos cujo o product type é = a 'spec-z' e o status é = a 1
"""
queryset = Product.objects.filter(product_type__name = 'specz_catalog', status = 1)
"""Esse endpoint retorna apenas os produtos cujo o product type é = a 'spec-z' e o status é = a 1"""

queryset = Product.objects.filter(product_type__name="specz_catalog", status=1)
serializer_class = ProductSerializer
search_fields = [
"display_name",
Expand All @@ -85,6 +89,8 @@ class ProductSpeczViewSet(viewsets.ReadOnlyModelViewSet):
"created_at",
]
ordering = ["-created_at"]


class ProductViewSet(viewsets.ModelViewSet):
queryset = Product.objects.all()
serializer_class = ProductSerializer
Expand Down

0 comments on commit 238972c

Please sign in to comment.