mirror of https://github.com/jumpserver/jumpserver
perf: Suggestion api
parent
89aa87fd6b
commit
48fa6172bd
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue