Merge pull request #5739 from jumpserver/dev

v2.8 发版 (2)
pull/5813/head
Jiangjie.Bai 2021-03-12 20:56:23 +08:00 committed by GitHub
commit 2e1763cce7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -9,11 +9,11 @@ from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ugettext from django.utils.translation import ugettext
from django.db import models from django.db import models
from terminal.models import Command
from terminal.utils import send_command_execution_alert_mail from terminal.utils import send_command_execution_alert_mail
from common.utils import lazyproperty from common.utils import lazyproperty
from orgs.models import Organization from orgs.models import Organization
from orgs.mixins.models import OrgModelMixin from orgs.mixins.models import OrgModelMixin
from orgs.utils import current_org, tmp_to_org
from ..ansible.runner import CommandRunner from ..ansible.runner import CommandRunner
from ..inventory import JMSInventory from ..inventory import JMSInventory
@ -33,6 +33,10 @@ class CommandExecution(OrgModelMixin):
def __str__(self): def __str__(self):
return self.command[:10] return self.command[:10]
def save(self, *args, **kwargs):
with tmp_to_org(self.run_as.org_id):
super().save(*args, **kwargs)
@property @property
def inventory(self): def inventory(self):
if self.run_as.username_same_with_user: if self.run_as.username_same_with_user:

View File

@ -611,12 +611,12 @@ class UserGrantedNodesQueryUtils(UserGrantedUtilsBase):
for node in nodes: for node in nodes:
node.use_granted_assets_amount() node.use_granted_assets_amount()
key_to_node_mapper[node.key] = node
if node.node_from == NodeFrom.granted: if node.node_from == NodeFrom.granted:
# 直接授权的节点 # 直接授权的节点
# 增加查询后代节点的过滤条件 # 增加查询后代节点的过滤条件
nodes_descendant_q |= Q(key__startswith=f'{node.key}:') nodes_descendant_q |= Q(key__startswith=f'{node.key}:')
key_to_node_mapper[node.key] = node
if nodes_descendant_q: if nodes_descendant_q:
descendant_nodes = PermNode.objects.filter( descendant_nodes = PermNode.objects.filter(