コード例 #1
0
class OnlineVersionListView(APIView):
    """创建或返回上线版本列表"""
    # 拥有工单提交/执行/审核权限的用户可以操作
    permission_classes = (anyof(CanCommitPermission, CanExecutePermission,
                                CanAuditPermission), )

    def get(self, request):
        data = OnlineVersion.objects.filter(is_deleted='0'). \
            values('id', 'version', 'username', 'expire_time', 'updated_at', 'created_at').order_by('-created_at')
        return Response(data=data, status=status.HTTP_200_OK)

    def post(self, request):
        serializer = OnlineVersionListSerializer(data=request.data)
        if serializer.is_valid():
            s, data = serializer.op(request)
            code = 0 if s else 2
            return Response(data={
                'code': code,
                'data': data
            },
                            status=status.HTTP_200_OK)
        else:
            errors = [str(v[0]) for k, v in serializer.errors.items()]
            data = {'code': 2, 'data': '\n'.join(errors)}
            return Response(data=data, status=status.HTTP_400_BAD_REQUEST)
コード例 #2
0
class RenderSubtasksView(APIView):
    """有执行权限的用户可以访问"""
    permission_classes = (anyof(CanCommitPermission, CanExecutePermission,
                                CanAuditPermission), )

    renderer_classes = [TemplateHTMLRenderer]
    template_name = 'orders/subtasks.html'

    def get(self, request, taskid):
        return Response(data={'taskid': taskid}, status=status.HTTP_200_OK)
コード例 #3
0
ファイル: opView.py プロジェクト: zyx852963/AuditSQL
class OrderCloseView(APIView):
    # 拥有工单提交/执行/审核权限的用户可以操作
    permission_classes = (anyof(CanCommitPermission, CanExecutePermission,
                                CanAuditPermission), )

    def post(self, request):
        serializer = OrderCloseSerializer(data=request.data)
        if serializer.is_valid():
            s, data = serializer.op(request)
            code = 0 if s else 2
            return Response(data={
                'code': code,
                'data': data
            },
                            status=status.HTTP_200_OK)
        else:
            print(serializer.errors.items())
            errors = [str(v[0]) for k, v in serializer.errors.items()]
            data = {'code': 2, 'data': '\n'.join(errors)}
            return Response(data=data, status=status.HTTP_400_BAD_REQUEST)
コード例 #4
0
ファイル: View.py プロジェクト: xingganfengxing/AuditSQL
class GetOrderReplyView(APIView):
    """
    获取工单回复的内容
    """
    # 拥有工单提交/执行/审核权限的用户可以操作
    permission_classes = (anyof(CanCommitPermission, CanExecutePermission,
                                CanAuditPermission), )

    def post(self, request):
        serializer = GetOrderReplySerializer(data=request.data)
        if serializer.is_valid():
            data = serializer.query()
            return Response(data={
                'code': 0,
                'data': data
            },
                            status=status.HTTP_200_OK)
        else:
            errors = [str(v[0]) for k, v in serializer.errors.items()]
            data = {'code': 2, 'data': '\n'.join(errors)}
            return Response(data=data, status=status.HTTP_400_BAD_REQUEST)
コード例 #5
0
class GenerateSubtasksView(APIView):
    """将SQL工单拆解成子任务"""
    # 有执行权限的用户可以执行
    permission_classes = (anyof(CanCommitPermission, CanExecutePermission,
                                CanAuditPermission), )

    def post(self, request):
        serializer = GenerateSubtasksSerializer(data=request.data)

        if serializer.is_valid():
            s, data = serializer.save(request)
            code = 0 if s else 2
            return Response(data={
                'code': code,
                'data': data
            },
                            status=status.HTTP_200_OK)
        else:
            errors = [str(v[0]) for k, v in serializer.errors.items()]
            data = {'code': 2, 'data': '\n'.join(errors)}
            return Response(data=data, status=status.HTTP_400_BAD_REQUEST)
コード例 #6
0
ファイル: opView.py プロジェクト: zyx852963/AuditSQL
class OrderReviewView(APIView):
    """
    工单的复核
    工单完成后,需要相关人员进行核对,核对完成后,需要点击复核按钮更新工单状态为已核对
    """
    # 拥有工单提交/执行/审核权限的用户可以操作
    permission_classes = (anyof(CanCommitPermission, CanExecutePermission,
                                CanAuditPermission), )

    def post(self, request):
        serializer = OrderReviewSerializer(data=request.data)
        if serializer.is_valid():
            s, data = serializer.op(request)
            code = 0 if s else 2
            return Response(data={
                'code': code,
                'data': data
            },
                            status=status.HTTP_200_OK)
        else:
            errors = [str(v[0]) for k, v in serializer.errors.items()]
            data = {'code': 2, 'data': '\n'.join(errors)}
            return Response(data=data, status=status.HTTP_400_BAD_REQUEST)