Exemple #1
0
 def update(self, request, pk=None):
     request.data['username'] = request.user.username
     ins = WorkFlowAPiRequest(username=self.request.user.username)
     ins.getdata(parameters={},
                 method='post',
                 url='/api/v1.0/tickets/{}/retry_script'.format(pk),
                 data=request.data)
     return Response({'code': 0}, status=status.HTTP_200_OK)
Exemple #2
0
 def create(self, request):
     request.data['username'] = request.user.username
     #resp = requests.post('http://localhost:6060/api/v1.0/tickets', data=simplejson.dumps(request.data)).text
     #resp = simplejson.loads(resp)
     ins = WorkFlowAPiRequest(appname='ops',
                              username=self.request.user.username)
     rstatus, resp = ins.getdata(dict(username=self.request.user.username,
                                      per_page=10,
                                      name=''),
                                 method='post',
                                 url='/api/v1.0/tickets',
                                 data=request.data)
     if resp['code'] == 0:
         status_resp = status.HTTP_200_OK
         return Response(
             {
                 'code': resp['code'],
                 'data': resp['data'],
                 'msg': resp['msg']
             },
             status=status_resp)
     else:
         status_resp = status.HTTP_400_BAD_REQUEST
         return Response(
             {
                 'code': resp['code'],
                 'data': None,
                 'msg': resp['msg']
             },
             status=status_resp)
Exemple #3
0
 def retrieve(self, request, pk=None):
     username = request.user.username
     #resp = requests.get('http://localhost:6060/api/v1.0/workflows/{}/init_state?username={}'.format(pk, username)).text
     #resp = simplejson.loads(resp)
     ins = WorkFlowAPiRequest(appname='ops',
                              username=self.request.user.username)
     rstatus, resp = ins.getdata(
         dict(username=self.request.user.username, per_page=10, name=''),
         method='get',
         url='/api/v1.0/workflows/{}/init_state?username={}'.format(
             pk, username))
     if resp['code'] == 0:
         status_resp = status.HTTP_200_OK
         return Response(
             {
                 'code': resp['code'],
                 'data': resp['data'],
                 'msg': resp['msg']
             },
             status=status_resp)
     else:
         status_resp = status.HTTP_400_BAD_REQUEST
         return Response(
             {
                 'code': resp['code'],
                 'data': None,
                 'msg': resp['msg']
             },
             status=status_resp)
Exemple #4
0
 def partial_update(self, request, pk=None):
     request.data['username'] = request.user.username
     #resp = requests.patch('http://localhost:6060/api/v1.0/tickets/{}'.format(pk), data=simplejson.dumps(request.data)).text
     # print(resp)
     #resp = simplejson.loads(resp)
     ins = WorkFlowAPiRequest(appname='ops',
                              username=self.request.user.username)
     rstatus, resp = ins.getdata(
         parameters=dict(username=self.request.user.username),
         method='patch',
         url='/api/v1.0/tickets/{}'.format(pk),
         data=request.data)
     if resp['code'] == 0:
         status_resp = status.HTTP_200_OK
         return Response(
             {
                 'code': resp['code'],
                 'data': resp['data'],
                 'msg': resp['msg']
             },
             status=status_resp)
     else:
         status_resp = status.HTTP_400_BAD_REQUEST
         return Response(
             {
                 'code': resp['code'],
                 'data': None,
                 'msg': resp['msg']
             },
             status=status_resp)
Exemple #5
0
    def get(self, request, format='json'):
        #resp = requests.get('http://localhost:6060/api/v1.0/workflows').text

        #resp = simplejson.loads(resp)
        ins = WorkFlowAPiRequest(username=self.request.user.username)
        rstatus, resp = ins.getdata(dict(per_page=10, name=''),
                                    method='get',
                                    url='/api/v1.0/workflows')
        if resp['code'] == 0:
            status_resp = status.HTTP_200_OK
            return Response(
                {
                    'code': resp['code'],
                    'data': resp['data'],
                    'msg': resp['msg']
                },
                status=status_resp)
        else:
            status_resp = status.HTTP_400_BAD_REQUEST
            return Response(
                {
                    'code': resp['code'],
                    'data': None,
                    'msg': resp['msg']
                },
                status=status_resp)
