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
4c4f5985
Commit
4c4f5985
authored
Sep 12, 2016
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finish asset permission detail and add user or user group list
parent
7b99a33a
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
57 additions
and
21 deletions
+57
-21
models.py
apps/perms/models.py
+4
-4
asset_permission_detail.html
apps/perms/templates/perms/asset_permission_detail.html
+0
-0
asset_permission_list.html
apps/perms/templates/perms/asset_permission_list.html
+12
-12
asset_permission_user_list.html
apps/perms/templates/perms/asset_permission_user_list.html
+0
-0
urls.py
apps/perms/urls.py
+4
-0
views.py
apps/perms/views.py
+37
-5
No files found.
apps/perms/models.py
View file @
4c4f5985
...
@@ -22,10 +22,10 @@ class AssetPermission(models.Model):
...
@@ -22,10 +22,10 @@ class AssetPermission(models.Model):
asset_groups
=
models
.
ManyToManyField
(
AssetGroup
,
related_name
=
'granted_by_permissions'
,
blank
=
True
)
asset_groups
=
models
.
ManyToManyField
(
AssetGroup
,
related_name
=
'granted_by_permissions'
,
blank
=
True
)
system_users
=
models
.
ManyToManyField
(
SystemUser
,
related_name
=
'granted_by_permissions'
)
system_users
=
models
.
ManyToManyField
(
SystemUser
,
related_name
=
'granted_by_permissions'
)
action
=
models
.
CharField
(
choices
=
ACTION_CHOICE
,
max_length
=
8
,
default
=
'1'
)
action
=
models
.
CharField
(
choices
=
ACTION_CHOICE
,
max_length
=
8
,
default
=
'1'
)
is_active
=
models
.
BooleanField
(
default
=
True
)
is_active
=
models
.
BooleanField
(
default
=
True
,
verbose_name
=
_
(
'Active'
)
)
date_expired
=
models
.
DateTimeField
(
default
=
date_expired_default
,
verbose_name
=
_
(
'Date expired'
))
date_expired
=
models
.
DateTimeField
(
default
=
date_expired_default
,
verbose_name
=
_
(
'Date expired'
))
created_by
=
models
.
CharField
(
max_length
=
128
,
blank
=
True
)
created_by
=
models
.
CharField
(
max_length
=
128
,
blank
=
True
,
verbose_name
=
_
(
'Created by'
)
)
date_created
=
models
.
DateTimeField
(
auto_now
=
True
)
date_created
=
models
.
DateTimeField
(
auto_now
=
True
,
verbose_name
=
_
(
'Date created'
)
)
comment
=
models
.
TextField
(
verbose_name
=
_
(
'Comment'
),
blank
=
True
)
comment
=
models
.
TextField
(
verbose_name
=
_
(
'Comment'
),
blank
=
True
)
def
__unicode__
(
self
):
def
__unicode__
(
self
):
...
@@ -33,7 +33,7 @@ class AssetPermission(models.Model):
...
@@ -33,7 +33,7 @@ class AssetPermission(models.Model):
@property
@property
def
is_valid
(
self
):
def
is_valid
(
self
):
if
self
.
date_expired
<
timezone
.
now
()
and
is_active
:
if
self
.
date_expired
<
timezone
.
now
()
and
self
.
is_active
:
return
True
return
True
return
True
return
True
...
...
apps/perms/templates/perms/asset_permission_detail.html
0 → 100644
View file @
4c4f5985
This diff is collapsed.
Click to expand it.
apps/perms/templates/perms/asset_permission_list.html
View file @
4c4f5985
...
@@ -20,31 +20,31 @@
...
@@ -20,31 +20,31 @@
{% endblock %}
{% endblock %}
{% block table_body %}
{% block table_body %}
{% for permission in asset_permission_list %}
{% for
asset_
permission in asset_permission_list %}
<tr
class=
"gradeX"
>
<tr
class=
"gradeX"
>
<td
class=
"text-center"
>
<td
class=
"text-center"
>
<input
type=
"checkbox"
name=
"checked"
value=
"{{ permission.id }}"
>
<input
type=
"checkbox"
name=
"checked"
value=
"{{
asset_
permission.id }}"
>
</td>
</td>
<td
class=
"text-center"
>
<td
class=
"text-center"
>
<a
href=
""
>
<a
href=
"
{% url 'perms:asset-permission-detail' pk=asset_permission.id %}
"
>
{{ permission.name }}
{{
asset_
permission.name }}
</a>
</a>
</td>
</td>
<td
class=
"text-center"
>
{{ permission.users.count}}
</td>
<td
class=
"text-center"
>
{{
asset_
permission.users.count}}
</td>
<td
class=
"text-center"
>
{{ permission.user_groups.count}}
</td>
<td
class=
"text-center"
>
{{
asset_
permission.user_groups.count}}
</td>
<td
class=
"text-center"
>
{{ permission.assets.count }}
</td>
<td
class=
"text-center"
>
{{
asset_
permission.assets.count }}
</td>
<td
class=
"text-center"
>
{{ permission.asset_groups.count }}
</td>
<td
class=
"text-center"
>
{{
asset_
permission.asset_groups.count }}
</td>
<td
class=
"text-center"
>
{{ permission.system_users.count }}
</td>
<td
class=
"text-center"
>
{{
asset_
permission.system_users.count }}
</td>
<td
class=
"text-center"
>
<td
class=
"text-center"
>
{% if permission.is_valid %}
{% if
asset_
permission.is_valid %}
<i
class=
"fa fa-check text-navy"
></i>
<i
class=
"fa fa-check text-navy"
></i>
{% else %}
{% else %}
<i
class=
"fa fa-times text-danger"
></i>
<i
class=
"fa fa-times text-danger"
></i>
{% endif %}
{% endif %}
</td>
</td>
<td
class=
"text-center"
>
<td
class=
"text-center"
>
<a
href=
"{% url 'perms:asset-permission-update' pk=permission.id %}"
class=
"btn btn-xs btn-info"
>
{% trans 'Update' %}
</a>
<a
href=
"{% url 'perms:asset-permission-update' pk=
asset_
permission.id %}"
class=
"btn btn-xs btn-info"
>
{% trans 'Update' %}
</a>
<a
href=
"{% url 'perms:asset-permission-delete' pk=permission.id %}"
class=
"btn btn-xs btn-danger del"
>
{% trans 'Delete' %}
</a>
<a
href=
"{% url 'perms:asset-permission-delete' pk=
asset_
permission.id %}"
class=
"btn btn-xs btn-danger del"
>
{% trans 'Delete' %}
</a>
</td>
</td>
</tr>
</tr>
{% endfor %}
{% endfor %}
...
...
apps/perms/templates/perms/asset_permission_user_list.html
0 → 100644
View file @
4c4f5985
This diff is collapsed.
Click to expand it.
apps/perms/urls.py
View file @
4c4f5985
...
@@ -14,5 +14,9 @@ urlpatterns = [
...
@@ -14,5 +14,9 @@ urlpatterns = [
name
=
'asset-permission-detail'
),
name
=
'asset-permission-detail'
),
url
(
r'^asset-permission/(?P<pk>[0-9]+)/delete$'
,
views
.
AssetPermissionDeleteView
.
as_view
(),
url
(
r'^asset-permission/(?P<pk>[0-9]+)/delete$'
,
views
.
AssetPermissionDeleteView
.
as_view
(),
name
=
'asset-permission-delete'
),
name
=
'asset-permission-delete'
),
url
(
r'^asset-permission/(?P<pk>[0-9]+)/user$'
,
views
.
AssetPermissionUserListView
.
as_view
(),
name
=
'asset-permission-user-list'
),
url
(
r'^asset-permission/(?P<pk>[0-9]+)/asset$'
,
views
.
AssetPermissionAssetListView
.
as_view
(),
name
=
'asset-permission-asset-list'
),
]
]
apps/perms/views.py
View file @
4c4f5985
...
@@ -11,7 +11,7 @@ from django.urls import reverse_lazy
...
@@ -11,7 +11,7 @@ from django.urls import reverse_lazy
from
django.contrib.messages.views
import
SuccessMessageMixin
from
django.contrib.messages.views
import
SuccessMessageMixin
from
django.views.generic.detail
import
DetailView
,
SingleObjectMixin
from
django.views.generic.detail
import
DetailView
,
SingleObjectMixin
from
.hands
import
AdminUserRequiredMixin
,
User
,
UserGroup
from
.hands
import
AdminUserRequiredMixin
,
User
,
UserGroup
,
SystemUser
from
.models
import
AssetPermission
from
.models
import
AssetPermission
from
.forms
import
AssetPermissionForm
from
.forms
import
AssetPermissionForm
...
@@ -95,14 +95,17 @@ class AssetPermissionUpdateView(AdminUserRequiredMixin, UpdateView):
...
@@ -95,14 +95,17 @@ class AssetPermissionUpdateView(AdminUserRequiredMixin, UpdateView):
class
AssetPermissionDetailView
(
AdminUserRequiredMixin
,
DetailView
):
class
AssetPermissionDetailView
(
AdminUserRequiredMixin
,
DetailView
):
template_name
=
'
assets/system_user
_detail.html'
template_name
=
'
perms/asset_permission
_detail.html'
context_object_name
=
'
system_user
'
context_object_name
=
'
asset_permission
'
model
=
AssetPermission
model
=
AssetPermission
def
get_context_data
(
self
,
**
kwargs
):
def
get_context_data
(
self
,
**
kwargs
):
context
=
{
context
=
{
'app'
:
_
(
'Assets'
),
'app'
:
_
(
'Perms'
),
'action'
:
_
(
'System user detail'
)
'action'
:
_
(
'Asset permission detail'
),
'system_users_remain'
:
[
system_user
for
system_user
in
SystemUser
.
objects
.
all
()
if
system_user
not
in
self
.
object
.
system_users
.
all
()],
'system_users'
:
self
.
object
.
system_users
.
all
(),
}
}
kwargs
.
update
(
context
)
kwargs
.
update
(
context
)
return
super
(
AssetPermissionDetailView
,
self
)
.
get_context_data
(
**
kwargs
)
return
super
(
AssetPermissionDetailView
,
self
)
.
get_context_data
(
**
kwargs
)
...
@@ -112,3 +115,32 @@ class AssetPermissionDeleteView(AdminUserRequiredMixin, DeleteView):
...
@@ -112,3 +115,32 @@ class AssetPermissionDeleteView(AdminUserRequiredMixin, DeleteView):
model
=
AssetPermission
model
=
AssetPermission
template_name
=
'perms/delete_confirm.html'
template_name
=
'perms/delete_confirm.html'
success_url
=
reverse_lazy
(
'perms:asset-permission-list'
)
success_url
=
reverse_lazy
(
'perms:asset-permission-list'
)
class
AssetPermissionUserListView
(
AdminUserRequiredMixin
,
SingleObjectMixin
,
ListView
):
template_name
=
'perms/asset_permission_user_list.html'
context_object_name
=
'asset_permission'
paginate_by
=
settings
.
CONFIG
.
DISPLAY_PER_PAGE
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
self
.
object
=
self
.
get_object
(
queryset
=
AssetPermission
.
objects
.
all
())
return
super
(
AssetPermissionUserListView
,
self
)
.
get
(
request
,
*
args
,
**
kwargs
)
def
get_queryset
(
self
):
return
self
.
object
.
users
.
all
()
def
get_context_data
(
self
,
**
kwargs
):
context
=
{
'app'
:
_
(
'Perms'
),
'action'
:
_
(
'Asset permission user list'
),
'users_remain'
:
[
user
for
user
in
User
.
objects
.
all
()
if
user
not
in
self
.
get_queryset
()],
'user_groups'
:
self
.
object
.
user_groups
.
all
(),
'user_groups_remain'
:
[
user_group
for
user_group
in
UserGroup
.
objects
.
all
()
if
user_group
not
in
self
.
object
.
user_groups
.
all
()]
}
kwargs
.
update
(
context
)
return
super
(
AssetPermissionUserListView
,
self
)
.
get_context_data
(
**
kwargs
)
class
AssetPermissionAssetListView
(
AdminUserRequiredMixin
,
ListView
):
pass
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