# coding=utf-8 from django.db import transaction from rest_framework.decorators import action from utils import response_ok, response_error from utils.exceptions import CustomError from utils.permission import IsCustomer from utils.custom_modelviewset import CustomModelViewSet from apps.order.models import ShoppingCart from apps.order.filters import ShoppingCartFilter from apps.customer.order.serializers import ShoppingCartSerializer from apps.log.models import BizLog class ShoppingCartViewSet(CustomModelViewSet): permission_classes = [IsCustomer, ] queryset = ShoppingCart.objects.filter() serializer_class = ShoppingCartSerializer def filter_queryset(self, queryset): queryset = queryset.filter(customer=self.request.customer) f = ShoppingCartFilter(self.request.GET, queryset=queryset) return f.qs def perform_create(self, serializer): super(ShoppingCartViewSet, self).perform_create(serializer)