perf(orgs): 默认组织改为实体组织,并支持全局组织 (#5617)

* perf(orgs): 默认组织改为实体组织

* perf: 添加获取当前组织信息的api

* perf: 资产列表在 root 组织下的表现

* fix: 修复 root 组织引起的问题

* perf: 优化OrgModelMixin save; org_root获取; org_roles获取; UserCanUseCurrentOrg权限类

Co-authored-by: ibuler <ibuler@qq.com>
Co-authored-by: Bai <bugatti_it@163.com>
This commit is contained in:
fit2bot
2021-03-02 14:57:48 +08:00
committed by GitHub
parent 51c9a89b1f
commit a56ac7b34e
19 changed files with 381 additions and 298 deletions

View File

@@ -110,12 +110,17 @@ class PermissionsMixin(UserPassesTestMixin):
return True
class UserCanUpdatePassword:
class UserCanUseCurrentOrg(permissions.BasePermission):
def has_permission(self, request, view):
return current_org.can_use_by(request.user)
class UserCanUpdatePassword(permissions.BasePermission):
def has_permission(self, request, view):
return request.user.can_update_password()
class UserCanUpdateSSHKey:
class UserCanUpdateSSHKey(permissions.BasePermission):
def has_permission(self, request, view):
return request.user.can_update_ssh_key()