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
37c10c6c
Unverified
Commit
37c10c6c
authored
Jul 17, 2019
by
BaiJiangJie
Committed by
GitHub
Jul 17, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2976 from jumpserver/dev
[Update] 解决授权资产显示禁用资产的问题 (#2975)
parents
158e2a91
3451c2b4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
10 deletions
+8
-10
asset.py
apps/assets/serializers/asset.py
+1
-1
base.py
apps/assets/serializers/base.py
+2
-0
asset_create.html
apps/assets/templates/assets/asset_create.html
+2
-6
asset_permission.py
apps/perms/utils/asset_permission.py
+3
-3
No files found.
apps/assets/serializers/asset.py
View file @
37c10c6c
...
...
@@ -112,7 +112,7 @@ class AssetSerializer(BulkOrgResourceModelSerializer):
protocol
=
protocols_data
[
0
]
.
split
(
'/'
)
validated_data
[
"protocol"
]
=
protocol
[
0
]
validated_data
[
"port"
]
=
int
(
protocol
[
1
])
if
validated
_data
:
if
protocols
_data
:
validated_data
[
"protocols"
]
=
' '
.
join
(
protocols_data
)
def
create
(
self
,
validated_data
):
...
...
apps/assets/serializers/base.py
View file @
37c10c6c
# -*- coding: utf-8 -*-
#
from
django.utils.translation
import
ugettext
as
_
from
rest_framework
import
serializers
from
common.utils
import
ssh_pubkey_gen
,
validate_ssh_private_key
...
...
apps/assets/templates/assets/asset_create.html
View file @
37c10c6c
...
...
@@ -216,6 +216,8 @@ $(document).ready(function () {
var
form
=
$
(
"form"
);
var
protocols
=
{};
var
data
=
form
.
serializeObject
();
objectAttrsIsBool
(
data
,
[
'is_active'
]);
objectAttrsIsList
(
data
,
[
'nodes'
,
'labels'
]);
$
.
each
(
data
,
function
(
k
,
v
)
{
if
(
k
.
startsWith
(
"form"
)){
delete
data
[
k
];
...
...
@@ -233,12 +235,6 @@ $(document).ready(function () {
return
v
.
name
+
'/'
+
v
.
port
});
data
[
"protocols"
]
=
protocols
;
if
(
typeof
data
.
labels
===
"string"
)
{
data
[
"labels"
]
=
[
data
[
"labels"
]];
}
if
(
typeof
data
[
"nodes"
]
==
"string"
)
{
data
[
"nodes"
]
=
[
data
[
"nodes"
]]
}
var
props
=
{
url
:
the_url
,
data
:
data
,
...
...
apps/perms/utils/asset_permission.py
View file @
37c10c6c
...
...
@@ -499,7 +499,7 @@ class AssetPermissionUtil(AssetPermissionCacheMixin):
if
pattern
:
assets_ids
=
Asset
.
objects
.
filter
(
nodes__key__regex
=
pattern
)
.
values_list
(
"id"
,
flat
=
True
)
.
distinct
()
)
.
val
id
()
.
val
ues_list
(
"id"
,
flat
=
True
)
.
distinct
()
else
:
assets_ids
=
[]
self
.
tree
.
add_assets_without_system_users
(
assets_ids
)
...
...
@@ -523,8 +523,8 @@ class AssetPermissionUtil(AssetPermissionCacheMixin):
assets_ids
=
defaultdict
(
lambda
:
defaultdict
(
int
))
for
perm
in
self
.
permissions
:
actions
=
[
perm
.
actions
]
_assets_ids
=
[
a
.
id
for
a
in
perm
.
assets
.
all
()]
system_users_ids
=
[
s
.
id
for
s
in
perm
.
system_users
.
all
()]
_assets_ids
=
perm
.
assets
.
valid
()
.
values_list
(
"id"
,
flat
=
True
)
system_users_ids
=
perm
.
system_users
.
values_list
(
"id"
,
flat
=
True
)
iterable
=
itertools
.
product
(
_assets_ids
,
system_users_ids
,
actions
)
for
asset_id
,
sys_id
,
action
in
iterable
:
assets_ids
[
asset_id
][
sys_id
]
|=
action
...
...
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