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
3b30eb32
Commit
3b30eb32
authored
Nov 15, 2016
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Weiteng
parent
99c36f2a
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
43 additions
and
6 deletions
+43
-6
api.py
apps/perms/api.py
+32
-1
urls.py
apps/perms/urls.py
+7
-1
user_group_asset_permission.html
apps/users/templates/users/user_group_asset_permission.html
+1
-1
user_group_detail.html
apps/users/templates/users/user_group_detail.html
+1
-1
urls.py
apps/users/urls.py
+1
-1
views.py
apps/users/views.py
+1
-1
No files found.
apps/perms/api.py
View file @
3b30eb32
...
...
@@ -7,7 +7,7 @@ from rest_framework import viewsets
from
users.backends
import
IsValidUser
,
IsSuperUser
from
common.utils
import
get_object_or_none
from
.utils
import
get_user_granted_assets
,
get_user_granted_asset_groups
,
get_user_asset_permissions
,
\
get_user_group_asset_permissions
,
get_user_group_granted_assets
get_user_group_asset_permissions
,
get_user_group_granted_assets
,
get_user_group_granted_asset_groups
from
.models
import
AssetPermission
from
.hands
import
AssetGrantedSerializer
,
User
,
UserGroup
,
AssetGroup
,
Asset
,
AssetGroup
,
AssetGroupSerializer
from
.
import
serializers
...
...
@@ -155,3 +155,33 @@ class MyAssetGroupAssetsApi(ListAPIView):
if
asset_group
in
asset
.
groups
.
all
():
queryset
.
append
(
asset
)
return
queryset
class
UserGroupGrantedAssetsApi
(
ListAPIView
):
permission_classes
=
(
IsSuperUser
,)
serializer_class
=
AssetGrantedSerializer
def
get_queryset
(
self
):
user_group_id
=
self
.
kwargs
.
get
(
'pk'
,
''
)
if
user_group_id
:
user_group
=
get_object_or_404
(
User
,
id
=
user_group_id
)
queryset
=
get_user_group_granted_assets
(
user_group
)
else
:
queryset
=
[]
return
queryset
class
UserGroupGrantedAssetGroupsApi
(
ListAPIView
):
permission_classes
=
(
IsSuperUser
,)
serializer_class
=
AssetGroupSerializer
def
get_queryset
(
self
):
user_group_id
=
self
.
kwargs
.
get
(
'pk'
,
''
)
if
user_group_id
:
user_group
=
get_object_or_404
(
User
,
id
=
user_group_id
)
queryset
=
get_user_group_granted_asset_groups
(
user_group
)
else
:
queryset
=
[]
return
queryset
\ No newline at end of file
apps/perms/urls.py
View file @
3b30eb32
...
...
@@ -31,11 +31,17 @@ urlpatterns += [
url
(
r'^v1/user/my/asset-group/(?P<pk>[0-9]+)/assets/$'
,
api
.
MyAssetGroupAssetsApi
.
as_view
(),
name
=
'user-my-asset-group-assets'
),
# Select user
or user group permission of asset or
asset group
# Select user
permission of asset and
asset group
url
(
r'^v1/user/(?P<pk>[0-9]+)/assets/$'
,
api
.
UserGrantedAssetsApi
.
as_view
(),
name
=
'api-user-assets'
),
url
(
r'^v1/user/(?P<pk>[0-9]+)/asset-groups/$'
,
api
.
UserGrantedAssetGroupsApi
.
as_view
(),
name
=
'api-user-asset-groups'
),
# Select user group permission of asset and asset group
url
(
r'^v1/user-group/(?P<pk>[0-9]+)/assets/$'
,
api
.
UserGroupGrantedAssetsApi
.
as_view
(),
name
=
'api-user-group-assets'
),
url
(
r'^v1/user-group/(?P<pk>[0-9]+)/asset-groups/$'
,
api
.
UserGroupGrantedAssetGroupsApi
.
as_view
(),
name
=
'api-user-group-asset-groups'
),
# Revoke permission api
url
(
r'^v1/asset-permissions/user/revoke/'
,
api
.
RevokeUserAssetPermission
.
as_view
(),
name
=
'revoke-user-asset-permission'
),
...
...
apps/users/templates/users/user_group_asset_permission.html
View file @
3b30eb32
...
...
@@ -23,7 +23,7 @@
<a
href=
"{% url 'users:user-group-asset-permission' pk=user_group.id %}"
class=
"text-center"
><i
class=
"fa fa-bar-chart-o"
></i>
{% trans 'Asset permission' %}
</a>
</li>
<li>
<a
href=
"{% url 'users:user-granted-asset' pk=user_group.id %}"
class=
"text-center"
><i
class=
"fa fa-cubes"
></i>
{% trans 'Asset granted' %}
</a>
<a
href=
"{% url 'users:user-gr
oup-gr
anted-asset' pk=user_group.id %}"
class=
"text-center"
><i
class=
"fa fa-cubes"
></i>
{% trans 'Asset granted' %}
</a>
</li>
</ul>
</div>
...
...
apps/users/templates/users/user_group_detail.html
View file @
3b30eb32
...
...
@@ -25,7 +25,7 @@
<a
href=
"{% url 'users:user-group-asset-permission' pk=user_group.id %}"
class=
"text-center"
><i
class=
"fa fa-bar-chart-o"
></i>
{% trans 'Asset permission' %}
</a>
</li>
<li>
<a
href=
"{% url 'users:user-granted-asset' pk=user.id %}"
class=
"text-center"
><i
class=
"fa fa-cubes"
></i>
{% trans 'Asset granted' %}
</a>
<a
href=
"{% url 'users:user-gr
oup-gr
anted-asset' pk=user.id %}"
class=
"text-center"
><i
class=
"fa fa-cubes"
></i>
{% trans 'Asset granted' %}
</a>
</li>
<li
class=
"pull-right"
>
<a
class=
"btn btn-outline btn-default"
href=
"{% url 'users:user-group-update' pk=user_group.id %}"
><i
class=
"fa fa-edit"
></i>
Update
</a>
...
...
apps/users/urls.py
View file @
3b30eb32
...
...
@@ -36,7 +36,7 @@ urlpatterns = [
url
(
r'^user-group/(?P<pk>[0-9]+)/update$'
,
views
.
UserGroupUpdateView
.
as_view
(),
name
=
'user-group-update'
),
url
(
r'^user-group/(?P<pk>[0-9]+)/asset-permission$'
,
views
.
UserGroupAssetPermissionView
.
as_view
(),
name
=
'user-group-asset-permission'
),
url
(
r'^user-group/(?P<pk>[0-9]+)/asset-permission/create$'
,
views
.
UserAssetPermissionCreateView
.
as_view
(),
url
(
r'^user-group/(?P<pk>[0-9]+)/asset-permission/create$'
,
views
.
User
Group
AssetPermissionCreateView
.
as_view
(),
name
=
'user-group-asset-permission-create'
),
url
(
r'^user-group/(?P<pk>[0-9]+)/assets'
,
views
.
UserGroupGrantedAssetView
.
as_view
(),
name
=
'user-group-granted-asset'
),
...
...
apps/users/views.py
View file @
3b30eb32
...
...
@@ -414,7 +414,7 @@ class UserAssetPermissionCreateView(AdminUserRequiredMixin, CreateView):
class
UserGroupAssetPermissionCreateView
(
AdminUserRequiredMixin
,
CreateView
):
form_class
=
forms
.
UserPrivateAssetPermissionForm
form_class
=
forms
.
User
Group
PrivateAssetPermissionForm
model
=
AssetPermission
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
...
...
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