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
38f8c5bb
Commit
38f8c5bb
authored
May 14, 2018
by
BaiJiangjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Bugfix] 修复资产树节点移动,资产授权树节点下的资产显示问题
parent
ebc1b497
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
7 deletions
+19
-7
node.py
apps/assets/api/node.py
+3
-2
node.py
apps/assets/models/node.py
+11
-1
asset_permission_list.html
apps/perms/templates/perms/asset_permission_list.html
+4
-3
views.py
apps/perms/views.py
+1
-1
No files found.
apps/assets/api/node.py
View file @
38f8c5bb
...
...
@@ -184,8 +184,9 @@ class NodeAddChildrenApi(generics.UpdateAPIView):
for
node
in
children
:
if
not
node
:
continue
node
.
parent
=
instance
node
.
save
()
# node.parent = instance
# node.save()
node
.
move
(
instance
)
return
Response
(
"OK"
)
...
...
apps/assets/models/node.py
View file @
38f8c5bb
...
...
@@ -2,7 +2,7 @@
#
import
uuid
from
django.db
import
models
from
django.db
import
models
,
transaction
from
django.utils.translation
import
ugettext_lazy
as
_
...
...
@@ -39,6 +39,16 @@ class Node(models.Model):
def
level
(
self
):
return
len
(
self
.
key
.
split
(
':'
))
def
move
(
self
,
instance
):
children
=
self
.
get_all_children
()
old_key
=
self
.
key
with
transaction
.
atomic
():
self
.
parent
=
instance
for
child
in
children
:
child
.
key
=
child
.
key
.
replace
(
old_key
,
self
.
key
,
1
)
child
.
save
()
self
.
save
()
def
get_next_child_key
(
self
):
mark
=
self
.
child_mark
self
.
child_mark
+=
1
...
...
apps/perms/templates/perms/asset_permission_list.html
View file @
38f8c5bb
...
...
@@ -226,7 +226,7 @@ function initTree() {
},
async
:
{
enable
:
true
,
url
:
"{% url 'api-assets:node-children-2' %}?assets=1&all=
1
"
,
url
:
"{% url 'api-assets:node-children-2' %}?assets=1&all="
,
autoParam
:[
"id"
,
"name=n"
,
"level=lv"
],
dataFilter
:
filter
,
type
:
'get'
...
...
@@ -238,7 +238,7 @@ function initTree() {
};
var
zNodes
=
[];
$
.
get
(
"{% url 'api-assets:node-children-2' %}?assets=1&all=
1
"
,
function
(
data
,
status
){
$
.
get
(
"{% url 'api-assets:node-children-2' %}?assets=1&all="
,
function
(
data
,
status
){
$
.
each
(
data
,
function
(
index
,
value
)
{
value
[
"pId"
]
=
value
[
"parent"
];
value
[
"name"
]
=
value
[
"value"
];
...
...
@@ -304,6 +304,7 @@ $(document).ready(function(){
if
(
row
.
child
.
isShown
())
{
tr
.
removeClass
(
'details'
);
$
(
this
).
children
(
'i:first-child'
).
removeClass
(
'fa-angle-down'
).
addClass
(
'fa-angle-right'
);
row
.
child
.
hide
();
// Remove from the 'open' array
...
...
@@ -311,7 +312,7 @@ $(document).ready(function(){
}
else
{
tr
.
addClass
(
'details'
);
$
(
'.toggle i
'
).
removeClass
(
'fa-angle-right'
).
addClass
(
'fa-angle-down'
);
$
(
this
).
children
(
'i:first-child
'
).
removeClass
(
'fa-angle-right'
).
addClass
(
'fa-angle-down'
);
row
.
child
(
format
(
row
.
data
())).
show
();
// Add to the 'open' array
if
(
idx
===
-
1
)
{
...
...
apps/perms/views.py
View file @
38f8c5bb
...
...
@@ -42,7 +42,7 @@ class AssetPermissionCreateView(AdminUserRequiredMixin, CreateView):
if
nodes_id
:
nodes_id
=
nodes_id
.
split
(
","
)
nodes
=
Node
.
objects
.
filter
(
id__in
=
nodes_id
)
nodes
=
Node
.
objects
.
filter
(
id__in
=
nodes_id
)
.
exclude
(
id
=
Node
.
root
()
.
id
)
form
[
'nodes'
]
.
initial
=
nodes
if
assets_id
:
assets_id
=
assets_id
.
split
(
","
)
...
...
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