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
80415afa
Commit
80415afa
authored
Sep 11, 2019
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 修改asset 过滤资产api
parent
dbb441df
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
5 deletions
+9
-5
asset_permission.py
apps/perms/api/asset_permission.py
+9
-5
No files found.
apps/perms/api/asset_permission.py
View file @
80415afa
...
...
@@ -93,11 +93,15 @@ class AssetPermissionViewSet(viewsets.ModelViewSet):
return
queryset
if
not
assets
:
return
queryset
.
none
()
inherit_nodes
=
set
()
for
asset
in
assets
:
for
node
in
asset
.
nodes
.
all
():
inherit_nodes
.
update
(
set
(
node
.
get_ancestor
(
with_self
=
True
)))
queryset
=
queryset
.
filter
(
Q
(
assets__in
=
assets
)
|
Q
(
nodes__in
=
inherit_nodes
))
inherit_all_nodes
=
set
()
inherit_nodes_keys
=
assets
.
all
()
.
values_list
(
'nodes__key'
,
flat
=
True
)
for
key
in
inherit_nodes_keys
:
ancestor_keys
=
Node
.
get_nodes_ancestor_keys_by_key
(
key
,
with_self
=
True
)
inherit_all_nodes
.
update
(
ancestor_keys
)
queryset
=
queryset
.
filter
(
Q
(
assets__in
=
assets
)
|
Q
(
nodes__key__in
=
inherit_all_nodes
)
)
return
queryset
def
filter_user
(
self
,
queryset
):
...
...
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