mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-26 15:25:55 +00:00
perf: Suggestion api
This commit is contained in:
@@ -8,6 +8,7 @@ from rest_framework.request import Request
|
|||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
|
|
||||||
from common.const.http import POST
|
from common.const.http import POST
|
||||||
|
from orgs.models import Organization
|
||||||
from orgs.utils import current_org
|
from orgs.utils import current_org
|
||||||
|
|
||||||
__all__ = ['SuggestionMixin', 'RenderToJsonMixin']
|
__all__ = ['SuggestionMixin', 'RenderToJsonMixin']
|
||||||
@@ -25,7 +26,12 @@ class SuggestionMixin:
|
|||||||
@action(methods=['get'], detail=False, url_path='suggestions')
|
@action(methods=['get'], detail=False, url_path='suggestions')
|
||||||
def match(self, request, *args, **kwargs):
|
def match(self, request, *args, **kwargs):
|
||||||
queryset = self.get_queryset()
|
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 = queryset.none()
|
||||||
|
|
||||||
queryset = self.filter_queryset(queryset)
|
queryset = self.filter_queryset(queryset)
|
||||||
|
Reference in New Issue
Block a user