From ff9e470ce296d0c3365c01011eb2cf93ce967913 Mon Sep 17 00:00:00 2001 From: xinwen Date: Fri, 12 Mar 2021 19:05:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=91=BD=E4=BB=A4=E6=89=A7=E8=A1=8C=205?= =?UTF-8?q?00?= 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: