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
cdbdc853
Commit
cdbdc853
authored
Jul 03, 2019
by
ibuler
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'bugfix' of github.com:jumpserver/jumpserver into bugfix
parents
c3a54a89
28ec1eb0
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
14 additions
and
1 deletion
+14
-1
django.mo
apps/locale/zh/LC_MESSAGES/django.mo
+0
-0
django.po
apps/locale/zh/LC_MESSAGES/django.po
+0
-0
user_permission.py
apps/perms/api/user_permission.py
+3
-1
const.py
apps/perms/const.py
+1
-0
asset_permission.py
apps/perms/utils/asset_permission.py
+10
-0
No files found.
apps/locale/zh/LC_MESSAGES/django.mo
View file @
cdbdc853
No preview for this file type
apps/locale/zh/LC_MESSAGES/django.po
View file @
cdbdc853
This diff is collapsed.
Click to expand it.
apps/perms/api/user_permission.py
View file @
cdbdc853
...
...
@@ -299,12 +299,14 @@ class UserGrantedNodeAssetsApi(UserPermissionCacheMixin, AssetsFilterMixin, List
nodes
=
util
.
get_nodes_with_assets
()
if
str
(
node_id
)
==
const
.
UNGROUPED_NODE_ID
:
node
=
util
.
tree
.
ungrouped_node
elif
str
(
node_id
)
==
const
.
EMPTY_NODE_ID
:
node
=
util
.
tree
.
empty_node
else
:
node
=
get_object_or_404
(
Node
,
id
=
node_id
)
if
node
==
util
.
tree
.
root_node
:
assets
=
util
.
get_assets
()
else
:
assets
=
nodes
.
get
(
node
,
[]
)
assets
=
nodes
.
get
(
node
,
{}
)
for
asset
,
system_users
in
assets
.
items
():
asset
.
system_users_granted
=
system_users
...
...
apps/perms/const.py
View file @
cdbdc853
...
...
@@ -2,3 +2,4 @@
#
UNGROUPED_NODE_ID
=
"00000000-0000-0000-0000-000000000002"
EMPTY_NODE_ID
=
"00000000-0000-0000-0000-000000000003"
apps/perms/utils/asset_permission.py
View file @
cdbdc853
...
...
@@ -109,6 +109,13 @@ class GenerateTree:
self
.
_ungroup_node
=
node
return
node
@property
def
empty_node
(
self
):
node_id
=
const
.
EMPTY_NODE_ID
value
=
_
(
'Empty'
)
node
=
Node
(
id
=
node_id
,
value
=
value
)
return
node
#@timeit
def
add_assets_without_system_users
(
self
,
assets
):
for
asset
in
assets
:
...
...
@@ -176,6 +183,9 @@ class GenerateTree:
for
node
,
values
in
self
.
nodes
.
items
():
node
.
_assets_amount
=
values
[
"assets_amount"
]
nodes
[
node
]
=
{
asset
:
self
.
assets
.
get
(
asset
,
{})
for
asset
in
values
[
"assets"
]}
# 如果返回空节点,页面构造授权资产树报错
if
not
nodes
:
nodes
[
self
.
empty_node
]
=
{}
self
.
_nodes_with_assets
=
nodes
return
dict
(
nodes
)
...
...
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