From bbddf6a342ffcad5254ea0fc3823809609615702 Mon Sep 17 00:00:00 2001 From: Bai Date: Wed, 8 Mar 2023 15:54:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=BB=84=E7=BB=87?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E6=9F=A5=E7=9C=8B=E6=B4=BB=E5=8A=A8?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E8=AF=A6=E6=83=85=E6=97=B6=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E5=AF=B9=E8=B1=A1=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/audits/api.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/audits/api.py b/apps/audits/api.py index 3bf010ba4..b672d8bad 100644 --- a/apps/audits/api.py +++ b/apps/audits/api.py @@ -10,6 +10,7 @@ from rest_framework.permissions import IsAuthenticated from common.drf.filters import DatetimeRangeFilter from common.plugins.es import QuerySet as ESQuerySet from common.utils import is_uuid +from common.utils import lazyproperty from orgs.mixins.api import OrgReadonlyModelViewSet, OrgModelViewSet from orgs.utils import current_org, tmp_to_root_org from orgs.models import Organization @@ -143,13 +144,19 @@ class OperateLogViewSet(OrgReadonlyModelViewSet): search_fields = ['resource', 'user'] ordering = ['-datetime'] + @lazyproperty + def is_action_detail(self): + return self.detail and self.request.query_params.get('type') == 'action_detail' + def get_serializer_class(self): - if self.request.query_params.get('type') == 'action_detail': + if self.is_action_detail: return OperateLogActionDetailSerializer return super().get_serializer_class() def get_queryset(self): org_q = Q(org_id=current_org.id) + if self.is_action_detail: + org_q |= Q(org_id=Organization.SYSTEM_ID) with tmp_to_root_org(): qs = OperateLog.objects.filter(org_q) es_config = settings.OPERATE_LOG_ELASTICSEARCH_CONFIG