mirror of https://github.com/jumpserver/jumpserver
fix: swagger
parent
ad2cb233d7
commit
f460916e84
|
@ -37,6 +37,7 @@ class GatewayViewSet(OrgBulkModelViewSet):
|
||||||
|
|
||||||
|
|
||||||
class GatewayTestConnectionApi(SingleObjectMixin, APIView):
|
class GatewayTestConnectionApi(SingleObjectMixin, APIView):
|
||||||
|
queryset = Gateway.objects.all()
|
||||||
object = None
|
object = None
|
||||||
rbac_perms = {
|
rbac_perms = {
|
||||||
'POST': 'assets.change_gateway'
|
'POST': 'assets.change_gateway'
|
||||||
|
|
|
@ -25,6 +25,9 @@ class RoleAdminMixin:
|
||||||
@lazyproperty
|
@lazyproperty
|
||||||
def user(self):
|
def user(self):
|
||||||
user_id = self.kwargs.get(self.user_id_url_kwarg)
|
user_id = self.kwargs.get(self.user_id_url_kwarg)
|
||||||
|
if hasattr(self, 'swagger_fake_view') and not user_id:
|
||||||
|
return self.request.user # NOQA
|
||||||
|
|
||||||
user_model = get_user_model()
|
user_model = get_user_model()
|
||||||
return user_model.objects.get(id=user_id)
|
return user_model.objects.get(id=user_id)
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,10 @@ class UserGroupGrantedApplicationsApi(CommonApiMixin, ListAPIView):
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
user_group_id = self.kwargs.get('pk', '')
|
user_group_id = self.kwargs.get('pk')
|
||||||
|
if not user_group_id:
|
||||||
|
return Application.objects.none()
|
||||||
|
|
||||||
queryset = Application.objects\
|
queryset = Application.objects\
|
||||||
.filter(Q(granted_by_permissions__user_groups__id=user_group_id))\
|
.filter(Q(granted_by_permissions__user_groups__id=user_group_id))\
|
||||||
.distinct().only(*self.only_fields)
|
.distinct().only(*self.only_fields)
|
||||||
|
|
|
@ -40,7 +40,9 @@ class UserGroupGrantedAssetsApi(ListAPIView):
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
user_group_id = self.kwargs.get('pk', '')
|
user_group_id = self.kwargs.get('pk')
|
||||||
|
if not user_group_id:
|
||||||
|
return Asset.objects.none()
|
||||||
|
|
||||||
asset_perm_ids = list(AssetPermission.objects.valid().filter(
|
asset_perm_ids = list(AssetPermission.objects.valid().filter(
|
||||||
user_groups__id=user_group_id
|
user_groups__id=user_group_id
|
||||||
|
@ -127,7 +129,10 @@ class UserGroupGrantedNodesApi(ListAPIView):
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
user_group_id = self.kwargs.get('pk', '')
|
user_group_id = self.kwargs.get('pk')
|
||||||
|
if not user_group_id:
|
||||||
|
return Node.objects.none()
|
||||||
|
|
||||||
nodes = Node.objects.filter(
|
nodes = Node.objects.filter(
|
||||||
Q(granted_by_permissions__user_groups__id=user_group_id) |
|
Q(granted_by_permissions__user_groups__id=user_group_id) |
|
||||||
Q(assets__granted_by_permissions__user_groups__id=user_group_id)
|
Q(assets__granted_by_permissions__user_groups__id=user_group_id)
|
||||||
|
|
|
@ -61,6 +61,7 @@ class OrgRoleViewSet(RoleViewSet):
|
||||||
|
|
||||||
# Sub view set
|
# Sub view set
|
||||||
class RolePermissionsViewSet(PermissionViewSet):
|
class RolePermissionsViewSet(PermissionViewSet):
|
||||||
|
filterset_fields = []
|
||||||
rbac_perms = (
|
rbac_perms = (
|
||||||
('get_tree', 'role.view_role'),
|
('get_tree', 'role.view_role'),
|
||||||
)
|
)
|
||||||
|
@ -69,6 +70,9 @@ class RolePermissionsViewSet(PermissionViewSet):
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
role_id = self.kwargs.get('role_pk')
|
role_id = self.kwargs.get('role_pk')
|
||||||
|
if not role_id:
|
||||||
|
return Role.objects.none()
|
||||||
|
|
||||||
role = Role.objects.get(id=role_id)
|
role = Role.objects.get(id=role_id)
|
||||||
self.scope = role.scope
|
self.scope = role.scope
|
||||||
self.check_disabled = role.builtin
|
self.check_disabled = role.builtin
|
||||||
|
|
|
@ -101,7 +101,7 @@ class LDAPUserListApi(generics.ListAPIView):
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
if hasattr(self, 'swagger_fake_view'):
|
if hasattr(self, 'swagger_fake_view'):
|
||||||
return []
|
return User.objects.none()
|
||||||
cache_police = self.request.query_params.get('cache_police', True)
|
cache_police = self.request.query_params.get('cache_police', True)
|
||||||
if cache_police in LDAP_USE_CACHE_FLAGS:
|
if cache_police in LDAP_USE_CACHE_FLAGS:
|
||||||
users = self.get_queryset_from_cache()
|
users = self.get_queryset_from_cache()
|
||||||
|
|
|
@ -166,6 +166,9 @@ class CommandViewSet(JMSBulkModelViewSet):
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
command_storage_id = self.request.query_params.get('command_storage_id')
|
command_storage_id = self.request.query_params.get('command_storage_id')
|
||||||
|
if not command_storage_id:
|
||||||
|
return Command.objects.none()
|
||||||
|
|
||||||
storage = CommandStorage.objects.get(id=command_storage_id)
|
storage = CommandStorage.objects.get(id=command_storage_id)
|
||||||
if not storage.is_valid():
|
if not storage.is_valid():
|
||||||
raise StorageInvalid
|
raise StorageInvalid
|
||||||
|
|
|
@ -11,7 +11,7 @@ from orgs.utils import tmp_to_root_org
|
||||||
|
|
||||||
|
|
||||||
class TicketSessionRelationViewSet(CreateModelMixin, JMSGenericViewSet):
|
class TicketSessionRelationViewSet(CreateModelMixin, JMSGenericViewSet):
|
||||||
queryset = TicketSession
|
queryset = TicketSession.objects.all()
|
||||||
serializer_class = TicketSessionRelationSerializer
|
serializer_class = TicketSessionRelationSerializer
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue