views.py 963 B

123456789101112131415161718192021222324252627
  1. # coding=utf-8
  2. from django.db import transaction
  3. from rest_framework.decorators import action
  4. from utils import response_ok, response_error
  5. from utils.exceptions import CustomError
  6. from utils.permission import IsCustomer
  7. from utils.custom_modelviewset import CustomModelViewSet
  8. from apps.order.models import ShoppingCart
  9. from apps.order.filters import ShoppingCartFilter
  10. from apps.customer.order.serializers import ShoppingCartSerializer
  11. from apps.log.models import BizLog
  12. class ShoppingCartViewSet(CustomModelViewSet):
  13. permission_classes = [IsCustomer, ]
  14. queryset = ShoppingCart.objects.filter()
  15. serializer_class = ShoppingCartSerializer
  16. def filter_queryset(self, queryset):
  17. queryset = queryset.filter(customer=self.request.customer)
  18. f = ShoppingCartFilter(self.request.GET, queryset=queryset)
  19. return f.qs
  20. def perform_create(self, serializer):
  21. super(ShoppingCartViewSet, self).perform_create(serializer)