fix: 账号改密-执行列表-详情-任务记录:模糊搜索500 (#11835)

Co-authored-by: feng <1304903146@qq.com>
pull/11837/head
fit2bot 1 year ago committed by GitHub
parent 588723a76c
commit ffc057f844
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -5,8 +5,7 @@ from rest_framework import mixins
from accounts import serializers from accounts import serializers
from accounts.const import AutomationTypes from accounts.const import AutomationTypes
from accounts.models import ChangeSecretAutomation, ChangeSecretRecord, AutomationExecution from accounts.models import ChangeSecretAutomation, ChangeSecretRecord
from common.utils import get_object_or_none
from orgs.mixins.api import OrgBulkModelViewSet, OrgGenericViewSet from orgs.mixins.api import OrgBulkModelViewSet, OrgGenericViewSet
from .base import ( from .base import (
AutomationAssetsListApi, AutomationRemoveAssetApi, AutomationAddAssetApi, AutomationAssetsListApi, AutomationRemoveAssetApi, AutomationAddAssetApi,
@ -30,8 +29,8 @@ class ChangeSecretAutomationViewSet(OrgBulkModelViewSet):
class ChangeSecretRecordViewSet(mixins.ListModelMixin, OrgGenericViewSet): class ChangeSecretRecordViewSet(mixins.ListModelMixin, OrgGenericViewSet):
serializer_class = serializers.ChangeSecretRecordSerializer serializer_class = serializers.ChangeSecretRecordSerializer
filter_fields = ['asset', 'execution_id'] filter_fields = ('asset', 'execution_id')
search_fields = ['asset__hostname'] search_fields = ('asset__address',)
def get_queryset(self): def get_queryset(self):
return ChangeSecretRecord.objects.filter( return ChangeSecretRecord.objects.filter(
@ -41,10 +40,7 @@ class ChangeSecretRecordViewSet(mixins.ListModelMixin, OrgGenericViewSet):
def filter_queryset(self, queryset): def filter_queryset(self, queryset):
queryset = super().filter_queryset(queryset) queryset = super().filter_queryset(queryset)
eid = self.request.query_params.get('execution_id') eid = self.request.query_params.get('execution_id')
execution = get_object_or_none(AutomationExecution, pk=eid) return queryset.filter(execution_id=eid)
if execution:
queryset = queryset.filter(execution=execution)
return queryset
class ChangSecretExecutionViewSet(AutomationExecutionViewSet): class ChangSecretExecutionViewSet(AutomationExecutionViewSet):

Loading…
Cancel
Save