Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
eca245fd
Commit
eca245fd
authored
Jul 27, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Bugfix] 修复节点前面有个空目录
parent
7e3cf908
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
25 additions
and
22 deletions
+25
-22
node.py
apps/assets/api/node.py
+0
-7
node.py
apps/assets/models/node.py
+9
-6
node.py
apps/assets/serializers/node.py
+5
-2
asset_list.html
apps/assets/templates/assets/asset_list.html
+5
-4
asset_permission_list.html
apps/perms/templates/perms/asset_permission_list.html
+5
-2
_user_profile.html
apps/templates/_user_profile.html
+1
-1
No files found.
apps/assets/api/node.py
View file @
eca245fd
...
...
@@ -42,13 +42,6 @@ class NodeViewSet(viewsets.ModelViewSet):
permission_classes
=
(
IsOrgAdmin
,)
serializer_class
=
serializers
.
NodeSerializer
def
get_queryset
(
self
):
# queryset = super(NodeViewSet, self).get_queryset()
print
(
"API GET QUWRYSET"
)
# print(get_current_org())
# print(queryset)
return
Node
.
objects
.
all
()
def
perform_create
(
self
,
serializer
):
child_key
=
Node
.
root
()
.
get_next_child_key
()
serializer
.
validated_data
[
"key"
]
=
child_key
...
...
apps/assets/models/node.py
View file @
eca245fd
...
...
@@ -178,12 +178,15 @@ class Node(OrgModelMixin):
# 如果使用current_org 在set_current_org时会死循环
_current_org
=
get_current_org
()
with
transaction
.
atomic
():
set_current_org
(
Organization
.
root
())
org_nodes_roots
=
cls
.
objects
.
filter
(
key__regex
=
r'^[0-9]+$'
)
org_nodes_roots_keys
=
org_nodes_roots
.
values_list
(
'key'
,
flat
=
True
)
max_value
=
max
([
int
(
k
)
for
k
in
org_nodes_roots_keys
])
if
org_nodes_roots_keys
else
-
1
set_current_org
(
_current_org
)
root
=
cls
.
objects
.
create
(
key
=
str
(
max_value
+
1
),
value
=
_current_org
.
name
)
if
_current_org
.
is_default
():
key
=
'0'
else
:
set_current_org
(
Organization
.
root
())
org_nodes_roots
=
cls
.
objects
.
filter
(
key__regex
=
r'^[0-9]+$'
)
org_nodes_roots_keys
=
org_nodes_roots
.
values_list
(
'key'
,
flat
=
True
)
key
=
max
([
int
(
k
)
for
k
in
org_nodes_roots_keys
])
+
1
set_current_org
(
_current_org
)
root
=
cls
.
objects
.
create
(
key
=
key
,
value
=
_current_org
.
name
)
return
root
@classmethod
...
...
apps/assets/serializers/node.py
View file @
eca245fd
...
...
@@ -26,7 +26,7 @@ class NodeGrantedSerializer(BulkSerializerMixin, serializers.ModelSerializer):
model
=
Node
fields
=
[
'id'
,
'key'
,
'name'
,
'value'
,
'parent'
,
'assets_granted'
,
'assets_amount'
,
'assets_granted'
,
'assets_amount'
,
'org_id'
,
]
@staticmethod
...
...
@@ -48,7 +48,10 @@ class NodeSerializer(serializers.ModelSerializer):
class
Meta
:
model
=
Node
fields
=
[
'id'
,
'key'
,
'value'
,
'parent'
,
'assets_amount'
,
'is_node'
]
fields
=
[
'id'
,
'key'
,
'value'
,
'parent'
,
'assets_amount'
,
'is_node'
,
'org_id'
,
]
list_serializer_class
=
BulkListSerializer
def
validate
(
self
,
data
):
...
...
apps/assets/templates/assets/asset_list.html
View file @
eca245fd
...
...
@@ -406,10 +406,11 @@ function initTree() {
var
zNodes
=
[];
$
.
get
(
"{% url 'api-assets:node-list' %}"
,
function
(
data
,
status
){
$
.
each
(
data
,
function
(
index
,
value
)
{
value
[
"pId"
]
=
value
[
"parent"
];
if
(
value
[
"key"
]
===
"0"
)
{
value
[
"open"
]
=
true
;
}
if
(
value
[
"parent"
]
!==
value
[
"id"
]){
value
[
"pId"
]
=
value
[
"parent"
];
}
else
{
value
[
"isParent"
]
=
true
;
}
value
[
"name"
]
=
value
[
"value"
]
+
' ('
+
value
[
'assets_amount'
]
+
')'
;
value
[
'value'
]
=
value
[
'value'
];
});
...
...
apps/perms/templates/perms/asset_permission_list.html
View file @
eca245fd
...
...
@@ -240,9 +240,12 @@ function initTree() {
var
zNodes
=
[];
$
.
get
(
"{% url 'api-assets:node-children-2' %}?assets=1&all="
,
function
(
data
,
status
){
$
.
each
(
data
,
function
(
index
,
value
)
{
value
[
"pId"
]
=
value
[
"parent"
];
if
(
value
[
"parent"
]
!==
value
[
"id"
]){
value
[
"pId"
]
=
value
[
"parent"
];
}
else
{
value
[
"isParent"
]
=
true
;
}
value
[
"name"
]
=
value
[
"value"
];
value
[
"open"
]
=
value
[
"key"
]
===
"0"
;
value
[
"isParent"
]
=
value
[
"is_node"
];
value
[
"iconSkin"
]
=
value
[
"is_node"
]
?
null
:
'file'
;
});
...
...
apps/templates/_user_profile.html
View file @
eca245fd
...
...
@@ -15,7 +15,7 @@
<a
class=
"dropdown-toggle"
data-toggle=
"dropdown"
aria-expanded=
"false"
style=
"display: block; background-color: transparent; color: #8095a8; padding: 14px 20px 14px 25px"
>
<i
class=
"fa fa-bookmark"
style=
"width: 14px; "
></i>
<span
class=
"nav-label"
style=
"padding-left: 7px"
>
{
% trans 'Org' %} - {
{ CURRENT_ORG.name }}
{{ CURRENT_ORG.name }}
</span>
<span
class=
"fa fa-sort-desc pull-right"
></span>
</a>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment