fix: 批量命令bug

pull/7534/head
feng626 2022-01-19 19:21:50 +08:00 committed by Jiangjie.Bai
parent 89c7e514eb
commit 9e47bf6ec5
2 changed files with 6 additions and 4 deletions

View File

@ -5,6 +5,7 @@
import logging import logging
from django.db import models from django.db import models
from django.db.models import Q
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.core.validators import MinValueValidator, MaxValueValidator from django.core.validators import MinValueValidator, MaxValueValidator
from django.core.cache import cache from django.core.cache import cache

View File

@ -38,6 +38,7 @@ class CommandExecution(OrgModelMixin):
with tmp_to_org(self.run_as.org_id): with tmp_to_org(self.run_as.org_id):
super().save(*args, **kwargs) super().save(*args, **kwargs)
@property
def inventory(self): def inventory(self):
if self.run_as.username_same_with_user: if self.run_as.username_same_with_user:
username = self.user.username username = self.user.username
@ -117,7 +118,7 @@ class CommandExecution(OrgModelMixin):
print(f'资产{asset}: 命令{self.command}不允许执行') print(f'资产{asset}: 命令{self.command}不允许执行')
if not allow_assets: if not allow_assets:
self.result = { self.result = {
"error": _('There are currently no assets that can be executed') "error": 'There are currently no assets that can be executed'
} }
self.save() self.save()
return self.result return self.result