Exemple #6
0
    def list(self, request, format='json'):
        username = request.user.username
        category = request.query_params.get('category', None)

        url = '/api/v1.0/tickets?username={}'.format(username)

        if category:
            url += '&category={}'.format(category)

        #resp = requests.get(url).text
        #resp = simplejson.loads(resp)
        page = request.query_params.get('page', 1)
        ins = WorkFlowAPiRequest(username=self.request.user.username)
        rstatus, resp = ins.getdata(dict(per_page=10, name='', page=page),
                                    method='get',
                                    url=url)
        if resp['code'] == 0:
            status_resp = status.HTTP_200_OK
            return Response(
                {
                    'code': resp['code'],
                    'data': resp['data'],
                    'msg': resp['msg']
                },
                status=status_resp)
        else:
            status_resp = status.HTTP_400_BAD_REQUEST
            return Response(
                {
                    'code': resp['code'],
                    'data': None,
                    'msg': resp['msg']
                },
                status=status_resp)
Exemple #7
0
 def retrieve(self, request, pk=None):
     username = request.user.username
     ins = WorkFlowAPiRequest(username=self.request.user.username)
     rstatus, resp = ins.getdata(
         dict(per_page=10, name=''),
         method='get',
         url='/api/v1.0/tickets/{}/transitions?username={}'.format(
             pk, username))
     if resp['code'] == 0:
         status_resp = status.HTTP_200_OK
         return Response(
             {
                 'code': resp['code'],
                 'data': resp['data'],
                 'msg': resp['msg']
             },
             status=status_resp)
     else:
         status_resp = status.HTTP_400_BAD_REQUEST
         return Response(
             {
                 'code': resp['code'],
                 'data': None,
                 'msg': resp['msg']
             },
             status=status_resp)
Exemple #8
0
 def update(self, request, pk=None):
     request.data['username'] = request.user.username
     ins = WorkFlowAPiRequest(username=self.request.user.username)
     rstatus, resp = ins.getdata(
         parameters={},
         method='post',
         url='/api/v1.0/tickets/{}/deliver'.format(pk),
         data=request.data)
     if resp['code'] == 0:
         status_resp = status.HTTP_200_OK
         return Response(
             {
                 'code': resp['code'],
                 'data': resp['data'],
                 'msg': resp['msg']
             },
             status=status_resp)
     else:
         status_resp = status.HTTP_400_BAD_REQUEST
         return Response(
             {
                 'code': resp['code'],
                 'data': None,
                 'msg': resp['msg']
             },
             status=status_resp)
Exemple #9
0
 def retrieve(self, request, pk=None):
     username = request.user.username
     #resp = requests.get('http://localhost:6060/api/v1.0/tickets/{}/transitions?username={}'.format(pk, username)).text
     #resp = simplejson.loads(resp)
     ins = WorkFlowAPiRequest(username=self.request.user.username)
     rstatus, resp = ins.getdata(self.request.query_params, method='get', url='/api/v1.0/tickets/{}/transitions?username={}'.format(pk, username))
     if resp['code'] == 0:
         status_resp = status.HTTP_200_OK
         return Response({'code': resp['code'], 'data': resp['data'], 'msg': resp['msg']},
                         status=status_resp)
     else:
         status_resp = status.HTTP_200_OK
         return Response({'code': resp['code'], 'data': None, 'msg': resp['msg']}, status=status_resp)
Exemple #10
0
    def list(self, request, format='json'):
        username = request.user.username
        category = request.query_params.get('category', None)

        url = '/api/v1.0/tickets?username={}'.format(username)

        if category:
            queryset = ShutongUser.objects.filter(username=username)
            data = FetchAccountUserSerializer(queryset, many=True).data
            if not data[0].get('is_superuser') and category == 'all':
                category = 'relation'
            url += '&category={}'.format(category)

        # resp = requests.get(url).text
        # resp = simplejson.loads(resp)
        page = request.query_params.get('page', 1)
        ins = WorkFlowAPiRequest(username=self.request.user.username)
        rstatus, resp = ins.getdata(dict(per_page=10, name='', page=page),
                                    method='get',
                                    url=url)
        if resp['code'] == 0:
            status_resp = status.HTTP_200_OK
            return Response(
                {
                    'code': resp['code'],
                    'data': resp['data'],
                    'msg': resp['msg']
                },
                status=status_resp)
        else:
            status_resp = status.HTTP_400_BAD_REQUEST
            return Response(
                {
                    'code': resp['code'],
                    'data': None,
                    'msg': resp['msg']
                },
                status=status_resp)