def retrieve(self, request, pk):
     try:
         proserver_data = ProjectDataServer.objects.get(id=pk)
     except ProjectDataServer.DoesNotExist:
         return StatusResponse(http_code=400, data={"tip": "项目不存在"})
     serializer = ProjectDataServerSerializer(instance=proserver_data)
     return StatusResponse(data=serializer.data, http_code=200)
 def delete(self, request, pk):
     try:
         proserver_data = ProjectDataServer.objects.get(id=pk)
         proserver_data.delete()
     except ProjectDataServer.DoesNotExist:
         return StatusResponse(http_code=400, data={"tip": "项目不存在"})
     return StatusResponse(http_code=200, data={"tip": "删除成功"})
 def delete(self, request):
     try:
         ids = request.data.get("ids")
         print("====ids====", request.data)
         InterfaceModel.objects.filter(id__in=ids).delete()
     except Exception as e:
         return StatusResponse(http_code=400, data={"tip": "删除失败"})
     return StatusResponse(http_code=200, data={"tip": "ok"})
Exemple #4
0
 def put(self, request):
     if request.user_id and request.refresh:
         token, refresh_token = self._generate_tokens(
             request.user_id, with_refresh_token=False)
         data = {"id": request.user_id, "token": token}
         response = StatusResponse(data=data, http_code=201)
         return response
     else:
         return StatusResponse(http_code=401, data={"tip": "token刷新失败"})
 def update(self, request, pk):
     try:
         proserverdata = ProjectDataServer.objects.get(id=pk)
     except ProjectDataServer.DoesNotExist:
         return StatusResponse(http_code=400, data={"tip": "服务不存在"})
     serializer = ProjectDataServerSerializer(instance=proserverdata,
                                              data=request.data)
     serializer.is_valid(raise_exception=True)
     serializer.save()
     return StatusResponse(data=serializer.data, http_code=200)
 def put(self, request):
     ids = request.data.get('ids')
     try:
         p = ProjectManager.objects.filter(id__in=ids).update(
             is_delete=True)
     except Exception as e:
         return StatusResponse(400, {"tip": "更新失败"})
     else:
         if p == 0:
             return StatusResponse(400, {"tip": "当前无更新"})
         else:
             return StatusResponse(200, {"tip": "更新成功"})
Exemple #7
0
 def delete(self, request):
     ids = request.data.get("ids", None)
     try:
         query = CaseFile.objects.filter(id__in=ids).all()
         if query.count() < 1:
             return StatusResponse(http_code=200,
                                   data={"success": "请选择要删除的数据"})
         for instance in query:
             instance.file_name.delete(False)
             instance.delete()
     except:
         return StatusResponse(http_code=200, data={"success": "删除失败"})
     return StatusResponse(http_code=200, data={"success": "删除成功"})
    def put(self, request):
        ids = request.data.get('ids')
        status = request.data.get('status')
        try:
            if status == 1:
                count = ProjectManager.objects.filter(id__in=ids).update(
                    status=True)
            else:
                count = ProjectManager.objects.filter(id__in=ids).update(
                    status=False)

        except ProjectManager.DoesNotExist:
            return StatusResponse(400, {"tip": "不存在"})
        else:
            if count == 0:
                return StatusResponse(400, {"tip": "当前无更新"})
            else:
                return StatusResponse(200, {"tip": "更新成功"})
Exemple #9
0
    def post(self, request):

        username = request.data.get("username")
        password = request.data.get("password")
        try:
            user = User.objects.get(username=username)
        except User.DoesNotExist as e:
            return StatusResponse(http_code=400, data={"tip": "用户不存在"})

        if user is not None and user.check_password(password):
            token, refresh_token = self._generate_tokens(
                user.id, with_refresh_token=True)
            data = {
                "token": token,
                "refresh_token": refresh_token,
                "id": user.id,
                "username": user.username
            }
            response = StatusResponse(data=data, http_code=201)
            return response
        return StatusResponse(http_code=400, data={"tip": "登录失败"})
Exemple #10
0
 def put(self, request, pk):
     ExcelImport.get_cases(request)
     return StatusResponse(http_code=200,
                           data=self.update(self.request, pk).data)
 def create(self, request):
     serializer = ProjectDataServerSerializer(data=request.data)
     serializer.is_valid(raise_exception=True)
     serializer.save()
     return StatusResponse(data=serializer.data, http_code=200)
Exemple #12
0
 def list(self, request, *args, **kwargs):
     return StatusResponse(data=super().list(request).data)
 def update(self, request, *args, **kwargs):
     return StatusResponse(http_code=200,
                           data=super().update(request, *args,
                                               **kwargs).data)
 def retrieve(self, request, pk):
     flow = InterfaceFlowModel.objects.filter(from_interfacemodel=pk).all()
     serializer = self.get_serializer(flow, many=True)
     return StatusResponse(http_code=200, data=serializer.data)
 def post(self, request):
     #self.send_executeid()
     test_script.delay([1, 2], name="zhangsan", age=18)
     return StatusResponse(http_code=200, data={"tip": "执行成功"})
 def create(self, request, *args, **kwargs):
     print(request.data)
     return StatusResponse(http_code=200,
                           data=super().create(request, *args,
                                               **kwargs).data)
 def get(self, request, pk):
     object = self.get_object()
     serilaizer = self.get_serializer(object)
     return StatusResponse(http_code=200, data=serilaizer.data)
 def post(self, request):
     """创建项目"""
     response = self.create(request)
     return StatusResponse(200, response.data)
    def put(self, request, pk):

        return StatusResponse(200, self.update(request).data)
 def get(self, request):
     return StatusResponse(200, self.list(request).data)
Exemple #21
0
 def post(self, request):
     ExcelImport.get_cases(request)
     return StatusResponse(http_code=200, data=self.create(request).data)
Exemple #22
0
 def post(self, request):
     serializer = self.get_serializer(data=request.data)
     serializer.is_valid(raise_exception=True)
     serializer.save()
     return StatusResponse(http_code=200, data=serializer.data)
Exemple #23
0
 def get(self, request):
     return StatusResponse(http_code=200, data=self.list(self.request).data)