mirror of https://github.com/jumpserver/jumpserver
[Update] 去掉一些filter
parent
f15dc881b6
commit
86c5a0ba8b
|
@ -36,7 +36,6 @@ class AssetViewSet(OrgBulkModelViewSet):
|
|||
serializer_class = serializers.AssetSerializer
|
||||
permission_classes = (IsOrgAdminOrAppUser,)
|
||||
extra_filter_backends = [AssetByNodeFilterBackend, LabelFilterBackend]
|
||||
custom_filter_fields = ['admin_user_id']
|
||||
|
||||
def set_assets_node(self, assets):
|
||||
if not isinstance(assets, list):
|
||||
|
@ -53,19 +52,6 @@ class AssetViewSet(OrgBulkModelViewSet):
|
|||
assets = serializer.save()
|
||||
self.set_assets_node(assets)
|
||||
|
||||
def filter_admin_user_id(self, queryset):
|
||||
admin_user_id = self.request.query_params.get('admin_user_id')
|
||||
if not admin_user_id:
|
||||
return queryset
|
||||
admin_user = get_object_or_404(AdminUser, id=admin_user_id)
|
||||
queryset = queryset.filter(admin_user=admin_user)
|
||||
return queryset
|
||||
|
||||
def filter_queryset(self, queryset):
|
||||
queryset = super().filter_queryset(queryset)
|
||||
queryset = self.filter_admin_user_id(queryset)
|
||||
return queryset
|
||||
|
||||
|
||||
class AssetRefreshHardwareApi(generics.RetrieveAPIView):
|
||||
"""
|
||||
|
|
|
@ -16,23 +16,14 @@ __all__ = ['DomainViewSet', 'GatewayViewSet', "GatewayTestConnectionApi"]
|
|||
|
||||
class DomainViewSet(OrgBulkModelViewSet):
|
||||
queryset = Domain.objects.all()
|
||||
permission_classes = (IsOrgAdmin,)
|
||||
permission_classes = (IsOrgAdminOrAppUser,)
|
||||
serializer_class = serializers.DomainSerializer
|
||||
|
||||
def get_queryset(self):
|
||||
queryset = super().get_queryset().all()
|
||||
return queryset
|
||||
|
||||
def get_serializer_class(self):
|
||||
if self.request.query_params.get('gateway'):
|
||||
return serializers.DomainWithGatewaySerializer
|
||||
return super().get_serializer_class()
|
||||
|
||||
def get_permissions(self):
|
||||
if self.request.query_params.get('gateway'):
|
||||
self.permission_classes = (IsOrgAdminOrAppUser,)
|
||||
return super().get_permissions()
|
||||
|
||||
|
||||
class GatewayViewSet(OrgBulkModelViewSet):
|
||||
filter_fields = ("domain__name", "name", "username", "ip", "domain")
|
||||
|
|
|
@ -8,7 +8,6 @@ from django.http import HttpResponseNotFound
|
|||
from django.conf import settings
|
||||
from rest_framework import viewsets
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.generics import GenericAPIView
|
||||
import jms_storage
|
||||
|
||||
from common.utils import is_uuid, get_logger
|
||||
|
@ -35,6 +34,7 @@ class SessionViewSet(OrgBulkModelViewSet):
|
|||
date_range_filter_fields = [
|
||||
('date_start', ('date_from', 'date_to'))
|
||||
]
|
||||
extra_filter_backends = [DatetimeRangeFilter]
|
||||
|
||||
def filter_queryset(self, queryset):
|
||||
queryset = super().filter_queryset(queryset)
|
||||
|
@ -43,12 +43,6 @@ class SessionViewSet(OrgBulkModelViewSet):
|
|||
queryset = queryset.select_for_update()
|
||||
return queryset
|
||||
|
||||
@property
|
||||
def filter_backends(self):
|
||||
backends = list(GenericAPIView.filter_backends)
|
||||
backends.append(DatetimeRangeFilter)
|
||||
return backends
|
||||
|
||||
def perform_create(self, serializer):
|
||||
if hasattr(self.request.user, 'terminal'):
|
||||
serializer.validated_data["terminal"] = self.request.user.terminal
|
||||
|
|
Loading…
Reference in New Issue