mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-10 20:00:10 +00:00
perf: 修改 CommandFilterACL, CommandGroup Model 的 Meta 内部类; 修改 Command Model 的 system_user -> account 字段; 修改 ConnectionToken 的 command_filter_acls 返回字段;
This commit is contained in:
@@ -8,7 +8,7 @@ from django.utils.translation import ugettext_lazy as _
|
||||
from common.utils import lazyproperty, get_logger
|
||||
from orgs.mixins.models import JMSOrgBaseModel
|
||||
|
||||
from .base import UserAssetAccountBaseACL, UserAssetAccountACLQuerySet, ACLManager
|
||||
from .base import UserAssetAccountBaseACL
|
||||
|
||||
logger = get_logger(__file__)
|
||||
|
||||
@@ -94,23 +94,11 @@ class CommandGroup(JMSOrgBaseModel):
|
||||
return '{} % {}'.format(self.name, self.type)
|
||||
|
||||
|
||||
class CommandFilterACLQuerySet(UserAssetAccountACLQuerySet):
|
||||
def get_command_groups(self):
|
||||
ids = self.values_list('id', flat=True)
|
||||
queryset = CommandFilterACL.command_groups.through.objects.filter(commandfilteracl_id__in=ids)
|
||||
cmd_group_ids = queryset.values_list('commandgroup_id', flat=True)
|
||||
command_groups = CommandGroup.objects.filter(id__in=cmd_group_ids)
|
||||
return command_groups
|
||||
|
||||
|
||||
class CommandFilterACL(UserAssetAccountBaseACL):
|
||||
command_groups = models.ManyToManyField(CommandGroup, verbose_name=_('Commands'))
|
||||
|
||||
objects = ACLManager.from_queryset(CommandFilterACLQuerySet)()
|
||||
|
||||
class Meta:
|
||||
unique_together = ('name', 'org_id')
|
||||
ordering = ('priority', '-date_updated', 'name')
|
||||
class Meta(UserAssetAccountBaseACL.Meta):
|
||||
abstract = False
|
||||
verbose_name = _('Command acl')
|
||||
|
||||
def __str__(self):
|
||||
|
Reference in New Issue
Block a user