mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-01 15:37:19 +00:00
@@ -16,6 +16,7 @@ from rbac.permissions import RBACPermission
|
||||
from users.utils import LoginBlockUtil, MFABlockUtils
|
||||
from .mixins import UserQuerysetMixin
|
||||
from .. import serializers
|
||||
from ..exceptions import UnableToDeleteAllUsers
|
||||
from ..filters import UserFilter
|
||||
from ..models import User
|
||||
from ..notifications import ResetMFAMsg
|
||||
@@ -55,6 +56,12 @@ class UserViewSet(CommonApiMixin, UserQuerysetMixin, SuggestionMixin, BulkModelV
|
||||
queryset = super().get_queryset().prefetch_related('groups')
|
||||
return queryset
|
||||
|
||||
def allow_bulk_destroy(self, qs, filtered):
|
||||
is_valid = filtered.count() < qs.count()
|
||||
if not is_valid:
|
||||
raise UnableToDeleteAllUsers()
|
||||
return True
|
||||
|
||||
@action(methods=['get'], detail=False, url_path='suggestions')
|
||||
def match(self, request, *args, **kwargs):
|
||||
with tmp_to_root_org():
|
||||
@@ -111,8 +118,6 @@ class UserViewSet(CommonApiMixin, UserQuerysetMixin, SuggestionMixin, BulkModelV
|
||||
self.check_object_permissions(self.request, user)
|
||||
return super().perform_bulk_update(serializer)
|
||||
|
||||
def allow_bulk_destroy(self, qs, filtered):
|
||||
return filtered.count() < qs.count()
|
||||
|
||||
def perform_bulk_destroy(self, objects):
|
||||
for obj in objects:
|
||||
|
Reference in New Issue
Block a user