mirror of https://github.com/jumpserver/jumpserver
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
862 B
30 lines
862 B
from django_filters import rest_framework as drf_filters
|
|
|
|
from common.api import JMSBulkModelViewSet
|
|
from orgs.utils import tmp_to_root_org
|
|
from .common import ACLUserFilterMixin
|
|
from .. import serializers
|
|
from ..models import ConnectMethodACL
|
|
|
|
__all__ = ['ConnectMethodACLViewSet']
|
|
|
|
|
|
class ConnectMethodFilter(ACLUserFilterMixin):
|
|
methods = drf_filters.CharFilter(field_name="methods__contains", lookup_expr='exact')
|
|
|
|
class Meta:
|
|
model = ConnectMethodACL
|
|
fields = ['name', ]
|
|
|
|
|
|
class ConnectMethodACLViewSet(JMSBulkModelViewSet):
|
|
queryset = ConnectMethodACL.objects.all()
|
|
filterset_class = ConnectMethodFilter
|
|
search_fields = ('name',)
|
|
serializer_class = serializers.ConnectMethodACLSerializer
|
|
|
|
def filter_queryset(self, queryset):
|
|
with tmp_to_root_org():
|
|
return super().filter_queryset(queryset)
|
|
|