Esempio n. 1
0
 def delete(self, request, *args, **kwargs):
     """
     删除工作流
     :param request:
     :param args:
     :param kwargs:
     :return:
     """
     app_name = request.META.get('HTTP_APPNAME')
     workflow_id = kwargs.get('workflow_id')
     from service.account.account_base_service import AccountBaseService
     # 判断是否有工作流的权限
     app_permission, msg = AccountBaseService.app_workflow_permission_check(
         app_name, workflow_id)
     if not app_permission:
         return api_response(
             -1,
             'APP:{} have no permission to get this workflow info'.format(
                 app_name), '')
     result, msg = WorkflowBaseService.delete_workflow(workflow_id)
     if not result:
         code, msg, data = -1, msg, {}
     else:
         code, msg, data = 0, '', {'workflow_id': result}
     return api_response(code, msg, data)
Esempio n. 2
0
 def post(self, request, *args, **kwargs):
     """
     新增工作流
     :param request:
     :param args:
     :param kwargs:
     :return:
     """
     json_str = request.body.decode('utf-8')
     if not json_str:
         return api_response(-1, 'post参数为空', {})
     request_data_dict = json.loads(json_str)
     workflow_data = {}
     app_name = request.META.get('HTTP_APPNAME')
     name = request_data_dict.get('name', '')
     description = request_data_dict.get('description', '')
     notices = request_data_dict.get('notices', '')
     view_permission_check = request_data_dict.get('view_permission_check',
                                                   1)
     limit_expression = request_data_dict.get('limit_expression', '')
     display_form_str = request_data_dict.get('display_form_str', '')
     creator = request.META.get('HTTP_USERNAME', '')
     result, msg = WorkflowBaseService.add_workflow(
         name, description, notices, view_permission_check,
         limit_expression, display_form_str, creator)
     if not result:
         code, msg, data = -1, msg, {}
     else:
         code, msg, data = 0, '', {'workflow_id': result}
     return api_response(code, msg, data)
Esempio n. 3
0
    def get(self, request, *args, **kwargs):
        """
        获取工作流列表
        :param request:
        :param args:
        :param kwargs:
        :return:
        """
        request_data = request.GET
        name = request_data.get('name', '')
        per_page = int(request_data.get('per_page', 10))
        page = int(request_data.get('page', 1))
        # username = request_data.get('username', '')  # 后续会根据username做必要的权限控制
        username = request.META.get('HTTP_USERNAME')
        app_name = request.META.get('HTTP_APPNAME')

        from service.account.account_base_service import AccountBaseService
        permission_workflow_id_list, msg = AccountBaseService.app_workflow_permission_list(
            app_name)

        workflow_result_restful_list, msg = WorkflowBaseService.get_workflow_list(
            name, page, per_page, permission_workflow_id_list)
        if workflow_result_restful_list is not False:
            data = dict(value=workflow_result_restful_list,
                        per_page=msg['per_page'],
                        page=msg['page'],
                        total=msg['total'])
            code, msg, = 0, ''
        else:
            code, data = -1, ''
        return api_response(code, msg, data)
Esempio n. 4
0
 def get(self, request, *args, **kwargs):
     """
     获取工作流详情
     :param request:
     :param args:
     :param kwargs:
     :return:
     """
     workflow_id = kwargs.get('workflow_id')
     app_name = request.META.get('HTTP_APPNAME')
     from service.account.account_base_service import AccountBaseService
     # 判断是否有工作流的权限
     app_permission, msg = AccountBaseService.app_workflow_permission_check(
         app_name, workflow_id)
     if not app_permission:
         return api_response(
             -1,
             'APP:{} have no permission to get this workflow info'.format(
                 app_name), '')
     workflow_result, msg = WorkflowBaseService.get_by_id(workflow_id)
     if not workflow_result:
         code, msg, data = -1, msg, {}
     else:
         data = dict(
             name=workflow_result.name,
             description=workflow_result.description,
             notices=workflow_result.notices,
             view_permission_check=workflow_result.view_permission_check,
             limit_expression=workflow_result.limit_expression,
             display_form_str=workflow_result.display_form_str,
             creator=workflow_result.creator,
             gmt_created=str(workflow_result.gmt_created)[:19])
         code = 0
     return api_response(code, msg, data)
