mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-27 07:44:23 +00:00
* perf: 整合系统用户和管理用户 * stash stash perf: 优化系统用户和资产的表结构 * perf: 添加信号 * perf: 添加算法 * perf: 去掉 asset user backends * perf: 整理系统用户api * perfF: 暂存一下 * stash * perf: 暂存一下 * perf: 暂存 * xxx * perf: ... * stash it * xxx * xxx * xxx * xxx * xxx * stash it * 修改Protocols * perf: 修改创建authbook信号 * perf: 添加auth info * .stash * perf: 基本完成 * perf: 修复完成 * perf: 修复更改的id * perf: 修复迁移过去数量不对的问题 * perf: 修改systemuser * fix: 修复批量编辑近期的问题 * fix: 修复authbook加载的问题 * xxx Co-authored-by: ibuler <ibuler@qq.com>
29 lines
826 B
Python
29 lines
826 B
Python
from django.db.models import Count
|
|
|
|
from orgs.mixins.api import OrgBulkModelViewSet
|
|
from common.utils import get_logger
|
|
from ..hands import IsOrgAdmin
|
|
from ..models import SystemUser
|
|
from .. import serializers
|
|
|
|
|
|
logger = get_logger(__file__)
|
|
__all__ = ['AdminUserViewSet']
|
|
|
|
|
|
# 兼容一下老的 api
|
|
class AdminUserViewSet(OrgBulkModelViewSet):
|
|
"""
|
|
Admin user api set, for add,delete,update,list,retrieve resource
|
|
"""
|
|
model = SystemUser
|
|
filterset_fields = ("name", "username")
|
|
search_fields = filterset_fields
|
|
serializer_class = serializers.AdminUserSerializer
|
|
permission_classes = (IsOrgAdmin,)
|
|
|
|
def get_queryset(self):
|
|
queryset = super().get_queryset().filter(type=SystemUser.Type.admin)
|
|
queryset = queryset.annotate(assets_amount=Count('assets'))
|
|
return queryset
|