Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
gjl2004yn
jumpserver
提交
aec78dc3
J
jumpserver
项目概览
gjl2004yn
/
jumpserver
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jumpserver
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
aec78dc3
编写于
5月 06, 2020
作者:
B
Bai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Update] 添加组织详情->组织用户tab页,解决组织详情页面加载超时问题
上级
cc30a20b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
35 addition
and
4 deletion
+35
-4
apps/orgs/api.py
apps/orgs/api.py
+16
-2
apps/orgs/serializers.py
apps/orgs/serializers.py
+12
-0
apps/orgs/urls/api_urls.py
apps/orgs/urls/api_urls.py
+2
-1
apps/users/api/mixins.py
apps/users/api/mixins.py
+5
-1
未找到文件。
apps/orgs/api.py
浏览文件 @
aec78dc3
# -*- coding: utf-8 -*-
#
from
rest_framework
import
status
from
django.shortcuts
import
get_object_or_404
from
rest_framework
import
status
,
generics
from
rest_framework.views
import
Response
from
rest_framework_bulk
import
BulkModelViewSet
from
common.permissions
import
IsSuperUserOrAppUser
from
.models
import
Organization
from
.serializers
import
OrgSerializer
,
OrgReadSerializer
,
\
OrgMembershipUserSerializer
,
OrgMembershipAdminSerializer
OrgMembershipUserSerializer
,
OrgMembershipAdminSerializer
,
\
OrgAllUserSerializer
from
users.models
import
User
,
UserGroup
from
assets.models
import
Asset
,
Domain
,
AdminUser
,
SystemUser
,
Label
from
perms.models
import
AssetPermission
...
...
@@ -67,3 +69,15 @@ class OrgMembershipUsersViewSet(OrgMembershipModelViewSetMixin, BulkModelViewSet
membership_class
=
Organization
.
users
.
through
permission_classes
=
(
IsSuperUserOrAppUser
,
)
class
OrgAllUserListApi
(
generics
.
ListAPIView
):
permission_classes
=
(
IsSuperUserOrAppUser
,)
serializer_class
=
OrgAllUserSerializer
filter_fields
=
(
"username"
,
"name"
)
search_fields
=
filter_fields
def
get_queryset
(
self
):
pk
=
self
.
kwargs
.
get
(
"pk"
)
org
=
get_object_or_404
(
Organization
,
pk
=
pk
)
users
=
org
.
get_org_users
().
only
(
*
self
.
serializer_class
.
Meta
.
only_fields
)
return
users
apps/orgs/serializers.py
浏览文件 @
aec78dc3
...
...
@@ -80,3 +80,15 @@ class OrgMembershipUserSerializer(OrgMembershipSerializerMixin, ModelSerializer)
model
=
Organization
.
users
.
through
list_serializer_class
=
AdaptedBulkListSerializer
fields
=
'__all__'
class
OrgAllUserSerializer
(
serializers
.
Serializer
):
user
=
serializers
.
UUIDField
(
read_only
=
True
,
source
=
'id'
)
user_display
=
serializers
.
SerializerMethodField
()
class
Meta
:
only_fields
=
[
'id'
,
'username'
,
'name'
]
@
staticmethod
def
get_user_display
(
obj
):
return
str
(
obj
)
apps/orgs/urls/api_urls.py
浏览文件 @
aec78dc3
# -*- coding: utf-8 -*-
#
from
django.urls
import
re_path
from
django.urls
import
re_path
,
path
from
rest_framework.routers
import
DefaultRouter
from
common
import
api
as
capi
...
...
@@ -24,6 +24,7 @@ old_version_urlpatterns = [
]
urlpatterns
=
[
path
(
'<uuid:pk>/users/all/'
,
api
.
OrgAllUserListApi
.
as_view
(),
name
=
'org-all-users'
),
]
urlpatterns
+=
router
.
urls
+
old_version_urlpatterns
apps/users/api/mixins.py
浏览文件 @
aec78dc3
# -*- coding: utf-8 -*-
#
from
..
import
utils
from
users.models
import
User
class
UserQuerysetMixin
:
def
get_queryset
(
self
):
queryset
=
utils
.
get_current_org_members
()
if
self
.
request
.
query_params
.
get
(
'all'
):
queryset
=
User
.
objects
.
exclude
(
role
=
User
.
ROLE_APP
)
else
:
queryset
=
utils
.
get_current_org_members
()
return
queryset
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录