From 21323b657840f14bd3323d2e0c173ca5389a494d Mon Sep 17 00:00:00 2001 From: feng <1304903146@qq.com> Date: Wed, 11 Dec 2024 16:04:53 +0800 Subject: [PATCH] perf: The entire organization can view activity log --- apps/audits/api.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/audits/api.py b/apps/audits/api.py index 2bf3a0a00..cb918462f 100644 --- a/apps/audits/api.py +++ b/apps/audits/api.py @@ -187,9 +187,13 @@ class ResourceActivityAPIView(generics.ListAPIView): 'id', 'datetime', 'r_detail', 'r_detail_id', 'r_user', 'r_action', 'r_type' ) - org_q = Q(org_id=Organization.SYSTEM_ID) | Q(org_id=current_org.id) - if resource_id: - org_q |= Q(org_id='') | Q(org_id=Organization.ROOT_ID) + + org_q = Q() + if not current_org.is_root(): + org_q = Q(org_id=Organization.SYSTEM_ID) | Q(org_id=current_org.id) + if resource_id: + org_q |= Q(org_id='') | Q(org_id=Organization.ROOT_ID) + with tmp_to_root_org(): qs1 = self.get_operate_log_qs(fields, limit, org_q, resource_id=resource_id) qs2 = self.get_activity_log_qs(fields, limit, org_q, resource_id=resource_id)