Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加下载的权限(hhyo#1367) #1369

Merged
merged 5 commits into from
Feb 12, 2022
Merged

增加下载的权限(hhyo#1367) #1369

merged 5 commits into from
Feb 12, 2022

Conversation

weideguo
Copy link
Collaborator

@weideguo weideguo commented Feb 8, 2022

虽然限制前端的下载功能没有什么实质的意义,但似乎有人有这要求。

@codecov
Copy link

codecov bot commented Feb 8, 2022

Codecov Report

Merging #1369 (c8f5a31) into master (0abcd43) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1369   +/-   ##
=======================================
  Coverage   75.39%   75.39%           
=======================================
  Files          81       81           
  Lines       12616    12616           
=======================================
  Hits         9512     9512           
  Misses       3104     3104           
Impacted Files Coverage Δ
sql/models.py 95.64% <ø> (ø)
sql/views.py 68.68% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0abcd43...c8f5a31. Read the comment docs.

Copy link
Collaborator

@LeoQuote LeoQuote left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

变量名可以改一下,改成 can_download,感谢贡献

sql/views.py Outdated
@@ -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})
is_download = 1 if user.has_perm('sql.download') or user.is_superuser else 0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
is_download = 1 if user.has_perm('sql.download') or user.is_superuser else 0
can_download = 1 if user.has_perm('sql.download') or user.is_superuser else 0

变量改成 can_download 更精准一点

@@ -781,11 +782,12 @@ <h4 class="modal-title text-danger">收藏语句</h4>
if (optgroup == 'Mongo') {
isdetail = true
}
var showExport = {{is_download}}==1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

三个等于号?

sql/models.py Outdated
@@ -730,6 +730,7 @@ class Meta:
('archive_review', '审核归档申请'),
('archive_mgt', '管理归档申请'),
('audit_user','审计权限'),
('download', '在线查询下载权限'),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

query_download ,你觉得这个名字怎么样


-- 在线查询下载权限
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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议逻辑保持一致,给默认用户组授予权限,不需要的可以主动剔除

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-- 默认组拥有在线查询下载权限
insert into auth_group_permissions (group_id, permission_id) select 1,id from auth_permission where 
name='在线查询下载权限' and content_type_id=@content_type_id and codename='query_download';

添加这样语句?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

对,不过也不一定用户都是用的这个默认组,不好确认,后续这边在release note中说明下好了

@hbbdgyb
Copy link

hbbdgyb commented Feb 11, 2022

大佬666

@@ -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})
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里需要调整下,判断的download,写入的定义是query_download😬

@feiazifeiazi
Copy link
Contributor

很需要这个权限控制。感谢。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants