Skip to content

Commit

Permalink
继续使用v1的数据结构
Browse files Browse the repository at this point in the history
  • Loading branch information
hhyo committed Oct 22, 2022
1 parent a0ae8fc commit cf186c6
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
2 changes: 2 additions & 0 deletions sql/templates/rollback.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
cardView: false, //是否显示详细视图
toolbar: "#toolbar", //指明自定义的toolbar
detailView: true, //是否显示父子表
totalField: "count",
dataField: "results",
//格式化详情
detailFormatter: function (index, row) {
var html = [];
Expand Down
4 changes: 3 additions & 1 deletion sql/templates/sqlworkflow.html
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ <h4 class="modal-title text-danger">工单日志</h4>
detailView: false, //是否显示父子表
locale: 'zh-CN', //本地化
toolbar: "#toolbar", //指明自定义的toolbar
totalField: "count",
dataField: "results",
queryParamsType: '',
//请求服务数据时所传参数
queryParams:
Expand All @@ -175,7 +177,7 @@ <h4 class="modal-title text-danger">工单日志</h4>
}
return {
page: params.pageNumber,
page_size: params.pageSize,
size: params.pageSize,
status: $("#navStatus").val(),
instance_id: $("#instance_id").val(),
group_id: $("#group_id").val(),
Expand Down
4 changes: 2 additions & 2 deletions sql_api/api_views/sql_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from sql.models import SqlWorkflow
from sql.utils.resource_group import user_groups
from sql_api.filters import SqlWorkflowFilter
from sql_api.pagination import BootStrapTablePagination
from sql_api.pagination import CustomizedPagination, CustomizedPaginationV2
from sql_api.permissions.sql_workflow import SqlWorkFlowViewPermission
from sql_api.serializers.sql_workflow import (
ExecuteCheckSerializer,
Expand Down Expand Up @@ -93,7 +93,7 @@ def post(self, request):
class SqlWorkflowView(viewsets.ModelViewSet):
permission_classes = [IsAuthenticated, SqlWorkFlowViewPermission]
serializer_class = SqlWorkflowSerializer
pagination_class = BootStrapTablePagination
pagination_class = CustomizedPaginationV2
filter_backends = [
filters.SearchFilter,
django_filters.rest_framework.DjangoFilterBackend,
Expand Down
13 changes: 4 additions & 9 deletions sql_api/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,9 @@ def get_paginated_response(self, data):
)


class BootStrapTablePagination(PageNumberPagination):
"""
自定义分页器,返回bootstrap-table需要的格式
"""
class CustomizedPaginationV2(PageNumberPagination):
"""V2的分页器"""

page_size = 14

def get_paginated_response(self, data):
return Response(
OrderedDict([("total", self.page.paginator.count), ("rows", data)])
)
page_size_query_param = "size"
max_page_size = None
11 changes: 6 additions & 5 deletions sql_api/permissions/sql_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
class SqlWorkFlowViewPermission(permissions.BasePermission):
"""SQL工单权限校验"""

message = "你无权操作当前工单"
message = "你没有获取工单列表的权限"
obj_message = "工单状态不正确或者你没有该工单的权限"

def has_permission(self, request, view):
self.message = "你没有获取工单列表的权限"
self.message = self.message
return any(
[
request.user.has_perm("sql.menu_sqlworkflow"),
Expand All @@ -28,15 +29,15 @@ def has_permission(self, request, view):
)

def has_retrieve_permission(self, request, view, obj):
self.message = "你无权操作当前工单"
self.message = self.obj_message
return can_view(request.user, obj.id)

def has_rollback_sql_permission(self, request, view, obj):
self.message = "工单状态不正确或者你没有该工单的权限"
self.message = self.obj_message
return can_rollback(request.user, obj.id)

def has_alter_run_date_permission(self, request, view, obj):
self.message = "工单状态不正确或者你没有该工单的权限"
self.message = self.obj_message
return Audit.can_review(request.user, obj.id, 2)

def has_object_permission(self, request, view, obj):
Expand Down

0 comments on commit cf186c6

Please sign in to comment.