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
8f5e91bc
Unverified
Commit
8f5e91bc
authored
5 years ago
by
老广
Committed by
GitHub
5 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 授权显示节点下所有的资产 (#3001)
parent
d97654b8
master
auditor_jym
dev
dev_beta
dev_beta_db
gengmei
node_service
v52
wph
1.5.2
No related merge requests found
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
15 additions
and
7 deletions
+15
-7
user_asset_list.html
apps/assets/templates/assets/user_asset_list.html
+1
-1
user_permission.py
apps/perms/api/user_permission.py
+6
-1
asset_permission.py
apps/perms/utils/asset_permission.py
+4
-2
stack.py
apps/perms/utils/stack.py
+2
-1
user_granted_asset.html
apps/users/templates/users/user_granted_asset.html
+1
-1
user_group_granted_asset.html
apps/users/templates/users/user_group_granted_asset.html
+1
-1
No files found.
apps/assets/templates/assets/user_asset_list.html
View file @
8f5e91bc
...
...
@@ -23,7 +23,7 @@
<script>
var
treeUrl
=
"{% url 'api-perms:my-nodes-as-tree' %}?&cache_policy=1"
;
var
assetTableUrl
=
"{% url 'api-perms:my-assets' %}?cache_policy=1"
;
var
selectUrl
=
'{% url "api-perms:my-node-assets" node_id=DEFAULT_PK %}?cache_policy=1'
;
var
selectUrl
=
'{% url "api-perms:my-node-assets" node_id=DEFAULT_PK %}?cache_policy=1
&all=1
'
;
var
showAssetHref
=
false
;
// Need input default true
var
actions
=
{
targets
:
4
,
createdCell
:
function
(
td
,
cellData
)
{
...
...
This diff is collapsed.
Click to expand it.
apps/perms/api/user_permission.py
View file @
8f5e91bc
...
...
@@ -88,13 +88,18 @@ class UserGrantedNodeAssetsApi(UserPermissionCacheMixin, GrantAssetsMixin, ListA
def
get_queryset
(
self
):
user
=
self
.
get_object
()
query_all
=
self
.
request
.
query_params
.
get
(
"all"
,
"0"
)
==
"1"
self
.
util
=
AssetPermissionUtil
(
user
,
cache_policy
=
self
.
cache_policy
)
key
=
self
.
get_node_key
()
nodes_items
=
self
.
util
.
get_nodes_with_assets
()
assets_system_users
=
{}
if
query_all
:
k
=
"all_assets"
else
:
k
=
"assets"
for
item
in
nodes_items
:
if
item
[
"key"
]
==
key
:
assets_system_users
=
item
[
"assets"
]
assets_system_users
=
item
[
k
]
break
assets
=
[]
for
asset_id
,
system_users
in
assets_system_users
.
items
():
...
...
This diff is collapsed.
Click to expand it.
apps/perms/utils/asset_permission.py
View file @
8f5e91bc
...
...
@@ -203,14 +203,16 @@ class GenerateTree:
nodes
=
[]
for
key
,
values
in
nodes_with_assets_amount
.
items
():
assets
=
{
asset_id
:
self
.
assets
.
get
(
asset_id
)
for
asset_id
in
values
[
"assets"
]}
all_assets
=
{
asset_id
:
self
.
assets
.
get
(
asset_id
)
for
asset_id
in
values
[
"all_assets"
]}
nodes
.
append
({
"key"
:
key
,
"assets"
:
assets
,
"key"
:
key
,
"assets"
:
assets
,
"all_assets"
:
all_assets
,
"assets_amount"
:
values
[
"assets_amount"
]
})
# 如果返回空节点,页面构造授权资产树报错
if
not
nodes
:
nodes
.
append
({
"key"
:
const
.
EMPTY_NODE_KEY
,
"assets"
:
{},
"assets_amount"
:
0
"key"
:
const
.
EMPTY_NODE_KEY
,
"assets"
:
{},
"assets_amount"
:
0
,
"all_assets"
:
{},
})
nodes
.
sort
(
key
=
lambda
n
:
self
.
key_sort
(
n
[
"key"
]))
self
.
_nodes_with_assets
=
nodes
...
...
This diff is collapsed.
Click to expand it.
apps/perms/utils/stack.py
View file @
8f5e91bc
...
...
@@ -102,7 +102,8 @@ class PermAssetsAmountUtil(PermStackUtilMixin):
self
.
debug
(
"出栈: {} 栈顶: {}"
.
format
(
_node
[
'key'
],
self
.
stack
.
top
[
'key'
]
if
self
.
stack
.
top
else
None
)
)
_node
[
"assets_amount"
]
=
len
(
_node
[
"all_assets"
]
|
_node
[
"assets"
])
_node
[
"all_assets"
]
=
_node
[
"all_assets"
]
|
_node
[
"assets"
]
_node
[
"assets_amount"
]
=
len
(
_node
[
"all_assets"
])
self
.
_nodes
[
_node
.
pop
(
"key"
)]
=
_node
if
not
self
.
stack
.
top
:
...
...
This diff is collapsed.
Click to expand it.
apps/users/templates/users/user_granted_asset.html
View file @
8f5e91bc
...
...
@@ -33,7 +33,7 @@
{% block custom_foot_js %}
<script>
var
assetTableUrl
=
"{% url 'api-perms:user-assets' pk=object.id %}?cache_policy=1"
;
var
selectUrl
=
'{% url "api-perms:user-node-assets" pk=object.id node_id=DEFAULT_PK %}?cache_policy=1'
;
var
selectUrl
=
'{% url "api-perms:user-node-assets" pk=object.id node_id=DEFAULT_PK %}?cache_policy=1
&all=1
'
;
var
treeUrl
=
"{% url 'api-perms:user-nodes-as-tree' pk=object.id %}?&cache_policy=1"
;
$
(
document
).
ready
(
function
()
{
...
...
This diff is collapsed.
Click to expand it.
apps/users/templates/users/user_group_granted_asset.html
View file @
8f5e91bc
...
...
@@ -35,7 +35,7 @@
<script>
var
treeUrl
=
"{% url 'api-perms:user-group-nodes-as-tree' pk=object.id %}?cache_policy=1"
;
var
assetTableUrl
=
"{% url 'api-perms:user-group-assets' pk=object.id %}?cache_policy=1"
;
var
selectUrl
=
'{% url "api-perms:user-group-node-assets" pk=object.id node_id=DEFAULT_PK %}?cache_policy=1'
;
var
selectUrl
=
'{% url "api-perms:user-group-node-assets" pk=object.id node_id=DEFAULT_PK %}?cache_policy=1
&all=1
'
;
var
showAssetHref
=
true
;
// Need input default true
...
...
This diff is collapsed.
Click to expand it.
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