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
e2329626
Commit
e2329626
authored
Sep 16, 2016
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update some template
parent
06b2c623
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
144 additions
and
130 deletions
+144
-130
models.py
apps/assets/models.py
+15
-0
admin_user_detail.html
apps/assets/templates/assets/admin_user_detail.html
+31
-11
system_user_asset.html
apps/assets/templates/assets/system_user_asset.html
+50
-10
system_user_detail.html
apps/assets/templates/assets/system_user_detail.html
+1
-5
system_user_list.html
apps/assets/templates/assets/system_user_list.html
+2
-2
urls.py
apps/assets/urls.py
+2
-2
views.py
apps/assets/views.py
+31
-24
asset_permission_asset.html
apps/perms/templates/perms/asset_permission_asset.html
+0
-0
asset_permission_user.html
apps/perms/templates/perms/asset_permission_user.html
+0
-0
perm_user_asset_list.html
apps/perms/templates/perms/perm_user_asset_list.html
+0
-66
urls.py
apps/perms/urls.py
+2
-2
views.py
apps/perms/views.py
+8
-8
jumpserver.css
apps/static/css/jumpserver.css
+2
-0
No files found.
apps/assets/models.py
View file @
e2329626
...
@@ -194,6 +194,21 @@ class SystemUser(models.Model):
...
@@ -194,6 +194,21 @@ class SystemUser(models.Model):
def
public_key
(
self
,
public_key_raw
):
def
public_key
(
self
,
public_key_raw
):
self
.
_public_key
=
encrypt
(
public_key_raw
)
self
.
_public_key
=
encrypt
(
public_key_raw
)
def
get_assets_inherit_from_asset_groups
(
self
):
assets
=
set
()
asset_groups
=
self
.
asset_groups
.
all
()
for
asset_group
in
asset_groups
:
for
asset
in
asset_group
.
assets
.
all
():
setattr
(
asset
,
'is_inherit_from_asset_groups'
,
True
)
setattr
(
asset
,
'inherit_from_asset_groups'
,
getattr
(
asset
,
b
'inherit_from_asset_groups'
,
set
())
.
add
(
asset_group
))
assets
.
add
(
asset
)
return
assets
def
get_assets
(
self
):
assets
=
set
(
self
.
assets
.
all
())
|
self
.
get_assets_inherit_from_asset_groups
()
return
list
(
assets
)
class
Meta
:
class
Meta
:
db_table
=
'system_user'
db_table
=
'system_user'
...
...
apps/assets/templates/assets/admin_user_detail.html
View file @
e2329626
...
@@ -15,9 +15,9 @@
...
@@ -15,9 +15,9 @@
<div
class=
"ibox float-e-margins"
>
<div
class=
"ibox float-e-margins"
>
<div
class=
"panel-options"
>
<div
class=
"panel-options"
>
<ul
class=
"nav nav-tabs"
>
<ul
class=
"nav nav-tabs"
>
<li
class=
"active"
><a
href=
""
class=
"text-center"
><i
class=
"fa fa-laptop"
></i>
{% trans 'Detail' %}
</a>
<li
class=
"active"
>
<a
href=
""
class=
"text-center"
><i
class=
"fa fa-laptop"
></i>
{% trans 'Detail' %}
</a>
</li>
</li>
<li><a
href=
""
class=
"text-center"
><i
class=
"fa fa-bar-chart-o"
></i>
{% trans 'Associate assets' %}
</a></li>
</ul>
</ul>
</div>
</div>
<div
class=
"tab-content"
>
<div
class=
"tab-content"
>
...
@@ -33,10 +33,6 @@
...
@@ -33,10 +33,6 @@
<i
class=
"fa fa-wrench"
></i>
<i
class=
"fa fa-wrench"
></i>
</a>
</a>
<ul
class=
"dropdown-menu dropdown-user"
>
<ul
class=
"dropdown-menu dropdown-user"
>
<li><a
href=
"#"
></a>
</li>
<li><a
href=
"#"
></a>
</li>
</ul>
</ul>
<a
class=
"close-link"
>
<a
class=
"close-link"
>
<i
class=
"fa fa-times"
></i>
<i
class=
"fa fa-times"
></i>
...
@@ -73,7 +69,7 @@
...
@@ -73,7 +69,7 @@
<div
class=
"ibox float-e-margins"
>
<div
class=
"ibox float-e-margins"
>
<div
class=
"ibox-title"
>
<div
class=
"ibox-title"
>
<span
style=
"float: left"
>
{% trans 'Asset list of ' %}
<b>
{{ admin_user.name }}
</b></span>
<span
style=
"float: left"
>
{% trans 'Asset list of ' %}
<b>
{{ admin_user.name }}
</b>
<span
class=
"badge"
>
{{ paginator.count }}
</span>
</span>
<div
class=
"ibox-tools"
>
<div
class=
"ibox-tools"
>
<a
class=
"collapse-link"
>
<a
class=
"collapse-link"
>
<i
class=
"fa fa-chevron-up"
></i>
<i
class=
"fa fa-chevron-up"
></i>
...
@@ -82,10 +78,6 @@
...
@@ -82,10 +78,6 @@
<i
class=
"fa fa-wrench"
></i>
<i
class=
"fa fa-wrench"
></i>
</a>
</a>
<ul
class=
"dropdown-menu dropdown-user"
>
<ul
class=
"dropdown-menu dropdown-user"
>
<li><a
href=
"#"
></a>
</li>
<li><a
href=
"#"
></a>
</li>
</ul>
</ul>
<a
class=
"close-link"
>
<a
class=
"close-link"
>
<i
class=
"fa fa-times"
></i>
<i
class=
"fa fa-times"
></i>
...
@@ -185,6 +177,34 @@
...
@@ -185,6 +177,34 @@
</table>
</table>
</div>
</div>
</div>
</div>
<div
class=
"panel panel-warning"
>
<div
class=
"panel-heading"
>
<i
class=
"fa fa-info-circle"
></i>
{% trans 'Replace asset admin user with this admin user' %}
</div>
<div
class=
"panel-body"
>
<table
class=
"table"
>
<tbody>
<form>
<tr
class=
"no-borders-tr"
>
<td
colspan=
"2"
>
<select
data-placeholder=
"{% trans 'Select asset groups' %}"
class=
"select2"
style=
"width: 100%"
multiple=
""
tabindex=
"4"
>
{% for group in groups %}
<option
value=
"{{ group.id }}"
>
{{ group.name }}
</option>
{% endfor %}
</select>
</td>
</tr>
<tr
class=
"no-borders-tr"
>
<td
colspan=
"2"
>
<button
type=
"button"
class=
"btn btn-warning btn-sm"
>
{% trans 'Replace' %}
</button>
</td>
</tr>
</form>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
...
...
apps/assets/templates/assets/system_user_asset.html
View file @
e2329626
...
@@ -19,10 +19,7 @@
...
@@ -19,10 +19,7 @@
<a
href=
"{% url 'assets:system-user-detail' pk=system_user.id %}"
class=
"text-center"
><i
class=
"fa fa-laptop"
></i>
{% trans 'Detail' %}
</a>
<a
href=
"{% url 'assets:system-user-detail' pk=system_user.id %}"
class=
"text-center"
><i
class=
"fa fa-laptop"
></i>
{% trans 'Detail' %}
</a>
</li>
</li>
<li
class=
"active"
><a
href=
"{% url 'assets:system-user-asset' pk=system_user.id %}"
class=
"text-center"
>
<li
class=
"active"
><a
href=
"{% url 'assets:system-user-asset' pk=system_user.id %}"
class=
"text-center"
>
<i
class=
"fa fa-bar-chart-o"
></i>
{% trans 'Associate assets' %}
</a>
<i
class=
"fa fa-bar-chart-o"
></i>
{% trans 'Associate assets and asset groups' %}
</a>
</li>
<li><a
href=
"{% url 'assets:system-user-asset-group' pk=system_user.id %}"
class=
"text-center"
>
<i
class=
"fa fa-bar-chart-o"
></i>
{% trans 'Associate asset groups' %}
</a>
</li>
</li>
</ul>
</ul>
</div>
</div>
...
@@ -30,7 +27,7 @@
...
@@ -30,7 +27,7 @@
<div
class=
"col-sm-7"
style=
"padding-left: 0;"
>
<div
class=
"col-sm-7"
style=
"padding-left: 0;"
>
<div
class=
"ibox float-e-margins"
>
<div
class=
"ibox float-e-margins"
>
<div
class=
"ibox-title"
>
<div
class=
"ibox-title"
>
<span
style=
"float: left"
>
{% trans 'Asset
list of ' %}
<b>
{{ admin_user.name }}
</b
></span>
<span
style=
"float: left"
>
{% trans 'Asset
s attached of ' %}
<b>
{{ system_user.name }}
</b><span
class=
"badge"
>
{{ paginator.count }}
</span
></span>
<div
class=
"ibox-tools"
>
<div
class=
"ibox-tools"
>
<a
class=
"collapse-link"
>
<a
class=
"collapse-link"
>
<i
class=
"fa fa-chevron-up"
></i>
<i
class=
"fa fa-chevron-up"
></i>
...
@@ -52,7 +49,8 @@
...
@@ -52,7 +49,8 @@
<th>
{% trans 'Hostname' %}
</th>
<th>
{% trans 'Hostname' %}
</th>
<th>
{% trans 'IP' %}
</th>
<th>
{% trans 'IP' %}
</th>
<th>
{% trans 'Port' %}
</th>
<th>
{% trans 'Port' %}
</th>
<th>
{% trans 'Alive' %}
</th>
<th>
{% trans 'Reachable' %}
</th>
<th></th>
</tr>
</tr>
</thead>
</thead>
<tbody>
<tbody>
...
@@ -61,7 +59,12 @@
...
@@ -61,7 +59,12 @@
<td>
{{ asset.hostname }}
</td>
<td>
{{ asset.hostname }}
</td>
<td>
{{ asset.ip }}
</td>
<td>
{{ asset.ip }}
</td>
<td>
{{ asset.port }}
</td>
<td>
{{ asset.port }}
</td>
<td>
Alive
</td>
<td>
<i
class=
"fa fa-check text-navy"
></i>
</td>
<td>
<button
class=
"btn btn-danger pull-right btn-xs {% if asset.is_inherit_from_asset_groups %} disabled {% endif %}"
type=
"button"
><i
class=
"fa fa-minus"
></i></button>
</td>
</tr>
</tr>
{% endfor %}
{% endfor %}
</tbody>
</tbody>
...
@@ -75,7 +78,7 @@
...
@@ -75,7 +78,7 @@
<div
class=
"col-sm-5"
style=
"padding-left: 0;padding-right: 0"
>
<div
class=
"col-sm-5"
style=
"padding-left: 0;padding-right: 0"
>
<div
class=
"panel panel-primary"
>
<div
class=
"panel panel-primary"
>
<div
class=
"panel-heading"
>
<div
class=
"panel-heading"
>
<i
class=
"fa fa-info-circle"
></i>
{% trans 'A
dd asset to this system user
' %}
<i
class=
"fa fa-info-circle"
></i>
{% trans 'A
ttach to assets
' %}
</div>
</div>
<div
class=
"panel-body"
>
<div
class=
"panel-body"
>
<table
class=
"table"
>
<table
class=
"table"
>
...
@@ -84,7 +87,7 @@
...
@@ -84,7 +87,7 @@
<tr
class=
"no-borders-tr"
>
<tr
class=
"no-borders-tr"
>
<td
colspan=
"2"
>
<td
colspan=
"2"
>
<select
data-placeholder=
"{% trans 'Select asset' %}"
class=
"select2"
style=
"width: 100%"
multiple=
""
tabindex=
"4"
>
<select
data-placeholder=
"{% trans 'Select asset' %}"
class=
"select2"
style=
"width: 100%"
multiple=
""
tabindex=
"4"
>
{% for asset in assets %}
{% for asset in assets
_remain
%}
<option
value=
"{{ asset.id }}"
>
{{ asset.ip}}:{{ asset.port }}
</option>
<option
value=
"{{ asset.id }}"
>
{{ asset.ip}}:{{ asset.port }}
</option>
{% endfor %}
{% endfor %}
</select>
</select>
...
@@ -92,7 +95,7 @@
...
@@ -92,7 +95,7 @@
</tr>
</tr>
<tr
class=
"no-borders-tr"
>
<tr
class=
"no-borders-tr"
>
<td
colspan=
"2"
>
<td
colspan=
"2"
>
<button
type=
"button"
class=
"btn btn-primary btn-sm"
>
{% trans 'A
dd
' %}
</button>
<button
type=
"button"
class=
"btn btn-primary btn-sm"
>
{% trans 'A
ttach
' %}
</button>
</td>
</td>
</tr>
</tr>
</form>
</form>
...
@@ -100,6 +103,43 @@
...
@@ -100,6 +103,43 @@
</table>
</table>
</div>
</div>
</div>
</div>
<div
class=
"panel panel-info"
>
<div
class=
"panel-heading"
>
<i
class=
"fa fa-info-circle"
></i>
{% trans 'Attach to asset groups' %}
</div>
<div
class=
"panel-body"
>
<table
class=
"table group_edit"
>
<tbody>
<form>
<tr>
<td
colspan=
"2"
class=
"no-borders"
>
<select
data-placeholder=
"{% trans 'Add asset group' %}"
class=
"select2"
style=
"width: 100%"
multiple=
""
tabindex=
"4"
>
{% for asset_group in asset_groups_remain %}
<option
value=
"{{ asset_group.id }}"
>
{{ asset_group.name }}
</option>
{% endfor %}
</select>
</td>
</tr>
<tr>
<td
colspan=
"2"
class=
"no-borders"
>
<button
type=
"button"
class=
"btn btn-info btn-sm"
id=
"btn_add_user_group"
>
{% trans 'Attach' %}
</button>
</td>
</tr>
</form>
{% for asset_group in asset_groups %}
<tr>
<td
><b
data-gid=
{{
asset_group
.
id
}}
>
{{ asset_group.name }}
</b></td>
<td>
<button
class=
"btn btn-danger pull-right btn-xs"
type=
"button"
><i
class=
"fa fa-minus"
></i></button>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
...
...
apps/assets/templates/assets/system_user_detail.html
View file @
e2329626
...
@@ -20,13 +20,9 @@
...
@@ -20,13 +20,9 @@
</li>
</li>
<li>
<li>
<a
href=
"{% url 'assets:system-user-asset' pk=system_user.id %}"
class=
"text-center"
>
<a
href=
"{% url 'assets:system-user-asset' pk=system_user.id %}"
class=
"text-center"
>
<i
class=
"fa fa-bar-chart-o"
></i>
{% trans 'Associate assets' %}
<i
class=
"fa fa-bar-chart-o"
></i>
{% trans 'Associate assets
and asset groups
' %}
</a>
</a>
</li>
</li>
<li>
<a
href=
"{% url 'assets:system-user-asset-group' pk=system_user.id %}"
class=
"text-center"
>
<i
class=
"fa fa-bar-chart-o"
></i>
{% trans 'Associate asset groups' %}
</a>
</li>
</ul>
</ul>
</div>
</div>
<div
class=
"tab-content"
>
<div
class=
"tab-content"
>
...
...
apps/assets/templates/assets/system_user_list.html
View file @
e2329626
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
<th
class=
"text-center"
><a
href=
"{% url 'assets:system-user-list' %}?sort=username"
>
{% trans 'Username' %}
</a></th>
<th
class=
"text-center"
><a
href=
"{% url 'assets:system-user-list' %}?sort=username"
>
{% trans 'Username' %}
</a></th>
<th
class=
"text-center"
>
{% trans 'Asset num' %}
</th>
<th
class=
"text-center"
>
{% trans 'Asset num' %}
</th>
<th
class=
"text-center"
>
{% trans 'Asset group num' %}
</th>
<th
class=
"text-center"
>
{% trans 'Asset group num' %}
</th>
<th
class=
"text-center"
>
{% trans 'Un
avail
able' %}
</th>
<th
class=
"text-center"
>
{% trans 'Un
reach
able' %}
</th>
<th
class=
"text-center"
>
{% trans 'Comment' %}
</th>
<th
class=
"text-center"
>
{% trans 'Comment' %}
</th>
<th
class=
"text-center"
></th>
<th
class=
"text-center"
></th>
{% endblock %}
{% endblock %}
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
</a>
</a>
</td>
</td>
<td
class=
"text-center"
>
{{ system_user.username }}
</td>
<td
class=
"text-center"
>
{{ system_user.username }}
</td>
<td
class=
"text-center"
>
{{ system_user.
assets.count
}}
</td>
<td
class=
"text-center"
>
{{ system_user.
get_assets|length
}}
</td>
<td
class=
"text-center"
>
{{ system_user.asset_groups.count }}
</td>
<td
class=
"text-center"
>
{{ system_user.asset_groups.count }}
</td>
<td
class=
"text-center"
>
{{ system_user.assets.count }}
</td>
<td
class=
"text-center"
>
{{ system_user.assets.count }}
</td>
<td
class=
"text-center"
>
{{ system_user.comment|truncatewords:4 }}
</td>
<td
class=
"text-center"
>
{{ system_user.comment|truncatewords:4 }}
</td>
...
...
apps/assets/urls.py
View file @
e2329626
...
@@ -48,7 +48,7 @@ urlpatterns = [
...
@@ -48,7 +48,7 @@ urlpatterns = [
url
(
r'^system-user/(?P<pk>[0-9]+)/update'
,
views
.
SystemUserUpdateView
.
as_view
(),
name
=
'system-user-update'
),
url
(
r'^system-user/(?P<pk>[0-9]+)/update'
,
views
.
SystemUserUpdateView
.
as_view
(),
name
=
'system-user-update'
),
url
(
r'^system-user/(?P<pk>[0-9]+)/delete$'
,
views
.
SystemUserDeleteView
.
as_view
(),
name
=
'system-user-delete'
),
url
(
r'^system-user/(?P<pk>[0-9]+)/delete$'
,
views
.
SystemUserDeleteView
.
as_view
(),
name
=
'system-user-delete'
),
url
(
r'^system-user/(?P<pk>[0-9]+)/asset$'
,
views
.
SystemUserAssetView
.
as_view
(),
name
=
'system-user-asset'
),
url
(
r'^system-user/(?P<pk>[0-9]+)/asset$'
,
views
.
SystemUserAssetView
.
as_view
(),
name
=
'system-user-asset'
),
url
(
r'^system-user/(?P<pk>[0-9]+)/asset-group$'
,
views
.
SystemUserAssetGroupView
.
as_view
(),
#
url(r'^system-user/(?P<pk>[0-9]+)/asset-group$', views.SystemUserAssetGroupView.as_view(),
name
=
'system-user-asset-group'
),
#
name='system-user-asset-group'),
# url(r'^api/v1.0/', include(router.urls)),
# url(r'^api/v1.0/', include(router.urls)),
]
]
apps/assets/views.py
View file @
e2329626
...
@@ -365,7 +365,6 @@ class SystemUserUpdateView(AdminUserRequiredMixin, UpdateView):
...
@@ -365,7 +365,6 @@ class SystemUserUpdateView(AdminUserRequiredMixin, UpdateView):
model
=
SystemUser
model
=
SystemUser
form_class
=
SystemUserForm
form_class
=
SystemUserForm
template_name
=
'assets/system_user_create_update.html'
template_name
=
'assets/system_user_create_update.html'
success_message
=
_
(
'Update system user <a href="
%
s">
%
s</a> successfully.'
)
def
get_context_data
(
self
,
**
kwargs
):
def
get_context_data
(
self
,
**
kwargs
):
context
=
{
context
=
{
...
@@ -376,7 +375,7 @@ class SystemUserUpdateView(AdminUserRequiredMixin, UpdateView):
...
@@ -376,7 +375,7 @@ class SystemUserUpdateView(AdminUserRequiredMixin, UpdateView):
return
super
(
SystemUserUpdateView
,
self
)
.
get_context_data
(
**
kwargs
)
return
super
(
SystemUserUpdateView
,
self
)
.
get_context_data
(
**
kwargs
)
def
get_success_url
(
self
):
def
get_success_url
(
self
):
success_url
=
reverse_lazy
(
'assets:system-user-detail'
,
pk
=
self
.
object
.
pk
)
success_url
=
reverse_lazy
(
'assets:system-user-detail'
,
kwargs
=
{
'pk'
:
self
.
object
.
pk
}
)
return
success_url
return
success_url
...
@@ -409,39 +408,47 @@ class SystemUserAssetView(AdminUserRequiredMixin, SingleObjectMixin, ListView):
...
@@ -409,39 +408,47 @@ class SystemUserAssetView(AdminUserRequiredMixin, SingleObjectMixin, ListView):
self
.
object
=
self
.
get_object
(
queryset
=
SystemUser
.
objects
.
all
())
self
.
object
=
self
.
get_object
(
queryset
=
SystemUser
.
objects
.
all
())
return
super
(
SystemUserAssetView
,
self
)
.
get
(
request
,
*
args
,
**
kwargs
)
return
super
(
SystemUserAssetView
,
self
)
.
get
(
request
,
*
args
,
**
kwargs
)
def
get_asset_groups
(
self
):
return
self
.
object
.
asset_groups
.
all
()
# Todo: queryset default order by connectivity, need ops support
# Todo: queryset default order by connectivity, need ops support
def
get_queryset
(
self
):
def
get_queryset
(
self
):
return
self
.
object
.
assets
.
all
(
)
return
list
(
self
.
object
.
get_assets
()
)
def
get_context_data
(
self
,
**
kwargs
):
def
get_context_data
(
self
,
**
kwargs
):
asset_groups
=
self
.
get_asset_groups
()
assets
=
self
.
get_queryset
()
context
=
{
context
=
{
'app'
:
'assets'
,
'app'
:
'assets'
,
'action'
:
'System user asset'
,
'action'
:
'System user asset'
,
'assets'
:
self
.
get_queryset
(),
'assets_remain'
:
[
asset
for
asset
in
Asset
.
objects
.
all
()
if
asset
not
in
assets
],
'asset_groups'
:
asset_groups
,
'asset_groups_remain'
:
[
asset_group
for
asset_group
in
AssetGroup
.
objects
.
all
()
if
asset_group
not
in
asset_groups
]
}
}
kwargs
.
update
(
context
)
kwargs
.
update
(
context
)
return
super
(
SystemUserAssetView
,
self
)
.
get_context_data
(
**
kwargs
)
return
super
(
SystemUserAssetView
,
self
)
.
get_context_data
(
**
kwargs
)
class
SystemUserAssetGroupView
(
AdminUserRequiredMixin
,
SingleObjectMixin
,
ListView
):
#
class SystemUserAssetGroupView(AdminUserRequiredMixin, SingleObjectMixin, ListView):
paginate_by
=
settings
.
CONFIG
.
DISPLAY_PER_PAGE
#
paginate_by = settings.CONFIG.DISPLAY_PER_PAGE
template_name
=
'assets/system_user_asset_group.html'
#
template_name = 'assets/system_user_asset_group.html'
context_object_name
=
'system_user'
#
context_object_name = 'system_user'
#
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
#
def get(self, request, *args, **kwargs):
self
.
object
=
self
.
get_object
(
queryset
=
SystemUser
.
objects
.
all
())
#
self.object = self.get_object(queryset=SystemUser.objects.all())
return
super
(
SystemUserAssetGroupView
,
self
)
.
get
(
request
,
*
args
,
**
kwargs
)
#
return super(SystemUserAssetGroupView, self).get(request, *args, **kwargs)
#
# Todo: queryset default order by connectivity, need ops support
# Todo: queryset default order by connectivity, need ops support
def
get_queryset
(
self
):
#
def get_queryset(self):
return
self
.
object
.
asset_groups
.
all
()
#
return self.object.asset_groups.all()
#
def
get_context_data
(
self
,
**
kwargs
):
#
def get_context_data(self, **kwargs):
context
=
{
#
context = {
'app'
:
'assets'
,
#
'app': 'assets',
'action'
:
'System user asset group'
,
#
'action': 'System user asset group',
'asset_groups'
:
self
.
get_queryset
(),
#
'asset_groups': self.get_queryset(),
}
#
}
kwargs
.
update
(
context
)
#
kwargs.update(context)
return
super
(
SystemUserAssetGroupView
,
self
)
.
get_context_data
(
**
kwargs
)
#
return super(SystemUserAssetGroupView, self).get_context_data(**kwargs)
apps/perms/templates/perms/asset_permission_asset
_list
.html
→
apps/perms/templates/perms/asset_permission_asset.html
View file @
e2329626
File moved
apps/perms/templates/perms/asset_permission_user
_list
.html
→
apps/perms/templates/perms/asset_permission_user.html
View file @
e2329626
File moved
apps/perms/templates/perms/perm_user_asset_list.html
deleted
100644 → 0
View file @
06b2c623
{% extends '_list_base.html' %}
{% load i18n %}
{% load common_tags %}
{% block content_left_head %}
<a
href=
"{% url 'users:user-create' %}"
class=
"btn btn-sm btn-primary "
>
{% trans "Create perm " %}
</a>
{% endblock %}
{% block table_head %}
<th
class=
"text-center"
>
<input
type=
"checkbox"
id=
"check_all"
onclick=
"checkAll('check_all', 'checked')"
>
</th>
<th
class=
"text-center"
><a
href=
"{% url 'users:user-list' %}?sort=name"
>
{% trans 'Name' %}
</a></th>
<th
class=
"text-center"
><a
href=
"{% url 'users:user-list' %}?sort=username"
>
{% trans 'Username' %}
</a></th>
<th
class=
"text-center"
>
{% trans 'Role' %}
</th>
<th
class=
"text-center"
>
{% trans 'Asset num' %}
</th>
<th
class=
"text-center"
>
{% trans 'Asset group' %}
</th>
<th
class=
"text-center"
>
{% trans 'System user' %}
</th>
<th
class=
"text-center"
><a
href=
"{% url 'users:user-list' %}?sort=date_expired"
>
{% trans 'Active' %}
</a></th>
<th
class=
"text-center"
></th>
{% endblock %}
{% block table_body %}
{% for perm in page_obj %}
<tr
class=
"gradeX"
>
<td
class=
"text-center"
>
<input
type=
"checkbox"
name=
"checked"
value=
"{{ user.id }}"
>
</td>
<td
class=
"text-center"
>
<a
href=
"{% url 'users:user-detail' pk=user.id %}"
>
{{ user.name }}
</a>
</td>
<td
class=
"text-center"
>
{{ user.username }}
</td>
<td
class=
"text-center"
>
{{ user.get_role_display }}
</td>
<th
class=
"text-center"
>
35/40
</th>
<th
class=
"text-center"
>
20
</th>
<th
class=
"text-center"
>
3
</th>
<td
class=
"text-center"
>
<a
href=
"{% url 'perms:perm-user-asset-create' pk=user.id %}"
class=
"btn btn-xs btn-info"
>
{% trans 'Create perm' %}
</a>
<a
href=
"{% url 'users:user-delete' pk=user.id %}"
class=
"btn btn-xs btn-danger del {% if user.id == request.user.id or user.username == 'admin' %} disabled {% endif %}"
>
{% trans 'Flush' %}
</a>
</td>
</tr>
{% endfor %}
{% endblock %}
{% block content_bottom_left %}
<form
id=
""
method=
"get"
action=
""
class=
" mail-search"
>
<div
class=
"input-group"
>
<select
class=
"form-control m-b"
style=
"width: auto"
>
<option>
{% trans 'Delete selected' %}
</option>
<option>
{% trans 'Update selected' %}
</option>
<option>
{% trans 'Deactive selected' %}
</option>
<option>
{% trans 'Export selected' %}
</option>
</select>
<div
class=
"input-group-btn pull-left"
style=
"padding-left: 5px;"
>
<button
id=
'search_btn'
type=
"submit"
style=
"height: 32px;"
class=
"btn btn-sm btn-primary"
>
{% trans 'Submit' %}
</button>
</div>
</div>
</form>
{% endblock %}
apps/perms/urls.py
View file @
e2329626
...
@@ -14,9 +14,9 @@ urlpatterns = [
...
@@ -14,9 +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
.
AssetPermissionUser
List
View
.
as_view
(),
url
(
r'^asset-permission/(?P<pk>[0-9]+)/user$'
,
views
.
AssetPermissionUserView
.
as_view
(),
name
=
'asset-permission-user-list'
),
name
=
'asset-permission-user-list'
),
url
(
r'^asset-permission/(?P<pk>[0-9]+)/asset$'
,
views
.
AssetPermissionAsset
List
View
.
as_view
(),
url
(
r'^asset-permission/(?P<pk>[0-9]+)/asset$'
,
views
.
AssetPermissionAssetView
.
as_view
(),
name
=
'asset-permission-asset-list'
),
name
=
'asset-permission-asset-list'
),
]
]
apps/perms/views.py
View file @
e2329626
...
@@ -120,15 +120,15 @@ class AssetPermissionDeleteView(AdminUserRequiredMixin, DeleteView):
...
@@ -120,15 +120,15 @@ class AssetPermissionDeleteView(AdminUserRequiredMixin, DeleteView):
success_url
=
reverse_lazy
(
'perms:asset-permission-list'
)
success_url
=
reverse_lazy
(
'perms:asset-permission-list'
)
class
AssetPermissionUser
List
View
(
AdminUserRequiredMixin
,
SingleObjectMixin
,
ListView
):
class
AssetPermissionUserView
(
AdminUserRequiredMixin
,
SingleObjectMixin
,
ListView
):
template_name
=
'perms/asset_permission_user
_list
.html'
template_name
=
'perms/asset_permission_user.html'
context_object_name
=
'asset_permission'
context_object_name
=
'asset_permission'
paginate_by
=
settings
.
CONFIG
.
DISPLAY_PER_PAGE
paginate_by
=
settings
.
CONFIG
.
DISPLAY_PER_PAGE
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
self
.
object
=
self
.
get_object
(
queryset
=
AssetPermission
.
objects
.
all
())
self
.
object
=
self
.
get_object
(
queryset
=
AssetPermission
.
objects
.
all
())
self
.
keyword
=
self
.
request
.
GET
.
get
(
'keyword'
,
''
)
self
.
keyword
=
self
.
request
.
GET
.
get
(
'keyword'
,
''
)
return
super
(
AssetPermissionUser
List
View
,
self
)
.
get
(
request
,
*
args
,
**
kwargs
)
return
super
(
AssetPermissionUserView
,
self
)
.
get
(
request
,
*
args
,
**
kwargs
)
def
get_queryset
(
self
):
def
get_queryset
(
self
):
queryset
=
self
.
object
.
get_granted_users
()
queryset
=
self
.
object
.
get_granted_users
()
...
@@ -152,18 +152,18 @@ class AssetPermissionUserListView(AdminUserRequiredMixin, SingleObjectMixin, Lis
...
@@ -152,18 +152,18 @@ class AssetPermissionUserListView(AdminUserRequiredMixin, SingleObjectMixin, Lis
'keyword'
:
self
.
keyword
,
'keyword'
:
self
.
keyword
,
}
}
kwargs
.
update
(
context
)
kwargs
.
update
(
context
)
return
super
(
AssetPermissionUser
List
View
,
self
)
.
get_context_data
(
**
kwargs
)
return
super
(
AssetPermissionUserView
,
self
)
.
get_context_data
(
**
kwargs
)
class
AssetPermissionAsset
List
View
(
AdminUserRequiredMixin
,
SingleObjectMixin
,
ListView
):
class
AssetPermissionAssetView
(
AdminUserRequiredMixin
,
SingleObjectMixin
,
ListView
):
template_name
=
'perms/asset_permission_asset
_list
.html'
template_name
=
'perms/asset_permission_asset.html'
context_object_name
=
'asset_permission'
context_object_name
=
'asset_permission'
paginate_by
=
settings
.
CONFIG
.
DISPLAY_PER_PAGE
paginate_by
=
settings
.
CONFIG
.
DISPLAY_PER_PAGE
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
self
.
object
=
self
.
get_object
(
queryset
=
AssetPermission
.
objects
.
all
())
self
.
object
=
self
.
get_object
(
queryset
=
AssetPermission
.
objects
.
all
())
self
.
keyword
=
self
.
request
.
GET
.
get
(
'keyword'
,
''
)
self
.
keyword
=
self
.
request
.
GET
.
get
(
'keyword'
,
''
)
return
super
(
AssetPermissionAsset
List
View
,
self
)
.
get
(
request
,
*
args
,
**
kwargs
)
return
super
(
AssetPermissionAssetView
,
self
)
.
get
(
request
,
*
args
,
**
kwargs
)
def
get_queryset
(
self
):
def
get_queryset
(
self
):
queryset
=
self
.
object
.
get_granted_assets
()
queryset
=
self
.
object
.
get_granted_assets
()
...
@@ -187,4 +187,4 @@ class AssetPermissionAssetListView(AdminUserRequiredMixin, SingleObjectMixin, Li
...
@@ -187,4 +187,4 @@ class AssetPermissionAssetListView(AdminUserRequiredMixin, SingleObjectMixin, Li
'keyword'
:
self
.
keyword
,
'keyword'
:
self
.
keyword
,
}
}
kwargs
.
update
(
context
)
kwargs
.
update
(
context
)
return
super
(
AssetPermissionAsset
List
View
,
self
)
.
get_context_data
(
**
kwargs
)
return
super
(
AssetPermissionAssetView
,
self
)
.
get_context_data
(
**
kwargs
)
apps/static/css/jumpserver.css
View file @
e2329626
...
@@ -77,3 +77,5 @@ th a {
...
@@ -77,3 +77,5 @@ th a {
.no-borders-tr
td
{
.no-borders-tr
td
{
border-top
:
none
!important
;
border-top
:
none
!important
;
}
}
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