From 19493767e10768f6ad4e92a77720bf38786fb4e5 Mon Sep 17 00:00:00 2001 From: bidaya0 Date: Fri, 24 Feb 2023 16:54:49 +0800 Subject: [PATCH] fix: hook rule goblal. --- dongtai_protocol/views/hook_profilesv2.py | 1 - dongtai_web/views/engine_hook_rule_modify.py | 8 ++------ .../views/engine_hook_rule_type_disable.py | 2 +- dongtai_web/views/engine_hook_rule_type_enable.py | 2 +- dongtai_web/views/engine_hook_rules.py | 15 ++++----------- 5 files changed, 8 insertions(+), 20 deletions(-) diff --git a/dongtai_protocol/views/hook_profilesv2.py b/dongtai_protocol/views/hook_profilesv2.py index ed2463ee0..d90302e18 100644 --- a/dongtai_protocol/views/hook_profilesv2.py +++ b/dongtai_protocol/views/hook_profilesv2.py @@ -34,7 +34,6 @@ def get_profiles(user=None, language_id=JAVA): if isinstance(hook_type, IastStrategyModel): hook_type = convert_strategy(hook_type) strategies = hook_type.strategies.filter( - created_by__in=[1, user.id] if user else [1], type__in=(1, 2, 3) if not isinstance(hook_type, IastStrategyModel) else [4], enable=const.HOOK_TYPE_ENABLE, diff --git a/dongtai_web/views/engine_hook_rule_modify.py b/dongtai_web/views/engine_hook_rule_modify.py index 9e45285ff..84ecfb245 100644 --- a/dongtai_web/views/engine_hook_rule_modify.py +++ b/dongtai_web/views/engine_hook_rule_modify.py @@ -84,19 +84,15 @@ def parse_args(self, request): def post(self, request): rule_id, rule_type, rule_value, rule_source, rule_target, inherit, is_track = self.parse_args(request) strategy = HookStrategy.objects.filter( - id=rule_id, created_by=request.user.id).first() + id=rule_id).first() if not strategy: return R.failure(msg=_('No such hookstrategy.')) if strategy.type == 4: hook_type = IastStrategyModel.objects.filter( id=rule_type, - user_id__in=[request.user.id, const.SYSTEM_USER_ID], ).first() else: - hook_type = HookType.objects.filter( - id=rule_type, - created_by__in=(request.user.id, - const.SYSTEM_USER_ID)).first() + hook_type = HookType.objects.filter(id=rule_type, ).first() if all((rule_id, rule_type, rule_value, rule_source, inherit, is_track, strategy)) is False: diff --git a/dongtai_web/views/engine_hook_rule_type_disable.py b/dongtai_web/views/engine_hook_rule_type_disable.py index ef125bf60..4d2bcb0ce 100644 --- a/dongtai_web/views/engine_hook_rule_type_disable.py +++ b/dongtai_web/views/engine_hook_rule_type_disable.py @@ -47,7 +47,7 @@ def get(self, request): if rule_id is None: return R.failure(msg=_('Strategy does not exist')) - rule = HookStrategy.objects.filter(id=rule_id, created_by=request.user.id).first() + rule = HookStrategy.objects.filter(id=rule_id).first() if rule: rule_type = rule.type.first() if rule_type: diff --git a/dongtai_web/views/engine_hook_rule_type_enable.py b/dongtai_web/views/engine_hook_rule_type_enable.py index 327488fe5..8d4d62d43 100644 --- a/dongtai_web/views/engine_hook_rule_type_enable.py +++ b/dongtai_web/views/engine_hook_rule_type_enable.py @@ -52,7 +52,7 @@ def get(self, request): if rule_id is None: return R.failure(msg=_('Strategy does not exist')) - rule = HookStrategy.objects.filter(id=rule_id, created_by=request.user.id).first() + rule = HookStrategy.objects.filter(id=rule_id).first() if rule: rule_type = rule.type.first() if rule_type: diff --git a/dongtai_web/views/engine_hook_rules.py b/dongtai_web/views/engine_hook_rules.py index e38294b85..1f37c9e3f 100644 --- a/dongtai_web/views/engine_hook_rules.py +++ b/dongtai_web/views/engine_hook_rules.py @@ -102,32 +102,25 @@ def get(self, request): if strategy_type: rule_type_queryset = IastStrategyModel.objects.filter( pk=strategy_type, - user_id__in=(user_id, const.SYSTEM_USER_ID), ) else: - rule_type_queryset = IastStrategyModel.objects.filter( - user_id__in=(user_id, const.SYSTEM_USER_ID), ) + rule_type_queryset = IastStrategyModel.objects.all() else: if strategy_type: rule_type_queryset = HookType.objects.filter( id=strategy_type, - created_by__in=(user_id, const.SYSTEM_USER_ID), type=rule_type, language_id=language_id) else: rule_type_queryset = HookType.objects.filter( - created_by__in=(user_id, const.SYSTEM_USER_ID), type=rule_type, language_id=language_id) if rule_type == 4: - q = Q(strategy__in=rule_type_queryset) & Q( - created_by=user_id) & Q( - enable__in=(const.ENABLE, const.DISABLE)) & Q( - language_id=language_id) + q = Q(strategy__in=rule_type_queryset) & Q(enable__in=( + const.ENABLE, const.DISABLE)) & Q(language_id=language_id) else: q = Q(hooktype__in=rule_type_queryset) & Q( - created_by=user_id) & Q(enable__in=(const.ENABLE, - const.DISABLE)) + enable__in=(const.ENABLE, const.DISABLE)) if keyword: q = Q(value__icontains=keyword) & q rule_queryset = HookStrategy.objects.filter(q)