Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
gjl2004yn
jumpserver
提交
6b86b8b4
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,发现更多精彩内容 >>
提交
6b86b8b4
编写于
8月 10, 2018
作者:
baltery
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Bugfix] 修复资产数量不对的bug
上级
7da46354
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
15 addition
and
14 deletion
+15
-14
apps/assets/api/node.py
apps/assets/api/node.py
+2
-6
apps/assets/models/node.py
apps/assets/models/node.py
+5
-0
apps/assets/serializers/node.py
apps/assets/serializers/node.py
+1
-1
apps/assets/views/asset.py
apps/assets/views/asset.py
+7
-4
apps/perms/utils.py
apps/perms/utils.py
+0
-2
apps/terminal/api.py
apps/terminal/api.py
+0
-1
未找到文件。
apps/assets/api/node.py
浏览文件 @
6b86b8b4
...
...
@@ -43,10 +43,6 @@ class NodeViewSet(viewsets.ModelViewSet):
permission_classes
=
(
IsOrgAdmin
,)
serializer_class
=
serializers
.
NodeSerializer
def
get_queryset
(
self
):
queryset
=
super
().
get_queryset
().
annotate
(
Count
(
'assets'
))
return
queryset
def
perform_create
(
self
,
serializer
):
child_key
=
Node
.
root
().
get_next_child_key
()
serializer
.
validated_data
[
"key"
]
=
child_key
...
...
@@ -108,9 +104,9 @@ class NodeChildrenApi(mixins.ListModelMixin, generics.CreateAPIView):
queryset
.
append
(
node
)
if
query_all
:
children
=
node
.
get_all_children
()
.
annotate
(
Count
(
"assets"
))
children
=
node
.
get_all_children
()
else
:
children
=
node
.
get_children
()
.
annotate
(
Count
(
"assets"
))
children
=
node
.
get_children
()
queryset
.
extend
(
list
(
children
))
if
query_assets
:
...
...
apps/assets/models/node.py
浏览文件 @
6b86b8b4
...
...
@@ -199,6 +199,11 @@ class Node(OrgModelMixin):
else
:
return
cls
.
create_root_node
()
@
classmethod
def
default_node
(
cls
):
defaults
=
{
'value'
:
'Default'
}
return
cls
.
objects
.
get_or_create
(
defaults
=
defaults
,
key
=
'0'
)
@
classmethod
def
generate_fake
(
cls
,
count
=
100
):
import
random
...
...
apps/assets/serializers/node.py
浏览文件 @
6b86b8b4
...
...
@@ -68,7 +68,7 @@ class NodeSerializer(serializers.ModelSerializer):
@
staticmethod
def
get_assets_amount
(
obj
):
return
obj
.
assets__count
if
hasattr
(
obj
,
'assets__count'
)
else
0
return
obj
.
get_all_assets
().
count
()
@
staticmethod
def
get_tree_id
(
obj
):
...
...
apps/assets/views/asset.py
浏览文件 @
6b86b8b4
...
...
@@ -8,7 +8,6 @@ import codecs
import
chardet
from
io
import
StringIO
from
django.conf
import
settings
from
django.db
import
transaction
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.views.generic
import
TemplateView
,
ListView
,
View
...
...
@@ -25,11 +24,12 @@ from django.shortcuts import redirect
from
django.contrib.messages.views
import
SuccessMessageMixin
from
common.mixins
import
JSONResponseMixin
from
common.utils
import
get_object_or_none
,
get_logger
,
is_uuid
from
common.utils
import
get_object_or_none
,
get_logger
from
common.permissions
import
AdminUserRequiredMixin
from
common.const
import
create_success_msg
,
update_success_msg
from
orgs.utils
import
current_org
from
..
import
forms
from
..models
import
Asset
,
AdminUser
,
SystemUser
,
Label
,
Node
,
Domain
from
common.permissions
import
AdminUserRequiredMixin
__all__
=
[
...
...
@@ -44,7 +44,10 @@ class AssetListView(AdminUserRequiredMixin, TemplateView):
template_name
=
'assets/asset_list.html'
def
get_context_data
(
self
,
**
kwargs
):
Node
.
root
()
if
current_org
.
is_default
():
Node
.
default_node
()
else
:
Node
.
root
()
context
=
{
'app'
:
_
(
'Assets'
),
'action'
:
_
(
'Asset list'
),
...
...
apps/perms/utils.py
浏览文件 @
6b86b8b4
...
...
@@ -139,8 +139,6 @@ class AssetPermissionUtil:
for
node
,
system_users
in
nodes
.
items
():
_assets
=
node
.
get_all_assets
().
valid
().
prefetch_related
(
'nodes'
)
for
asset
in
_assets
:
if
isinstance
(
asset
,
Node
):
print
(
_assets
)
assets
[
asset
].
update
(
system_users
)
self
.
_assets
=
assets
return
self
.
_assets
...
...
apps/terminal/api.py
浏览文件 @
6b86b8b4
...
...
@@ -243,7 +243,6 @@ class CommandViewSet(viewsets.ViewSet):
def
create
(
self
,
request
,
*
args
,
**
kwargs
):
serializer
=
self
.
serializer_class
(
data
=
request
.
data
,
many
=
True
)
if
serializer
.
is_valid
():
print
(
serializer
.
validated_data
)
ok
=
self
.
command_store
.
bulk_save
(
serializer
.
validated_data
)
if
ok
:
return
Response
(
"ok"
,
status
=
201
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录