Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
gjl2004yn
jumpserver
提交
86c5a0ba
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,发现更多精彩内容 >>
提交
86c5a0ba
编写于
9月 23, 2019
作者:
baltery
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Update] 去掉一些filter
上级
f15dc881
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
2 addition
and
31 deletion
+2
-31
apps/assets/api/asset.py
apps/assets/api/asset.py
+0
-14
apps/assets/api/domain.py
apps/assets/api/domain.py
+1
-10
apps/terminal/api/session.py
apps/terminal/api/session.py
+1
-7
未找到文件。
apps/assets/api/asset.py
浏览文件 @
86c5a0ba
...
...
@@ -36,7 +36,6 @@ class AssetViewSet(OrgBulkModelViewSet):
serializer_class
=
serializers
.
AssetSerializer
permission_classes
=
(
IsOrgAdminOrAppUser
,)
extra_filter_backends
=
[
AssetByNodeFilterBackend
,
LabelFilterBackend
]
custom_filter_fields
=
[
'admin_user_id'
]
def
set_assets_node
(
self
,
assets
):
if
not
isinstance
(
assets
,
list
):
...
...
@@ -53,19 +52,6 @@ class AssetViewSet(OrgBulkModelViewSet):
assets
=
serializer
.
save
()
self
.
set_assets_node
(
assets
)
def
filter_admin_user_id
(
self
,
queryset
):
admin_user_id
=
self
.
request
.
query_params
.
get
(
'admin_user_id'
)
if
not
admin_user_id
:
return
queryset
admin_user
=
get_object_or_404
(
AdminUser
,
id
=
admin_user_id
)
queryset
=
queryset
.
filter
(
admin_user
=
admin_user
)
return
queryset
def
filter_queryset
(
self
,
queryset
):
queryset
=
super
().
filter_queryset
(
queryset
)
queryset
=
self
.
filter_admin_user_id
(
queryset
)
return
queryset
class
AssetRefreshHardwareApi
(
generics
.
RetrieveAPIView
):
"""
...
...
apps/assets/api/domain.py
浏览文件 @
86c5a0ba
...
...
@@ -16,23 +16,14 @@ __all__ = ['DomainViewSet', 'GatewayViewSet', "GatewayTestConnectionApi"]
class
DomainViewSet
(
OrgBulkModelViewSet
):
queryset
=
Domain
.
objects
.
all
()
permission_classes
=
(
IsOrgAdmin
,)
permission_classes
=
(
IsOrgAdmin
OrAppUser
,)
serializer_class
=
serializers
.
DomainSerializer
def
get_queryset
(
self
):
queryset
=
super
().
get_queryset
().
all
()
return
queryset
def
get_serializer_class
(
self
):
if
self
.
request
.
query_params
.
get
(
'gateway'
):
return
serializers
.
DomainWithGatewaySerializer
return
super
().
get_serializer_class
()
def
get_permissions
(
self
):
if
self
.
request
.
query_params
.
get
(
'gateway'
):
self
.
permission_classes
=
(
IsOrgAdminOrAppUser
,)
return
super
().
get_permissions
()
class
GatewayViewSet
(
OrgBulkModelViewSet
):
filter_fields
=
(
"domain__name"
,
"name"
,
"username"
,
"ip"
,
"domain"
)
...
...
apps/terminal/api/session.py
浏览文件 @
86c5a0ba
...
...
@@ -8,7 +8,6 @@ from django.http import HttpResponseNotFound
from
django.conf
import
settings
from
rest_framework
import
viewsets
from
rest_framework.response
import
Response
from
rest_framework.generics
import
GenericAPIView
import
jms_storage
from
common.utils
import
is_uuid
,
get_logger
...
...
@@ -35,6 +34,7 @@ class SessionViewSet(OrgBulkModelViewSet):
date_range_filter_fields
=
[
(
'date_start'
,
(
'date_from'
,
'date_to'
))
]
extra_filter_backends
=
[
DatetimeRangeFilter
]
def
filter_queryset
(
self
,
queryset
):
queryset
=
super
().
filter_queryset
(
queryset
)
...
...
@@ -43,12 +43,6 @@ class SessionViewSet(OrgBulkModelViewSet):
queryset
=
queryset
.
select_for_update
()
return
queryset
@
property
def
filter_backends
(
self
):
backends
=
list
(
GenericAPIView
.
filter_backends
)
backends
.
append
(
DatetimeRangeFilter
)
return
backends
def
perform_create
(
self
,
serializer
):
if
hasattr
(
self
.
request
.
user
,
'terminal'
):
serializer
.
validated_data
[
"terminal"
]
=
self
.
request
.
user
.
terminal
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录