From ffc057f844a85cac63ab5c0596eb2f96dc0ceb1f Mon Sep 17 00:00:00 2001 From: fit2bot <68588906+fit2bot@users.noreply.github.com> Date: Fri, 13 Oct 2023 15:33:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B4=A6=E5=8F=B7=E6=94=B9=E5=AF=86-?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E5=88=97=E8=A1=A8-=E8=AF=A6=E6=83=85-?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E8=AE=B0=E5=BD=95=EF=BC=9A=E6=A8=A1=E7=B3=8A?= =?UTF-8?q?=E6=90=9C=E7=B4=A2500=20(#11835)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: feng <1304903146@qq.com> --- apps/accounts/api/automations/change_secret.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/apps/accounts/api/automations/change_secret.py b/apps/accounts/api/automations/change_secret.py index 2af9afd09..e334403f5 100644 --- a/apps/accounts/api/automations/change_secret.py +++ b/apps/accounts/api/automations/change_secret.py @@ -5,8 +5,7 @@ from rest_framework import mixins from accounts import serializers from accounts.const import AutomationTypes -from accounts.models import ChangeSecretAutomation, ChangeSecretRecord, AutomationExecution -from common.utils import get_object_or_none +from accounts.models import ChangeSecretAutomation, ChangeSecretRecord from orgs.mixins.api import OrgBulkModelViewSet, OrgGenericViewSet from .base import ( AutomationAssetsListApi, AutomationRemoveAssetApi, AutomationAddAssetApi, @@ -30,8 +29,8 @@ class ChangeSecretAutomationViewSet(OrgBulkModelViewSet): class ChangeSecretRecordViewSet(mixins.ListModelMixin, OrgGenericViewSet): serializer_class = serializers.ChangeSecretRecordSerializer - filter_fields = ['asset', 'execution_id'] - search_fields = ['asset__hostname'] + filter_fields = ('asset', 'execution_id') + search_fields = ('asset__address',) def get_queryset(self): return ChangeSecretRecord.objects.filter( @@ -41,10 +40,7 @@ class ChangeSecretRecordViewSet(mixins.ListModelMixin, OrgGenericViewSet): def filter_queryset(self, queryset): queryset = super().filter_queryset(queryset) eid = self.request.query_params.get('execution_id') - execution = get_object_or_none(AutomationExecution, pk=eid) - if execution: - queryset = queryset.filter(execution=execution) - return queryset + return queryset.filter(execution_id=eid) class ChangSecretExecutionViewSet(AutomationExecutionViewSet):