from rest_framework.viewsets import ModelViewSet

from apps.common.api import TeamScopedViewSetMixin

from .models import Product
from .serializers import ProductSerializer


class ProductViewSet(TeamScopedViewSetMixin, ModelViewSet):
    queryset = Product.objects.prefetch_related("images", "selling_points").all()
    serializer_class = ProductSerializer
    search_fields = ["title", "brand", "category"]
    ordering_fields = ["created_at", "updated_at", "title"]

