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
1b6fd4d1
Commit
1b6fd4d1
authored
Dec 16, 2017
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Bugfix] 修改普通用户获取资产详情的bug
parent
0f64d39c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
10 deletions
+5
-10
api.py
apps/assets/api.py
+3
-2
serializers.py
apps/assets/serializers.py
+2
-1
views.py
apps/perms/views.py
+0
-7
No files found.
apps/assets/api.py
View file @
1b6fd4d1
...
@@ -38,10 +38,11 @@ class AssetViewSet(IDInFilterMixin, BulkModelViewSet):
...
@@ -38,10 +38,11 @@ class AssetViewSet(IDInFilterMixin, BulkModelViewSet):
permission_classes
=
(
IsValidUser
,)
permission_classes
=
(
IsValidUser
,)
def
get_queryset
(
self
):
def
get_queryset
(
self
):
if
self
.
request
.
user
.
is_superuser
:
if
self
.
request
.
user
.
is_superuser
or
self
.
request
.
user
.
is_app
:
queryset
=
super
()
.
get_queryset
()
queryset
=
super
()
.
get_queryset
()
else
:
else
:
queryset
=
get_user_granted_assets
(
self
.
request
.
user
)
assets_granted
=
get_user_granted_assets
(
self
.
request
.
user
)
queryset
=
self
.
queryset
.
filter
(
id__in
=
[
asset
.
id
for
asset
in
assets_granted
])
cluster_id
=
self
.
request
.
query_params
.
get
(
'cluster_id'
)
cluster_id
=
self
.
request
.
query_params
.
get
(
'cluster_id'
)
asset_group_id
=
self
.
request
.
query_params
.
get
(
'asset_group_id'
)
asset_group_id
=
self
.
request
.
query_params
.
get
(
'asset_group_id'
)
admin_user_id
=
self
.
request
.
query_params
.
get
(
'admin_user_id'
)
admin_user_id
=
self
.
request
.
query_params
.
get
(
'admin_user_id'
)
...
...
apps/assets/serializers.py
View file @
1b6fd4d1
...
@@ -164,7 +164,8 @@ class AssetGrantedSerializer(serializers.ModelSerializer):
...
@@ -164,7 +164,8 @@ class AssetGrantedSerializer(serializers.ModelSerializer):
class
Meta
(
object
):
class
Meta
(
object
):
model
=
Asset
model
=
Asset
fields
=
(
"id"
,
"hostname"
,
"ip"
,
"port"
,
"system_users_granted"
,
fields
=
(
"id"
,
"hostname"
,
"ip"
,
"port"
,
"system_users_granted"
,
"is_inherited"
,
"is_active"
,
"system_users_join"
,
"comment"
)
"is_inherited"
,
"is_active"
,
"system_users_join"
,
"platform"
,
"comment"
,)
@staticmethod
@staticmethod
def
get_is_inherited
(
obj
):
def
get_is_inherited
(
obj
):
...
...
apps/perms/views.py
View file @
1b6fd4d1
...
@@ -122,13 +122,6 @@ class AssetPermissionUpdateView(AdminUserRequiredMixin, UpdateView):
...
@@ -122,13 +122,6 @@ class AssetPermissionUpdateView(AdminUserRequiredMixin, UpdateView):
url
=
url
,
name
=
self
.
object
.
name
url
=
url
,
name
=
self
.
object
.
name
)
)
def
form_valid
(
self
,
form
):
assets
=
form
.
cleaned_data
[
'assets'
]
asset_groups
=
form
.
cleaned_data
[
'asset_groups'
]
system_users
=
form
.
cleaned_data
[
'system_users'
]
associate_system_users_and_assets
(
system_users
,
assets
,
asset_groups
)
return
super
(
AssetPermissionUpdateView
,
self
)
.
form_valid
(
form
)
class
AssetPermissionDetailView
(
AdminUserRequiredMixin
,
DetailView
):
class
AssetPermissionDetailView
(
AdminUserRequiredMixin
,
DetailView
):
template_name
=
'perms/asset_permission_detail.html'
template_name
=
'perms/asset_permission_detail.html'
...
...
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