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
3ce9d01b
Commit
3ce9d01b
authored
Sep 13, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Bugfix] 修复coco无法查看资产的bug
parent
310bc6ad
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
17 deletions
+21
-17
api.py
apps/perms/api.py
+21
-17
No files found.
apps/perms/api.py
View file @
3ce9d01b
...
@@ -62,14 +62,15 @@ class UserGrantedAssetsApi(ListAPIView):
...
@@ -62,14 +62,15 @@ class UserGrantedAssetsApi(ListAPIView):
"""
"""
permission_classes
=
(
IsOrgAdminOrAppUser
,)
permission_classes
=
(
IsOrgAdminOrAppUser
,)
serializer_class
=
AssetGrantedSerializer
serializer_class
=
AssetGrantedSerializer
def
dispatch
(
self
,
request
,
*
args
,
**
kwargs
):
def
change_org_if_need
(
self
):
if
request
.
user
.
is_superuser
or
request
.
user
.
is_app
or
\
if
self
.
request
.
user
.
is_superuser
or
\
self
.
request
.
user
.
is_app
or
\
self
.
kwargs
.
get
(
'pk'
)
is
None
:
self
.
kwargs
.
get
(
'pk'
)
is
None
:
set_to_root_org
()
set_to_root_org
()
return
super
()
.
dispatch
(
request
,
*
args
,
**
kwargs
)
def
get_queryset
(
self
):
def
get_queryset
(
self
):
self
.
change_org_if_need
()
user_id
=
self
.
kwargs
.
get
(
'pk'
,
''
)
user_id
=
self
.
kwargs
.
get
(
'pk'
,
''
)
queryset
=
[]
queryset
=
[]
...
@@ -97,14 +98,15 @@ class UserGrantedNodesApi(ListAPIView):
...
@@ -97,14 +98,15 @@ class UserGrantedNodesApi(ListAPIView):
"""
"""
permission_classes
=
(
IsOrgAdmin
,)
permission_classes
=
(
IsOrgAdmin
,)
serializer_class
=
NodeSerializer
serializer_class
=
NodeSerializer
def
dispatch
(
self
,
request
,
*
args
,
**
kwargs
):
def
change_org_if_need
(
self
):
if
request
.
user
.
is_superuser
or
request
.
user
.
is_app
or
\
if
self
.
request
.
user
.
is_superuser
or
\
self
.
request
.
user
.
is_app
or
\
self
.
kwargs
.
get
(
'pk'
)
is
None
:
self
.
kwargs
.
get
(
'pk'
)
is
None
:
set_to_root_org
()
set_to_root_org
()
return
super
()
.
dispatch
(
request
,
*
args
,
**
kwargs
)
def
get_queryset
(
self
):
def
get_queryset
(
self
):
self
.
change_org_if_need
()
user_id
=
self
.
kwargs
.
get
(
'pk'
,
''
)
user_id
=
self
.
kwargs
.
get
(
'pk'
,
''
)
if
user_id
:
if
user_id
:
user
=
get_object_or_404
(
User
,
id
=
user_id
)
user
=
get_object_or_404
(
User
,
id
=
user_id
)
...
@@ -126,14 +128,15 @@ class UserGrantedNodesWithAssetsApi(ListAPIView):
...
@@ -126,14 +128,15 @@ class UserGrantedNodesWithAssetsApi(ListAPIView):
"""
"""
permission_classes
=
(
IsOrgAdminOrAppUser
,)
permission_classes
=
(
IsOrgAdminOrAppUser
,)
serializer_class
=
NodeGrantedSerializer
serializer_class
=
NodeGrantedSerializer
def
dispatch
(
self
,
request
,
*
args
,
**
kwargs
):
def
change_org_if_need
(
self
):
if
request
.
user
.
is_superuser
or
request
.
user
.
is_app
or
\
if
self
.
request
.
user
.
is_superuser
or
\
self
.
request
.
user
.
is_app
or
\
self
.
kwargs
.
get
(
'pk'
)
is
None
:
self
.
kwargs
.
get
(
'pk'
)
is
None
:
set_to_root_org
()
set_to_root_org
()
return
super
()
.
dispatch
(
request
,
*
args
,
**
kwargs
)
def
get_queryset
(
self
):
def
get_queryset
(
self
):
self
.
change_org_if_need
()
user_id
=
self
.
kwargs
.
get
(
'pk'
,
''
)
user_id
=
self
.
kwargs
.
get
(
'pk'
,
''
)
queryset
=
[]
queryset
=
[]
if
not
user_id
:
if
not
user_id
:
...
@@ -164,14 +167,15 @@ class UserGrantedNodeAssetsApi(ListAPIView):
...
@@ -164,14 +167,15 @@ class UserGrantedNodeAssetsApi(ListAPIView):
"""
"""
permission_classes
=
(
IsOrgAdminOrAppUser
,)
permission_classes
=
(
IsOrgAdminOrAppUser
,)
serializer_class
=
AssetGrantedSerializer
serializer_class
=
AssetGrantedSerializer
def
dispatch
(
self
,
request
,
*
args
,
**
kwargs
):
def
change_org_if_need
(
self
):
if
request
.
user
.
is_superuser
or
request
.
user
.
is_app
or
\
if
self
.
request
.
user
.
is_superuser
or
\
self
.
request
.
user
.
is_app
or
\
self
.
kwargs
.
get
(
'pk'
)
is
None
:
self
.
kwargs
.
get
(
'pk'
)
is
None
:
set_to_root_org
()
set_to_root_org
()
return
super
()
.
dispatch
(
request
,
*
args
,
**
kwargs
)
def
get_queryset
(
self
):
def
get_queryset
(
self
):
self
.
change_org_if_need
()
user_id
=
self
.
kwargs
.
get
(
'pk'
,
''
)
user_id
=
self
.
kwargs
.
get
(
'pk'
,
''
)
node_id
=
self
.
kwargs
.
get
(
'node_id'
)
node_id
=
self
.
kwargs
.
get
(
'node_id'
)
...
...
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