mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-10-20 07:19:03 +00:00
perf: 修改权限树 (#7757)
* perf: 修改 rbac tree * perf: 修改权限树 * perf: 修改用户默认权限 Co-authored-by: ibuler <ibuler@qq.com>
This commit is contained in:
@@ -7,6 +7,7 @@ from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from common.utils import lazyproperty
|
||||
from .base import BasePermission, Action
|
||||
from applications.models import Application
|
||||
from users.models import User
|
||||
from applications.const import AppCategory, AppType
|
||||
|
||||
@@ -36,12 +37,7 @@ class ApplicationPermission(BasePermission):
|
||||
unique_together = [('org_id', 'name')]
|
||||
verbose_name = _('Application permission')
|
||||
ordering = ('name',)
|
||||
permissions = [
|
||||
('view_myapps', _('Can view my apps')),
|
||||
('connect_myapps', _('Can connect my apps')),
|
||||
('view_userapps', _('Can view user apps')),
|
||||
('view_usergroupapps', _('Can view usergroup apps')),
|
||||
]
|
||||
|
||||
|
||||
@property
|
||||
def category_remote_app(self):
|
||||
@@ -106,3 +102,15 @@ class ApplicationPermission(BasePermission):
|
||||
include_choices = cls.get_include_actions_choices(category)
|
||||
exclude_choices = set(Action.NAME_MAP.values()) - set(include_choices)
|
||||
return exclude_choices
|
||||
|
||||
|
||||
class PermedApplication(Application):
|
||||
class Meta:
|
||||
proxy = True
|
||||
verbose_name = _("Permed app")
|
||||
permissions = [
|
||||
('view_myapps', _('Can view my apps')),
|
||||
('connect_myapps', _('Can connect my apps')),
|
||||
('view_userapps', _('Can view user apps')),
|
||||
('view_usergroupapps', _('Can view usergroup apps')),
|
||||
]
|
||||
|
@@ -28,12 +28,6 @@ class AssetPermission(BasePermission):
|
||||
unique_together = [('org_id', 'name')]
|
||||
verbose_name = _("Asset permission")
|
||||
ordering = ('name',)
|
||||
permissions = [
|
||||
('view_myassets', _('Can view my assets')),
|
||||
('connect_myassets', _('Can connect my assets')),
|
||||
('view_userassets', _('Can view user assets')),
|
||||
('view_usergroupassets', _('Can view usergroup assets')),
|
||||
]
|
||||
|
||||
@lazyproperty
|
||||
def users_amount(self):
|
||||
@@ -179,3 +173,16 @@ class PermNode(Node):
|
||||
def save(self):
|
||||
# 这是个只读 Model
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
class PermedAsset(Asset):
|
||||
class Meta:
|
||||
proxy = True
|
||||
verbose_name = _('Permed asset')
|
||||
permissions = [
|
||||
('view_myassets', _('Can view my assets')),
|
||||
('connect_myassets', _('Can connect my assets')),
|
||||
('view_userassets', _('Can view user assets')),
|
||||
('view_usergroupassets', _('Can view usergroup assets')),
|
||||
]
|
||||
|
||||
|
Reference in New Issue
Block a user