diff --git a/apps/audits/signal_handlers/operate_log.py b/apps/audits/signal_handlers/operate_log.py index 4fa0e12c2..21a13d158 100644 --- a/apps/audits/signal_handlers/operate_log.py +++ b/apps/audits/signal_handlers/operate_log.py @@ -14,7 +14,7 @@ from audits.handler import ( create_or_update_operate_log, get_instance_dict_from_cache ) from audits.utils import model_to_dict_for_operate_log as model_to_dict -from common.const.signals import POST_ADD, POST_REMOVE, POST_CLEAR, SKIP_SIGNAL +from common.const.signals import POST_ADD, POST_REMOVE, POST_CLEAR, OP_LOG_SKIP_SIGNAL from common.signals import django_ready from jumpserver.utils import current_request from ..const import MODELS_NEED_RECORD, ActionChoices @@ -77,7 +77,7 @@ def signal_of_operate_log_whether_continue( condition = True if not instance: condition = False - if instance and getattr(instance, SKIP_SIGNAL, False): + if instance and getattr(instance, OP_LOG_SKIP_SIGNAL, False): condition = False # 不记录组件的操作日志 user = current_request.user if current_request else None diff --git a/apps/common/const/signals.py b/apps/common/const/signals.py index 78117ef13..cace35ab1 100644 --- a/apps/common/const/signals.py +++ b/apps/common/const/signals.py @@ -16,4 +16,4 @@ POST_CLEAR = 'post_clear' POST_PREFIX = 'post' PRE_PREFIX = 'pre' -SKIP_SIGNAL = 'skip_signal' +OP_LOG_SKIP_SIGNAL = 'operate_log_skip_signal' diff --git a/apps/common/db/models.py b/apps/common/db/models.py index a3d51bcb7..2ed3c936a 100644 --- a/apps/common/db/models.py +++ b/apps/common/db/models.py @@ -17,7 +17,7 @@ from django.db.models import F, ExpressionWrapper, CASCADE from django.db.models import QuerySet from django.utils.translation import gettext_lazy as _ -from ..const.signals import SKIP_SIGNAL +from ..const.signals import OP_LOG_SKIP_SIGNAL class ChoicesMixin: @@ -82,7 +82,7 @@ def CASCADE_SIGNAL_SKIP(collector, field, sub_objs, using): # 级联删除时,操作日志标记不保存,以免用户混淆 try: for obj in sub_objs: - setattr(obj, SKIP_SIGNAL, True) + setattr(obj, OP_LOG_SKIP_SIGNAL, True) except: pass diff --git a/apps/terminal/models/component/terminal.py b/apps/terminal/models/component/terminal.py index 8666c5da2..72123ed43 100644 --- a/apps/terminal/models/component/terminal.py +++ b/apps/terminal/models/component/terminal.py @@ -5,7 +5,7 @@ from django.core.cache import cache from django.db import models from django.utils.translation import gettext_lazy as _ -from common.const.signals import SKIP_SIGNAL +from common.const.signals import OP_LOG_SKIP_SIGNAL from common.db.models import JMSBaseModel from common.utils import get_logger, lazyproperty from orgs.utils import tmp_to_root_org @@ -152,7 +152,7 @@ class Terminal(StorageMixin, TerminalStatusMixin, JMSBaseModel): def delete(self, using=None, keep_parents=False): if self.user: - setattr(self.user, SKIP_SIGNAL, True) + setattr(self.user, OP_LOG_SKIP_SIGNAL, True) self.user.delete() self.name = self.name + '_' + uuid.uuid4().hex[:8] self.user = None diff --git a/apps/terminal/models/session/session.py b/apps/terminal/models/session/session.py index 388250419..b2ec89f7b 100644 --- a/apps/terminal/models/session/session.py +++ b/apps/terminal/models/session/session.py @@ -12,6 +12,7 @@ from django.utils import timezone from django.utils.translation import gettext_lazy as _ from assets.models import Asset +from common.const import OP_LOG_SKIP_SIGNAL from common.utils import get_object_or_none, lazyproperty from orgs.mixins.models import OrgModelMixin from terminal.backends import get_multi_command_storage @@ -203,6 +204,7 @@ class Session(OrgModelMixin): if self.need_update_cmd_amount: cmd_amount = self.compute_command_amount() self.cmd_amount = cmd_amount + setattr(self, OP_LOG_SKIP_SIGNAL, True) self.save() elif self.need_compute_cmd_amount: cmd_amount = self.compute_command_amount()