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
bb235f3e
Unverified
Commit
bb235f3e
authored
Jul 30, 2019
by
老广
Committed by
GitHub
Jul 30, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 修改获取资产时使用in (#3053)
parent
c706a410
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
7 deletions
+10
-7
utils.py
apps/assets/utils.py
+2
-2
asset_permission.py
apps/perms/utils/asset_permission.py
+8
-5
No files found.
apps/assets/utils.py
View file @
bb235f3e
...
...
@@ -213,10 +213,10 @@ class NodeUtil:
children
.
add
(
node
)
return
list
(
children
)
def
get_children
(
self
,
node
,
with_self
=
True
):
def
get_
all_
children
(
self
,
node
,
with_self
=
True
):
return
self
.
get_all_children_by_key
(
node
.
key
,
with_self
=
with_self
)
def
get_children_keys_by_key
(
self
,
key
,
with_self
=
True
):
def
get_
all_
children_keys_by_key
(
self
,
key
,
with_self
=
True
):
nodes
=
self
.
get_all_children_by_key
(
key
,
with_self
=
with_self
)
return
[
n
.
key
for
n
in
nodes
]
...
...
apps/perms/utils/asset_permission.py
View file @
bb235f3e
...
...
@@ -449,6 +449,8 @@ class AssetPermissionUtil(AssetPermissionCacheMixin):
self
.
_nodes
=
None
self
.
_assets_direct
=
None
self
.
_nodes_direct
=
None
self
.
node_util
=
NodeUtil
()
self
.
tree
.
_node_util
=
self
.
node_util
@staticmethod
def
change_org_if_need
():
...
...
@@ -491,13 +493,14 @@ class AssetPermissionUtil(AssetPermissionCacheMixin):
self
.
tree
.
add_nodes
(
nodes_keys
)
pattern
=
set
()
all_nodes_keys
=
set
()
for
key
in
nodes_keys
:
pattern
.
add
(
r'^{0}$|^{0}:'
.
format
(
key
))
pattern
=
'|'
.
join
(
list
(
pattern
))
if
pattern
:
children_keys
=
self
.
node_util
.
get_all_children_keys_by_key
(
key
)
all_nodes_keys
.
update
(
set
(
children_keys
))
if
all_nodes_keys
:
assets_ids
=
Asset
.
objects
.
filter
(
nodes__key__
regex
=
pattern
nodes__key__
in
=
all_nodes_keys
)
.
valid
()
.
values_list
(
"id"
,
flat
=
True
)
.
distinct
()
else
:
assets_ids
=
[]
...
...
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