67 lines
1.5 KiB
Python
67 lines
1.5 KiB
Python
from rest_framework.viewsets import ModelViewSet
|
|
|
|
from shop.api.v1.serializers import (
|
|
ProductSerializer,
|
|
ProductPriceSerializer,
|
|
CustomerSerializer,
|
|
TaxSerializer,
|
|
OrderSerializer,
|
|
OrderLineSerializer,
|
|
ProviderSerializer,
|
|
ProductBatchSerializer,
|
|
)
|
|
from shop.models import (
|
|
Product,
|
|
ProductPrice,
|
|
Customer,
|
|
Tax,
|
|
Order,
|
|
OrderLine,
|
|
Provider,
|
|
ProductBatch,
|
|
)
|
|
|
|
|
|
class ProductViewSet(ModelViewSet):
|
|
serializer_class = ProductSerializer
|
|
queryset = Product.objects.all()
|
|
|
|
|
|
class ProductPriceViewSet(ModelViewSet):
|
|
serializer_class = ProductPriceSerializer
|
|
queryset = ProductPrice.objects.all()
|
|
|
|
|
|
class ProductBatchViewSet(ModelViewSet):
|
|
serializer_class = ProductBatchSerializer
|
|
queryset = ProductBatch.objects.all()
|
|
|
|
|
|
class CustomerViewSet(ModelViewSet):
|
|
serializer_class = CustomerSerializer
|
|
queryset = Customer.objects.all()
|
|
|
|
|
|
class ProviderViewSet(ModelViewSet):
|
|
serializer_class = ProviderSerializer
|
|
queryset = Provider.objects.all()
|
|
|
|
|
|
class TaxViewSet(ModelViewSet):
|
|
serializer_class = TaxSerializer
|
|
queryset = Tax.objects.all()
|
|
|
|
|
|
class OrderViewSet(ModelViewSet):
|
|
serializer_class = OrderSerializer
|
|
queryset = Order.objects.all()
|
|
lookup_field = "uuid"
|
|
|
|
|
|
class OrderLineViewSet(ModelViewSet):
|
|
serializer_class = OrderLineSerializer
|
|
queryset = OrderLine.objects.all()
|
|
|
|
def get_queryset(self):
|
|
return super().get_queryset().filter(order_id=self.kwargs.get("order_id"))
|