Skip to content

Commit

Permalink
增加下载的权限(#1367) (#1369)
Browse files Browse the repository at this point in the history
* 增加下载的权限(#1367)

* 修复拼写错误

* 补加SQL文件

* 变量名修改以及其他优化

* 权限名修改
  • Loading branch information
weideguo authored Feb 12, 2022
1 parent 17fad34 commit 360d052
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions sql/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,7 @@ class Meta:
('archive_review', '审核归档申请'),
('archive_mgt', '管理归档申请'),
('audit_user','审计权限'),
('query_download', '在线查询下载权限'),
)


Expand Down
2 changes: 1 addition & 1 deletion sql/templates/group.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
}],
onLoadSuccess: function () {
},
onLoadError: fonLoadErrorCallback,
onLoadError: onLoadErrorCallback,
onSearch: function (e) {
//传搜索参数给服务器
queryParams(e)
Expand Down
6 changes: 4 additions & 2 deletions sql/templates/sqlquery.html
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ <h4 class="modal-title text-danger">收藏语句</h4>
<script>
//获取查询列表
function get_querylog(query_log_id) {
var showExport = {{can_download}}===1
//初始化table
$('#sql-log').bootstrapTable('destroy').bootstrapTable({
escape: true,
Expand All @@ -280,7 +281,7 @@ <h4 class="modal-title text-danger">收藏语句</h4>
pageNumber: 1, //初始化加载第一页默认第一页,并记录
pageSize: 14, //每页的记录行数*
pageList: [10, 30, 50, 100], //可供选择的每页的行数*
showExport: true, //是否显示导出按钮
showExport: showExport, //是否显示导出按钮
exportTypes: ['json', 'sql', 'csv', 'txt', 'xml', 'xlsx'],
exportOptions: {
ignoreColumn: [0], //忽略某些列的索引数组
Expand Down Expand Up @@ -781,11 +782,12 @@ <h4 class="modal-title text-danger">收藏语句</h4>
if (optgroup == 'Mongo') {
isdetail = true
}
var showExport = {{can_download}}===1
$("#" + ('query_result' + n)).bootstrapTable('destroy').bootstrapTable({
escape: true,
data: result['rows'],
columns: columns,
showExport: true,
showExport: showExport,
exportDataType: "all",
exportTypes: ['json', 'sql', 'csv', 'txt', 'xml', 'xlsx'],
exportOptions: {
Expand Down
6 changes: 3 additions & 3 deletions sql/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ def sqlquery(request):
# 收藏语句
user = request.user
favorites = QueryLog.objects.filter(username=user.username, favorite=True).values('id', 'alias')
return render(request, 'sqlquery.html', {'favorites': favorites})
can_download = 1 if user.has_perm('sql.download') or user.is_superuser else 0
return render(request, 'sqlquery.html', {'favorites': favorites, 'can_download':can_download})


@permission_required('sql.menu_queryapplylist', raise_exception=True)
Expand Down Expand Up @@ -448,8 +449,7 @@ def audit_sqlquery(request):
"""SQL在线查询页面审计"""
user = request.user
favorites = QueryLog.objects.filter(username=user.username, favorite=True).values('id', 'alias')
is_download = 1 if user.has_perm('sql.download') or user.is_superuser else 0
return render(request, 'audit_sqlquery.html', {'favorites': favorites, 'is_download':is_download})
return render(request, 'audit_sqlquery.html', {'favorites': favorites})


def audit_sqlworkflow(request):
Expand Down
7 changes: 6 additions & 1 deletion src/init_sql/v1.8.3.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,9 @@ alter table audit_log add `user_display` varchar(50) DEFAULT NULL COMMENT '用

set @content_type_id=(select id from django_content_type where app_label='sql' and model='permission');
insert IGNORE INTO auth_permission (name, content_type_id, codename) VALUES
('审计权限 ', @content_type_id, 'audit_user');
('审计权限', @content_type_id, 'audit_user');

-- 在线查询下载权限
set @content_type_id=(select id from django_content_type where app_label='sql' and model='permission');
insert IGNORE INTO auth_permission (name, content_type_id, codename) VALUES
('在线查询下载权限', @content_type_id, 'query_download');

0 comments on commit 360d052

Please sign in to comment.