Esempio n. 5
0
    def get(self, request, *args, **kwargs):
        """
        获取工作流列表
        :param request:
        :param args:
        :param kwargs:
        :return:
        """
        request_data = request.GET
        name = request_data.get('name', '')
        per_page = int(request_data.get('per_page', 10))
        page = int(request_data.get('page', 1))
        username = request_data.get('username', '')  # 后续会根据username做必要的权限控制

        workflow_result_restful_list, msg = WorkflowBaseService.get_workflow_list(
            name, page, per_page)
        if workflow_result_restful_list is not False:
            data = dict(value=workflow_result_restful_list,
                        per_page=msg['per_page'],
                        page=msg['page'],
                        total=msg['total'])
            code, msg, = 0, ''
        else:
            code, data = -1, ''
        return api_response(code, msg, data)
Esempio n. 6
0
    def get(self, request, *args, **kwargs):
        request_data = request.GET

        query_value = request_data.get('query_value', '')
        page = int(request_data.get('page', 1)) if request_data.get('page',
                                                                    0) else 1
        per_page = int(request_data.get('per_page', 10)) if request_data.get(
            'per_page', 10) else 10

        workflows, msg = WorkflowBaseService.get_workflows(
            query_value, per_page, page)

        if workflows is not False:
            workflow_serializer_list = [
                WorkflowSerializer(workflow) for workflow in workflows
            ]
            workflow_serializer_list = [
                workflow_serializer.data
                for workflow_serializer in workflow_serializer_list
            ]
            return format_response.JsonResponse(data=workflow_serializer_list,
                                                code=status.HTTP_200_OK,
                                                per_page=msg.get(
                                                    'per_page', ''),
                                                page=msg.get('page', ''),
                                                total=msg.get('total', ''))
        else:
            return format_response.JsonResponse(
                data='', code=status.HTTP_500_INTERNAL_SERVER_ERROR, msg=msg)
Esempio n. 7
0
    def patch(self, request, *args, **kwargs):
        """
        修改工作流
        :param request:
        :param args:
        :param kwargs:
        :return:
        """
        json_str = request.body.decode('utf-8')
        if not json_str:
            return api_response(-1, 'post参数为空', {})
        request_data_dict = json.loads(json_str)
        app_name = request.META.get('HTTP_APPNAME')
        workflow_id = kwargs.get('workflow_id')
        from service.account.account_base_service import AccountBaseService
        # 判断是否有工作流的权限
        app_permission, msg = AccountBaseService.app_workflow_permission_check(
            app_name, workflow_id)
        if not app_permission:
            return api_response(
                -1,
                'APP:{} have no permission to get this workflow info'.format(
                    app_name), '')
        name = request_data_dict.get('name', '')
        description = request_data_dict.get('description', '')
        notices = request_data_dict.get('notices', '')
        view_permission_check = request_data_dict.get('view_permission_check',
                                                      1)
        limit_expression = request_data_dict.get('limit_expression', '')
        display_form_str = request_data_dict.get('display_form_str', '')

        result, msg = WorkflowBaseService.edit_workflow(
            workflow_id, name, description, notices, view_permission_check,
            limit_expression, display_form_str)
        if not result:
            code, msg, data = -1, msg, {}
        else:
            code, msg, data = 0, '', {'workflow_id': result}
        return api_response(code, msg, data)
Esempio n. 8
0
 def delete(self, request, workflow_id):
     result, msg = WorkflowBaseService.del_workflow_by_id(workflow_id)
     if result:
         return format_response.JsonResponse(data='',
                                             code=status.HTTP_200_OK,
                                             msg=msg)
Esempio n. 9
0
 def get(self, request, workflow_id):
     workflow, msg = WorkflowBaseService.get_workflow_by_id(workflow_id)
     workflow_serializer = WorkflowSerializer(workflow).data
     return format_response.JsonResponse(data=workflow_serializer,
                                         code=status.HTTP_200_OK,
                                         msg=msg)