feat: added tags
This commit is contained in:
@@ -20,6 +20,8 @@ from shop.api.v1.serializers import (
|
||||
ProductBatchSerializer,
|
||||
CreateProductSerializer,
|
||||
CreateProductPriceSerializer,
|
||||
TagSerializer,
|
||||
ListProductSerializer,
|
||||
)
|
||||
from shop.models import (
|
||||
Product,
|
||||
@@ -30,6 +32,7 @@ from shop.models import (
|
||||
OrderLine,
|
||||
Provider,
|
||||
ProductBatch,
|
||||
Tag,
|
||||
)
|
||||
|
||||
from shop.api.v1.permissions import ProductPermissions, ProductPricePermissions
|
||||
@@ -46,6 +49,8 @@ class ProductViewSet(ModelViewSet):
|
||||
def get_serializer_class(self):
|
||||
if self.action == "create":
|
||||
return CreateProductSerializer
|
||||
elif self.action == "list":
|
||||
return ListProductSerializer
|
||||
return self.serializer_class
|
||||
|
||||
def perform_destroy(self, instance):
|
||||
@@ -145,3 +150,8 @@ class OrderLineViewSet(ModelViewSet):
|
||||
.select_related("order")
|
||||
.filter(order__uuid=self.kwargs.get("order_id"))
|
||||
)
|
||||
|
||||
|
||||
class TagViewSet(ModelViewSet):
|
||||
serializer_class = TagSerializer
|
||||
queryset = Tag.objects.all()
|
||||
|
||||
Reference in New Issue
Block a user