From 9e47bf6ec515201bf1065c3cd75da325c3538a96 Mon Sep 17 00:00:00 2001 From: feng626 <1304903146@qq.com> Date: Wed, 19 Jan 2022 19:21:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=89=B9=E9=87=8F=E5=91=BD=E4=BB=A4bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/assets/models/user.py | 1 + apps/ops/models/command.py | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/assets/models/user.py b/apps/assets/models/user.py index 7b0df464b..50ca5389b 100644 --- a/apps/assets/models/user.py +++ b/apps/assets/models/user.py @@ -5,6 +5,7 @@ import logging from django.db import models +from django.db.models import Q from django.utils.translation import ugettext_lazy as _ from django.core.validators import MinValueValidator, MaxValueValidator from django.core.cache import cache diff --git a/apps/ops/models/command.py b/apps/ops/models/command.py index 61504d782..81f9ce9e9 100644 --- a/apps/ops/models/command.py +++ b/apps/ops/models/command.py @@ -38,6 +38,7 @@ class CommandExecution(OrgModelMixin): 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: username = self.user.username @@ -105,7 +106,7 @@ class CommandExecution(OrgModelMixin): return allow_assets def run(self): - print('-'*10 + ' ' + ugettext('Task start') + ' ' + '-'*10) + print('-' * 10 + ' ' + ugettext('Task start') + ' ' + '-' * 10) org = Organization.get_instance(self.run_as.org_id) org.change_to() self.date_start = timezone.now() @@ -117,7 +118,7 @@ class CommandExecution(OrgModelMixin): print(f'资产{asset}: 命令{self.command}不允许执行') if not allow_assets: self.result = { - "error": _('There are currently no assets that can be executed') + "error": 'There are currently no assets that can be executed' } self.save() return self.result @@ -147,10 +148,10 @@ class CommandExecution(OrgModelMixin): 'user': str(self.user), 'risk_level': 5, }).publish_async() - self.result = {"error": msg} + self.result = {"error": msg} self.org_id = self.run_as.org_id self.is_finished = True self.date_finished = timezone.now() self.save() - print('-'*10 + ' ' + ugettext('Task end') + ' ' + '-'*10) + print('-' * 10 + ' ' + ugettext('Task end') + ' ' + '-' * 10) return self.result