fix: 修复组织管理员查看操作日志可以看到 system 组织下的操作问题, 只有系统管理员可以查看任务监控

pull/9887/head
Bai 2023-03-08 15:01:05 +08:00 committed by Jiangjie.Bai
parent 21352a2ab7
commit 6bbe602ebb
3 changed files with 4 additions and 4 deletions

View File

@ -149,7 +149,7 @@ class OperateLogViewSet(OrgReadonlyModelViewSet):
return super().get_serializer_class() return super().get_serializer_class()
def get_queryset(self): def get_queryset(self):
org_q = Q(org_id=Organization.SYSTEM_ID) | Q(org_id=current_org.id) org_q = Q(org_id=current_org.id)
with tmp_to_root_org(): with tmp_to_root_org():
qs = OperateLog.objects.filter(org_q) qs = OperateLog.objects.filter(org_q)
es_config = settings.OPERATE_LOG_ELASTICSEARCH_CONFIG es_config = settings.OPERATE_LOG_ELASTICSEARCH_CONFIG

View File

@ -2,7 +2,7 @@
# #
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from rest_framework import serializers from rest_framework import serializers
from orgs.mixins.serializers import BulkOrgResourceModelSerializer
from audits.backends.db import OperateLogStore from audits.backends.db import OperateLogStore
from common.serializers.fields import LabeledChoiceField from common.serializers.fields import LabeledChoiceField
from common.utils import reverse, i18n_trans from common.utils import reverse, i18n_trans
@ -78,7 +78,7 @@ class OperateLogActionDetailSerializer(serializers.ModelSerializer):
return data return data
class OperateLogSerializer(serializers.ModelSerializer): class OperateLogSerializer(BulkOrgResourceModelSerializer):
action = LabeledChoiceField(choices=ActionChoices.choices, label=_("Action")) action = LabeledChoiceField(choices=ActionChoices.choices, label=_("Action"))
resource = serializers.SerializerMethodField(label=_("Resource")) resource = serializers.SerializerMethodField(label=_("Resource"))
resource_type = serializers.SerializerMethodField(label=_('Resource Type')) resource_type = serializers.SerializerMethodField(label=_('Resource Type'))

View File

@ -135,7 +135,7 @@ only_system_permissions = (
('xpack', 'license', '*', '*'), ('xpack', 'license', '*', '*'),
('settings', 'setting', '*', '*'), ('settings', 'setting', '*', '*'),
('tickets', '*', '*', '*'), ('tickets', '*', '*', '*'),
('ops', 'task', 'view', 'taskmonitor'), ('ops', 'celerytask', 'view', 'taskmonitor'),
('terminal', 'terminal', '*', '*'), ('terminal', 'terminal', '*', '*'),
('terminal', 'commandstorage', '*', '*'), ('terminal', 'commandstorage', '*', '*'),
('terminal', 'replaystorage', '*', '*'), ('terminal', 'replaystorage', '*', '*'),