From 3080bf3647afe0872dfc4482d4d6a1497c69dc68 Mon Sep 17 00:00:00 2001 From: xinwen Date: Fri, 12 Mar 2021 18:40:24 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=95=B4=E4=B8=AA=E6=8E=88=E6=9D=83=E6=A0=91=E7=BC=BA=E5=B0=91?= =?UTF-8?q?=E8=8A=82=E7=82=B9=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/perms/utils/asset/user_permission.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/perms/utils/asset/user_permission.py b/apps/perms/utils/asset/user_permission.py index e638c7d64..739a4191e 100644 --- a/apps/perms/utils/asset/user_permission.py +++ b/apps/perms/utils/asset/user_permission.py @@ -611,12 +611,12 @@ class UserGrantedNodesQueryUtils(UserGrantedUtilsBase): for node in nodes: node.use_granted_assets_amount() + key_to_node_mapper[node.key] = node if node.node_from == NodeFrom.granted: # 直接授权的节点 # 增加查询后代节点的过滤条件 nodes_descendant_q |= Q(key__startswith=f'{node.key}:') - key_to_node_mapper[node.key] = node if nodes_descendant_q: descendant_nodes = PermNode.objects.filter( From ff9e470ce296d0c3365c01011eb2cf93ce967913 Mon Sep 17 00:00:00 2001 From: xinwen Date: Fri, 12 Mar 2021 19:05:59 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E5=91=BD=E4=BB=A4=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=20500?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/ops/models/command.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/ops/models/command.py b/apps/ops/models/command.py index 80a26be70..0a2012e73 100644 --- a/apps/ops/models/command.py +++ b/apps/ops/models/command.py @@ -9,11 +9,11 @@ from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext from django.db import models -from terminal.models import Command from terminal.utils import send_command_execution_alert_mail from common.utils import lazyproperty from orgs.models import Organization from orgs.mixins.models import OrgModelMixin +from orgs.utils import current_org, tmp_to_org from ..ansible.runner import CommandRunner from ..inventory import JMSInventory @@ -33,6 +33,10 @@ class CommandExecution(OrgModelMixin): def __str__(self): return self.command[:10] + def save(self, *args, **kwargs): + with tmp_to_org(self.run_as.org_id): + super().save(*args, **kwargs) + @property def inventory(self): if self.run_as.username_same_with_user: