perf: Suggestion api

This commit is contained in:
feng
2025-06-16 11:33:46 +08:00
committed by ZhaoJiSen
parent 7dfb31840e
commit 41658af8fd
7 changed files with 13 additions and 7 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, PUT
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)