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
30fd51c2
Commit
30fd51c2
authored
Sep 06, 2016
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Asset group detail
parent
dc01833a
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
97 additions
and
42 deletions
+97
-42
models.py
apps/assets/models.py
+46
-18
asset_group_detail.html
apps/assets/templates/assets/asset_group_detail.html
+0
-0
asset_group_list.html
apps/assets/templates/assets/asset_group_list.html
+1
-1
delete_confirm.html
apps/assets/templates/assets/delete_confirm.html
+16
-0
views.py
apps/assets/views.py
+32
-3
django.po
apps/locale/zh/LC_MESSAGES/django.po
+0
-0
jumpserver.css
apps/static/css/jumpserver.css
+1
-0
_list_base.html
apps/templates/_list_base.html
+0
-1
_pagination.html
apps/templates/_pagination.html
+0
-5
user_detail.html
apps/users/templates/users/user_detail.html
+1
-14
No files found.
apps/assets/models.py
View file @
30fd51c2
...
...
@@ -2,19 +2,10 @@
from
__future__
import
unicode_literals
,
absolute_import
from
django.db
import
models
import
logging
from
django.utils.translation
import
ugettext_lazy
as
_
class
AssetGroup
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
64
,
unique
=
True
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'Name'
))
created_by
=
models
.
CharField
(
max_length
=
32
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'Created by'
))
comment
=
models
.
TextField
(
blank
=
True
,
verbose_name
=
_
(
'Comment'
))
def
__unicode__
(
self
):
return
self
.
name
class
Meta
:
db_table
=
'asset_group'
logger
=
logging
.
getLogger
(
__name__
)
class
IDC
(
models
.
Model
):
...
...
@@ -24,7 +15,7 @@ class IDC(models.Model):
phone
=
models
.
CharField
(
max_length
=
32
,
blank
=
True
,
verbose_name
=
_
(
'Phone'
))
address
=
models
.
CharField
(
max_length
=
128
,
blank
=
True
,
verbose_name
=
_
(
"Address"
))
network
=
models
.
TextField
(
blank
=
True
,
verbose_name
=
_
(
'Network'
))
date_created
=
models
.
DateField
(
auto_now
=
True
,
null
=
True
,
verbose_name
=
_
(
'Date added'
))
date_created
=
models
.
Date
Time
Field
(
auto_now
=
True
,
null
=
True
,
verbose_name
=
_
(
'Date added'
))
operator
=
models
.
CharField
(
max_length
=
32
,
blank
=
True
,
verbose_name
=
_
(
'Operator'
))
created_by
=
models
.
CharField
(
max_length
=
32
,
blank
=
True
,
verbose_name
=
_
(
'Created by'
))
comment
=
models
.
TextField
(
blank
=
True
,
verbose_name
=
_
(
'Comment'
))
...
...
@@ -47,7 +38,7 @@ class AssetExtend(models.Model):
return
self
.
name
class
Meta
:
db_table
=
'assetextend'
db_table
=
'asset
_
extend'
class
AdminUser
(
models
.
Model
):
...
...
@@ -65,10 +56,10 @@ class AdminUser(models.Model):
return
self
.
name
class
Meta
:
db_table
=
'adminuser'
db_table
=
'admin
_
user'
class
SysUser
(
models
.
Model
):
class
Sys
tem
User
(
models
.
Model
):
PROTOCOL_CHOICES
=
(
(
'ssh'
,
'ssh'
),
(
'telnet'
,
'telnet'
),
...
...
@@ -94,7 +85,44 @@ class SysUser(models.Model):
return
self
.
name
class
Meta
:
db_table
=
'sysuser'
db_table
=
'system_user'
class
AssetGroup
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
64
,
unique
=
True
,
verbose_name
=
_
(
'Name'
))
system_users
=
models
.
ManyToManyField
(
SystemUser
,
related_name
=
'asset_groups'
,
blank
=
True
)
created_by
=
models
.
CharField
(
max_length
=
32
,
blank
=
True
,
verbose_name
=
_
(
'Created by'
))
date_created
=
models
.
DateTimeField
(
auto_now
=
True
,
null
=
True
,
verbose_name
=
_
(
'Date added'
))
comment
=
models
.
TextField
(
blank
=
True
,
verbose_name
=
_
(
'Comment'
))
def
__unicode__
(
self
):
return
self
.
name
class
Meta
:
db_table
=
'asset_group'
@classmethod
def
initial
(
cls
):
asset_group
=
cls
(
name
=
_
(
'Default'
),
commont
=
_
(
'Default asset group'
))
asset_group
.
save
()
@classmethod
def
generate_fake
(
cls
,
count
=
100
):
from
random
import
seed
import
forgery_py
from
django.db
import
IntegrityError
seed
()
for
i
in
range
(
count
):
group
=
cls
(
name
=
forgery_py
.
name
.
full_name
(),
comment
=
forgery_py
.
lorem_ipsum
.
sentence
(),
created_by
=
'Fake'
)
try
:
group
.
save
()
logger
.
debug
(
'Generate fake asset group:
%
s'
%
group
.
name
)
except
IntegrityError
:
print
(
'Error continue'
)
continue
class
Asset
(
models
.
Model
):
...
...
@@ -106,8 +134,8 @@ class Asset(models.Model):
groups
=
models
.
ManyToManyField
(
AssetGroup
,
related_name
=
'assets'
,
verbose_name
=
_
(
'Asset groups'
))
username
=
models
.
CharField
(
max_length
=
16
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'Admin user'
))
password
=
models
.
CharField
(
max_length
=
256
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
"Admin password"
))
admin_user
=
models
.
ForeignKey
(
AdminUser
,
null
=
True
,
blank
=
True
,
on_delete
=
models
.
SET_NULL
,
verbose_name
=
_
(
"Admin user"
))
sys
_user
=
models
.
ManyToManyField
(
SysUser
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
"System User"
))
admin_user
=
models
.
ForeignKey
(
AdminUser
,
null
=
True
,
on_delete
=
models
.
SET_NULL
,
verbose_name
=
_
(
"Admin user"
))
sys
tem_user
=
models
.
ManyToManyField
(
SystemUser
,
blank
=
True
,
verbose_name
=
_
(
"System User"
))
idc
=
models
.
ForeignKey
(
IDC
,
null
=
True
,
blank
=
True
,
on_delete
=
models
.
SET_NULL
,
verbose_name
=
_
(
'IDC'
))
mac_addr
=
models
.
CharField
(
max_length
=
20
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
"Mac address"
))
brand
=
models
.
CharField
(
max_length
=
64
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'Brand'
))
...
...
apps/assets/templates/assets/asset_group_detail.html
0 → 100644
View file @
30fd51c2
This diff is collapsed.
Click to expand it.
apps/assets/templates/assets/asset_group_list.html
View file @
30fd51c2
...
...
@@ -27,7 +27,7 @@
</a>
</td>
<td
class=
"text-center"
>
{{ asset_group.assets.count }}
</td>
<td
class=
"text-center"
>
{{ asset_group.comment }}
</td>
<td
class=
"text-center"
>
{{ asset_group.comment
|truncatewords:8
}}
</td>
<td
class=
"text-center"
>
<a
href=
"{% url 'assets:asset-group-update' pk=asset_group.id %}"
class=
"btn btn-xs btn-info"
>
{% trans 'Update' %}
</a>
<a
href=
"{% url 'assets:asset-group-delete' pk=asset_group.id %}"
class=
"btn btn-xs btn-danger del"
>
{% trans 'Delete' %}
</a>
...
...
apps/assets/templates/assets/delete_confirm.html
0 → 100644
View file @
30fd51c2
{% load i18n %}
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
{% trans 'Confirm delete' %}
</title>
</head>
<body>
<form
action=
""
method=
"post"
>
{% csrf_token %}
<p>
Are you sure you want to delete "{{ object.name }}"?
</p>
<input
type=
"submit"
value=
"Confirm"
/>
</form>
</body>
</html>
\ No newline at end of file
apps/assets/views.py
View file @
30fd51c2
...
...
@@ -6,6 +6,8 @@ from django.shortcuts import get_object_or_404
from
django.views.generic
import
TemplateView
,
ListView
from
django.urls
import
reverse_lazy
from
django.views.generic.edit
import
CreateView
,
DeleteView
,
FormView
,
UpdateView
from
django.conf
import
settings
from
django.db.models
import
Q
from
django.views.generic
import
TemplateView
,
ListView
from
django.views.generic.edit
import
CreateView
,
DeleteView
,
FormView
,
UpdateView
from
django.urls
import
reverse_lazy
...
...
@@ -70,20 +72,45 @@ class AssetGroupCreateView(CreateView):
class
AssetGroupListView
(
ListView
):
model
=
AssetGroup
paginate_by
=
settings
.
CONFIG
.
DISPLAY_PER_PAGE
context_object_name
=
'asset_group_list'
template_name
=
'assets/asset_group_list.html'
def
get_context_data
(
self
,
**
kwargs
):
context
=
{
'app'
:
_
(
'Assets'
),
'action'
:
_
(
'Asset group list'
)
'action'
:
_
(
'Asset group list'
),
'keyword'
:
self
.
request
.
GET
.
get
(
'keyword'
,
''
)
}
kwargs
.
update
(
context
)
return
super
(
AssetGroupListView
,
self
)
.
get_context_data
(
**
kwargs
)
def
get_queryset
(
self
):
self
.
queryset
=
super
(
AssetGroupListView
,
self
)
.
get_queryset
()
self
.
keyword
=
keyword
=
self
.
request
.
GET
.
get
(
'keyword'
,
''
)
self
.
sort
=
sort
=
self
.
request
.
GET
.
get
(
'sort'
,
'-date_created'
)
if
keyword
:
self
.
queryset
=
self
.
queryset
.
filter
(
Q
(
name__icontains
=
keyword
)
|
Q
(
comment__icontains
=
keyword
))
if
sort
:
self
.
queryset
=
self
.
queryset
.
order_by
(
sort
)
return
self
.
queryset
class
AssetGroupDetailView
(
DetailView
):
pass
template_name
=
'assets/asset_group_detail.html'
model
=
AssetGroup
context_object_name
=
'asset_group'
def
get_context_data
(
self
,
**
kwargs
):
context
=
{
'app'
:
_
(
'Assets'
),
'action'
:
_
(
'Asset group detail'
)
}
kwargs
.
update
(
context
)
return
super
(
AssetGroupDetailView
,
self
)
.
get_context_data
(
**
kwargs
)
class
AssetGroupUpdateView
(
UpdateView
):
...
...
@@ -103,4 +130,6 @@ class AssetGroupUpdateView(UpdateView):
class
AssetGroupDeleteView
(
DeleteView
):
pass
template_name
=
'assets/delete_confirm.html'
model
=
AssetGroup
success_url
=
reverse_lazy
(
'assets:asset-group-list'
)
apps/locale/zh/LC_MESSAGES/django.po
View file @
30fd51c2
This diff is collapsed.
Click to expand it.
apps/static/css/jumpserver.css
View file @
30fd51c2
...
...
@@ -38,6 +38,7 @@ th a {
color
:
white
;
}
.select2-selection--single
,
.select2-selection--multiple
{
border
:
1px
solid
#e5e6e7
!important
;
cursor
:
text
!important
;
...
...
apps/templates/_list_base.html
View file @
30fd51c2
...
...
@@ -22,7 +22,6 @@
<div
class=
"ibox-content"
>
<div
class=
""
>
{# left button add #}
{% block content_left_head %} {% endblock %}
<form
id=
"search_form"
method=
"get"
action=
""
class=
"pull-right mail-search"
>
<div
class=
"input-group"
>
...
...
apps/templates/_pagination.html
View file @
30fd51c2
...
...
@@ -34,11 +34,6 @@
</div>
{% endif %}
<script>
{
#
function
sleep
(
n
)
{
//n表示的毫秒数#}
{
#
var
start
=
new
Date
().
getTime
();
#
}
{
#
while
(
true
)
if
(
new
Date
().
getTime
()
-
start
>
n
)
break
;
#
}
{
#
}
#
}
$
(
document
).
ready
(
function
()
{
$
(
'.page'
).
click
(
function
()
{
var
searchStr
=
location
.
search
;
...
...
apps/users/templates/users/user_detail.html
View file @
30fd51c2
...
...
@@ -19,19 +19,6 @@
</li>
<li><a
href=
""
class=
"text-center"
><i
class=
"fa fa-bar-chart-o"
></i>
{% trans 'User assets' %}
</a></li>
<li><a
href=
""
class=
"text-center"
><i
class=
"fa fa-bar-chart-o"
></i>
{% trans 'User log' %}
</a></li>
<div
class=
""
style=
"float: right"
>
<form
id=
"search_form"
method=
"get"
action=
""
class=
"pull-right mail-search"
>
<div
class=
"input-group"
>
<input
type=
"text"
class=
"form-control input-sm"
id=
"keyword"
name=
"keyword"
value=
"{{ keyword }}"
placeholder=
"Search"
>
<div
class=
"input-group-btn"
>
<button
id=
'search_btn'
type=
"submit"
class=
"btn btn-sm btn-primary"
>
{% trans 'Search' %}
</button>
</div>
</div>
</form>
</div>
</ul>
</div>
<div
class=
"tab-content"
>
...
...
@@ -118,7 +105,7 @@
</div>
</div>
</div>
<div
class=
"col-sm-5"
style=
"padding-left: 0
px;
"
>
<div
class=
"col-sm-5"
style=
"padding-left: 0
;padding-right: 0
"
>
<div
class=
"panel panel-primary"
>
<div
class=
"panel-heading"
>
<i
class=
"fa fa-info-circle"
></i>
{% trans 'Quick modify' %}
...
...
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