perf: 修复一些bug, rolebingding 找到合适的

pull/7876/head
ibuler 2022-03-16 12:01:51 +08:00 committed by 老广
parent 5ec970fab4
commit 995c9a6c19
4 changed files with 8 additions and 9 deletions

View File

@ -14,7 +14,7 @@ __all__ = ['celery_flower_view']
@csrf_exempt
def celery_flower_view(request, path):
if not request.user.is_superuser:
if not request.user.has_perm('ops.view_taskmonitor'):
return HttpResponse("Forbidden")
remote_url = 'http://{}/{}'.format(flower_url, path)
try:

View File

@ -3111,15 +3111,15 @@ msgstr "如果有疑问或需求,请联系系统管理员"
#: rbac/api/role.py:32
msgid "Internal role, can't be destroy"
msgstr ""
msgstr "内部角色,不能删除"
#: rbac/api/role.py:36
msgid "The role has been bound to users, can't be destroy"
msgstr ""
msgstr "角色已绑定用户,不能删除"
#: rbac/api/role.py:43
msgid "Internal role, can't be update"
msgstr ""
msgstr "内部角色,不能更新"
#: rbac/api/rolebinding.py:46
msgid "{} at least one system role"

View File

@ -102,7 +102,8 @@ only_system_permissions = (
('terminal', 'replaystorage', '*', '*'),
('terminal', 'status', '*', '*'),
('terminal', 'task', '*', '*'),
('tickets', 'ticketflow', '*', '*'),
('tickets', '*', '*', '*'),
('authentication', '*', '*', '*'),
)
only_org_permissions = (

View File

@ -15,11 +15,9 @@ __all__ = ['RoleBinding', 'SystemRoleBinding', 'OrgRoleBinding']
class RoleBindingManager(models.Manager):
def get_queryset(self):
queryset = super(RoleBindingManager, self).get_queryset()
q = Q(scope=Scope.system)
if not current_org.is_root():
q = Q(scope=Scope.system) | Q(org_id=current_org.id, scope=Scope.org)
else:
q = Q()
q |= Q(org_id=current_org.id, scope=Scope.org)
queryset = queryset.filter(q)
return queryset