|
@@ -1,31 +1,32 @@
|
|
|
# coding=utf-8
|
|
|
from rest_framework.views import APIView
|
|
|
+from django.db.models import Q
|
|
|
|
|
|
from utils.custom_modelviewset import CustomModelViewSet
|
|
|
from utils import response_ok, response_error
|
|
|
from apps.option.models import Option
|
|
|
from apps.option.serializers import OptionComboboxSerializer
|
|
|
-from .models import Customer
|
|
|
-from .serializers import CustomerSerializer
|
|
|
-from .filters import CustomerFilter
|
|
|
+from .models import ReportCustomer
|
|
|
+from .serializers import ReportCustomerSerializer
|
|
|
+from .filters import ReportCustomerFilter
|
|
|
|
|
|
|
|
|
-class CustomerViewSet(CustomModelViewSet):
|
|
|
+class ReportCustomerViewSet(CustomModelViewSet):
|
|
|
permission_classes = []
|
|
|
- queryset = Customer.objects.filter()
|
|
|
- serializer_class = CustomerSerializer
|
|
|
+ queryset = ReportCustomer.objects.filter()
|
|
|
+ serializer_class = ReportCustomerSerializer
|
|
|
|
|
|
def filter_queryset(self, queryset):
|
|
|
- f = CustomerFilter(self.request.GET, queryset=queryset)
|
|
|
+ f = ReportCustomerFilter(self.request.GET, queryset=queryset)
|
|
|
return f.qs
|
|
|
|
|
|
def perform_create(self, serializer):
|
|
|
- super(CustomerViewSet, self).perform_create(serializer)
|
|
|
+ super(ReportCustomerViewSet, self).perform_create(serializer)
|
|
|
instance = serializer.instance
|
|
|
validated_data = serializer.validated_data
|
|
|
|
|
|
def perform_update(self, serializer):
|
|
|
- super(CustomerViewSet, self).perform_update(serializer)
|
|
|
+ super(ReportCustomerViewSet, self).perform_update(serializer)
|
|
|
instance = serializer.instance
|
|
|
validated_data = serializer.validated_data
|
|
|
|
|
@@ -33,7 +34,7 @@ class CustomerViewSet(CustomModelViewSet):
|
|
|
instance = self.get_object()
|
|
|
# if instance.tenant != request.user.employee.tenant:
|
|
|
# raise CustomError(u'禁止跨企业操作!')
|
|
|
- super(CustomerViewSet, self).destroy(self, request, *args, **kwargs)
|
|
|
+ super(ReportCustomerViewSet, self).destroy(self, request, *args, **kwargs)
|
|
|
return response_ok()
|
|
|
|
|
|
# @action(methods=['post'], detail=False)
|
|
@@ -56,19 +57,17 @@ class CustomerViewSet(CustomModelViewSet):
|
|
|
# return response_error(str(e))
|
|
|
# return response_ok('审核完成!')
|
|
|
|
|
|
-class SourceDictView(APIView):
|
|
|
+class ReportCustomerDictView(APIView):
|
|
|
permission_classes = []
|
|
|
|
|
|
def get(self, request):
|
|
|
- rows = Option.objects.filter(type=Option.CUSTOMER_SOURCE,enable=True)
|
|
|
- serializer = OptionComboboxSerializer(rows, many=True)
|
|
|
- return response_ok(serializer.data)
|
|
|
+ scouce = Option.objects.filter(type=Option.CUSTOMER_SOURCE , enable=True)
|
|
|
+ project = Option.objects.filter(type=Option.CATEGORY, enable=True)
|
|
|
+ serializer_scouce = OptionComboboxSerializer(scouce, many=True)
|
|
|
+ serializer_project = OptionComboboxSerializer(project, many=True)
|
|
|
+ return response_ok({
|
|
|
+ 'source': serializer_scouce.data,
|
|
|
+ 'project': serializer_project.data,
|
|
|
+ })
|
|
|
|
|
|
|
|
|
-class ProjectDictView(APIView):
|
|
|
- permission_classes = []
|
|
|
-
|
|
|
- def get(self, request):
|
|
|
- rows = Option.objects.filter(type=Option.CATEGORY, enable=True)
|
|
|
- serializer = OptionComboboxSerializer(rows, many=True)
|
|
|
- return response_ok(serializer.data)
|