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

调整资源组和实例标签的多对多模型,使用Django默认的中间表 #620

Merged
merged 2 commits into from
Feb 5, 2020

Conversation

hhyo
Copy link
Owner

@hhyo hhyo commented Feb 5, 2020

相关pr:#162 #208

调整模型配置,多对多的选择和权限组一致,配置更方便,也可以避免关联项过多时出现的效率问题

@hhyo hhyo added ease of use enhancement New feature or request labels Feb 5, 2020
@codecov
Copy link

codecov bot commented Feb 5, 2020

Codecov Report

Merging #620 into master will decrease coverage by 0.1%.
The diff coverage is 77.5%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #620      +/-   ##
=========================================
- Coverage   82.01%   81.9%   -0.11%     
=========================================
  Files          77      77              
  Lines       10362   10317      -45     
=========================================
- Hits         8498    8450      -48     
- Misses       1864    1867       +3
Impacted Files Coverage Δ
sql/instance.py 46.69% <0%> (ø) ⬆️
common/auth.py 68.69% <100%> (ø) ⬆️
sql/utils/tests.py 98.93% <100%> (-0.01%) ⬇️
sql/utils/sql_review.py 90.1% <100%> (ø) ⬆️
sql/admin.py 97.32% <100%> (-0.3%) ⬇️
common/tests.py 100% <100%> (ø) ⬆️
sql/tests.py 100% <100%> (ø) ⬆️
sql/resource_group.py 14.68% <6.66%> (-0.32%) ⬇️
sql/utils/resource_group.py 86.95% <80%> (-0.55%) ⬇️
sql/models.py 97.71% <93.75%> (-0.13%) ⬇️

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 52f5533...977176a. Read the comment docs.

@LeoQuote
Copy link
Collaborator

LeoQuote commented Feb 5, 2020

可以, 舒服了, 我记得之前提过一个issue ?

@LeoQuote
Copy link
Collaborator

LeoQuote commented Feb 5, 2020

Archery/sql/utils/tests.py

Lines 1030 to 1055 in 52f5533

@patch('sql.utils.workflow_audit.auth_group_users')
@patch('sql.utils.workflow_audit.Audit.detail_by_workflow_id')
def test_can_review_no_prem(self, _detail_by_workflow_id, _auth_group_users):
"""测试判断用户当前是否是可审核,普通用户无权限"""
aug = Group.objects.create(name='auth_group')
_detail_by_workflow_id.return_value.current_audit = aug.id
_auth_group_users.return_value.filter.exists = True
self.audit.workflow_type = WorkflowDict.workflow_type['sqlreview']
self.audit.workflow_id = self.wf.id
self.audit.save()
r = Audit.can_review(self.user, self.audit.workflow_id, self.audit.workflow_type)
self.assertEqual(r, False)
@patch('sql.utils.workflow_audit.auth_group_users')
@patch('sql.utils.workflow_audit.Audit.detail_by_workflow_id')
def test_can_review_no_prem(self, _detail_by_workflow_id, _auth_group_users):
"""测试判断用户当前是否是可审核,权限组不存在"""
Group.objects.create(name='auth_group')
_detail_by_workflow_id.side_effect = RuntimeError()
_auth_group_users.return_value.filter.exists = True
self.audit.workflow_type = WorkflowDict.workflow_type['sqlreview']
self.audit.workflow_id = self.wf.id
self.audit.save()
with self.assertRaisesMessage(Exception, '当前审批auth_group_id不存在,请检查并清洗历史数据'):
Audit.can_review(self.user, self.audit.workflow_id, self.audit.workflow_type)

1030 行这个函数和下面的重复了


# 获取关联数据
resource_group = ResourceGroup.objects.get(group_id=group_id)
rows_users = resource_group.users_set.all().filter()
Copy link
Owner Author

Choose a reason for hiding this comment

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

删除.filter()

@@ -21,20 +21,17 @@ class UsersAdmin(UserAdmin):
('认证信息', {'fields': ('username', 'password')}),
('个人信息', {'fields': ('display', 'email', 'ding_user_id', 'wx_user_id')}),
('权限信息', {'fields': ('is_superuser', 'is_active', 'is_staff', 'groups', 'user_permissions')}),
('其他信息', {'fields': ('date_joined',)}),
Copy link
Owner Author

Choose a reason for hiding this comment

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

这个可以在页面显示

@hhyo
Copy link
Owner Author

hhyo commented Feb 5, 2020

可以, 舒服了, 我记得之前提过一个issue ?

issue好像没提过, @yyukai 做过类似的修改

@hhyo hhyo merged commit 8e33476 into master Feb 5, 2020
@hhyo hhyo deleted the feature/manytomany branch March 21, 2020 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ease of use enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants