perf: Suggestion api

pull/15588/head
feng 2025-06-16 14:16:41 +08:00 committed by feng626
parent 89aa87fd6b
commit 48fa6172bd
1 changed files with 7 additions and 1 deletions

View File

@ -8,6 +8,7 @@ from rest_framework.request import Request
from rest_framework.response import Response
from common.const.http import POST
from orgs.models import Organization
from orgs.utils import current_org
__all__ = ['SuggestionMixin', 'RenderToJsonMixin']
@ -25,7 +26,12 @@ class SuggestionMixin:
@action(methods=['get'], detail=False, url_path='suggestions')
def match(self, request, *args, **kwargs):
queryset = self.get_queryset()
if not request.user.orgs.filter(id=current_org.id).exists():
org_id = str(current_org.id)
if (
not request.user.is_superuser and
org_id != Organization.ROOT_ID and
not request.user.orgs.filter(id=org_id).exists()
):
queryset = queryset.none()
queryset = self.filter_queryset(queryset)