|
@@ -1,12 +1,15 @@
|
|
|
# coding=utf-8
|
|
|
from rest_framework.decorators import action
|
|
|
from rest_framework import permissions
|
|
|
-from django.utils import timezone
|
|
|
+
|
|
|
+from rest_framework.views import APIView
|
|
|
|
|
|
from utils.custom_modelviewset import CustomModelViewSet
|
|
|
from utils.permission import IsAdministratorUser,IsTenantUser
|
|
|
from utils.exceptions import CustomError
|
|
|
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
|
|
@@ -38,27 +41,39 @@ class CustomerViewSet(CustomModelViewSet):
|
|
|
super(CustomerViewSet, self).destroy(self, request, *args, **kwargs)
|
|
|
return response_ok()
|
|
|
|
|
|
- @action(methods=['post'], detail=False)
|
|
|
- def check(self, request, pk):
|
|
|
- # 审核
|
|
|
- report_status = request.POST.get('report_status')
|
|
|
- try:
|
|
|
- instance = Customer.objects.filter(id=pk).first()
|
|
|
- if not instance:
|
|
|
- raise CustomError('当前客户报备有误!')
|
|
|
- if instance.report_status == Customer.CHECKED:
|
|
|
- instance.report_status = Customer.REPEAT_REPORT
|
|
|
- instance.save()
|
|
|
- return response_ok('当前客户已审核!')
|
|
|
- if instance.report_status == Customer.REPEAT_REPORT:
|
|
|
- raise CustomError('当前用户已重复报备!')
|
|
|
+ # @action(methods=['post'], detail=False)
|
|
|
+ # def check(self, request, pk):
|
|
|
+ # # 审核
|
|
|
+ # report_status = request.POST.get('report_status')
|
|
|
+ # try:
|
|
|
+ # instance = Customer.objects.filter(id=pk).first()
|
|
|
+ # if not instance:
|
|
|
+ # raise CustomError('当前客户报备信息有误!')
|
|
|
+ #
|
|
|
+ # instance.check_user = self.request.user
|
|
|
+ # instance.report_status = report_status
|
|
|
+ # instance.check_time = timezone.now()
|
|
|
+ # instance.save()
|
|
|
+ #
|
|
|
+ # except CustomError as e:
|
|
|
+ # return response_error(e.get_error_msg())
|
|
|
+ # except Exception as e:
|
|
|
+ # return response_error(str(e))
|
|
|
+ # return response_ok('审核完成!')
|
|
|
+
|
|
|
+class SourceDictView(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)
|
|
|
+
|
|
|
|
|
|
- instance.report_status = report_status
|
|
|
- instance.check_time = timezone.now()
|
|
|
- instance.save()
|
|
|
+class ProjectDictView(APIView):
|
|
|
+ permission_classes = []
|
|
|
|
|
|
- except CustomError as e:
|
|
|
- return response_error(e.get_error_msg())
|
|
|
- except Exception as e:
|
|
|
- return response_error(str(e))
|
|
|
- return response_ok('审核完成!')
|
|
|
+ def get(self, request):
|
|
|
+ rows = Option.objects.filter(type=Option.CATEGORY, enable=True)
|
|
|
+ serializer = OptionComboboxSerializer(rows, many=True)
|
|
|
+ return response_ok(serializer.data)
|