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
d0ba1737
Commit
d0ba1737
authored
Sep 07, 2016
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finish asset group create
parent
30fd51c2
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
120 additions
and
28 deletions
+120
-28
forms.py
apps/assets/forms.py
+3
-0
hands.py
apps/assets/hands.py
+14
-0
models.py
apps/assets/models.py
+19
-0
asset_group_detail.html
apps/assets/templates/assets/asset_group_detail.html
+55
-23
views.py
apps/assets/views.py
+14
-5
hands.py
apps/users/hands.py
+14
-0
urls.py
apps/users/urls.py
+1
-0
No files found.
apps/assets/forms.py
View file @
d0ba1737
...
...
@@ -45,6 +45,9 @@ class AssetGroupForm(forms.ModelForm):
fields
=
[
"name"
,
"comment"
]
help_texts
=
{
'name'
:
'* required'
,
}
class
IdcForm
(
forms
.
ModelForm
):
...
...
apps/assets/hands.py
0 → 100644
View file @
d0ba1737
"""
jumpserver.__app__.hands.py
~~~~~~~~~~~~~~~~~
This app depends other apps api, function .. should be import or write mack here.
Other module of this app shouldn't connect with other app.
:copyright: (c) 2014-2016 by Jumpserver Team.
:license: GPL v2, see LICENSE for more details.
"""
apps/assets/models.py
View file @
d0ba1737
...
...
@@ -165,6 +165,25 @@ class Asset(models.Model):
db_table
=
'asset'
index_together
=
(
'ip'
,
'port'
)
@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
):
asset
=
cls
(
ip
=
'
%
s.
%
s.
%
s.
%
s'
%
tuple
([
forgery_py
.
forgery
.
basic
.
text
(
length
=
3
,
digits
=
True
)
for
i
in
range
(
0
,
4
)]),
port
=
22
,
created_by
=
'Fake'
)
try
:
asset
.
save
()
logger
.
debug
(
'Generate fake asset :
%
s'
%
asset
.
ip
)
except
IntegrityError
:
print
(
'Error continue'
)
continue
class
Label
(
models
.
Model
):
key
=
models
.
CharField
(
max_length
=
64
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'KEY'
))
...
...
apps/assets/templates/assets/asset_group_detail.html
View file @
d0ba1737
...
...
@@ -69,7 +69,7 @@
<div
class=
"ibox float-e-margins"
>
<div
class=
"ibox-title"
>
<span
class=
"label"
>
<b>
{{ asset_group.name }}
</b></span>
<span
>
{% trans 'Asset list of ' %}
<b>
{{ asset_group.name }}
</b></span>
<div
class=
"ibox-tools"
>
<a
class=
"collapse-link"
>
<i
class=
"fa fa-chevron-up"
></i>
...
...
@@ -89,26 +89,29 @@
</div>
</div>
<div
class=
"ibox-content"
>
<table
class=
"table"
>
<table
class=
"table table-hover"
>
<thead>
<tr>
<th>
{% trans 'Hostname' %}
</th>
<th>
{% trans 'IP' %}
</th>
<th>
{% trans 'Port' %}
</th>
<th>
{% trans 'Alive' %}
</th>
</tr>
</thead>
<tbody>
<tr
class=
"no-borders-tr"
>
<td>
{% trans 'Name' %}:
</td>
<td><b>
{{ asset_group.name }}
</b></td>
</tr>
<tr>
<td>
{% trans 'Date created' %}:
</td>
<td><b>
{{ asset_group.date_created }}
</b></td>
</tr>
<tr>
<td>
{% trans 'Created by' %}:
</td>
<td><b>
{{ asset_group.created_by }}
</b></td>
</tr>
<tr>
<td>
{% trans 'Comment' %}:
</td>
<td><b>
{{ asset_group.comment }}
</b></td>
</tr>
{% for asset in page_obj %}
<tr>
<td>
{{ asset.hostname }}
</td>
<td>
{{ asset.ip }}
</td>
<td>
{{ asset.port }}
</td>
<td>
Alive
</td>
</tr>
{% endfor %}
</tbody>
</table>
<div
class=
"row"
>
{% include '_pagination.html' %}
</div>
</div>
</div>
</div>
...
...
@@ -129,14 +132,42 @@
</td>
</tr>
<form>
<tr>
<tr
class=
"no-borders-tr"
>
<td
colspan=
"2"
>
<select
class=
"select2 form-control"
>
<option
value=
"1"
>
{% trans 'System user' %}
</option>
<option
value=
"2"
>
{% trans 'Admin user' %}
</option>
<select
data-placeholder=
"{% trans 'Select system user' %}"
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-primary btn-sm"
>
{% trans 'Associate' %}
</button>
</td>
</tr>
</form>
{% for group in user.groups.all %}
<tr>
<td
><b>
{{ group.name }}
</b></td>
<td>
<button
class=
"btn btn-danger btn-xs"
type=
"button"
style=
"float: right;"
><i
class=
"fa fa-minus"
></i></button>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<div
class=
"panel panel-info"
>
<div
class=
"panel-heading"
>
<i
class=
"fa fa-info-circle"
></i>
{% trans 'Add asset to this group' %}
</div>
<div
class=
"panel-body"
>
<table
class=
"table"
>
<tbody>
<form>
<tr
class=
"no-borders-tr"
>
<td
colspan=
"2"
>
<select
data-placeholder=
"{% trans 'Select asset user' %}"
class=
"select2"
style=
"width: 100%"
multiple=
""
tabindex=
"4"
>
...
...
@@ -148,7 +179,7 @@
</tr>
<tr
class=
"no-borders-tr"
>
<td
colspan=
"2"
>
<button
type=
"button"
class=
"btn btn-
primary btn-sm"
>
{% trans 'Associate
' %}
</button>
<button
type=
"button"
class=
"btn btn-
info btn-sm"
>
{% trans 'Add
' %}
</button>
</td>
</tr>
</form>
...
...
@@ -164,6 +195,7 @@
</table>
</div>
</div>
</div>
</div>
</div>
...
...
apps/assets/views.py
View file @
d0ba1737
...
...
@@ -11,7 +11,7 @@ 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
from
django.views.generic.detail
import
DetailView
from
django.views.generic.detail
import
DetailView
,
SingleObjectMixin
from
.models
import
Asset
,
AssetGroup
,
IDC
,
AssetExtend
from
.forms
import
AssetForm
,
AssetGroupForm
...
...
@@ -56,6 +56,8 @@ class AssetGroupCreateView(CreateView):
template_name
=
'assets/asset_group_create.html'
success_url
=
reverse_lazy
(
'assets:asset-group-list'
)
# Todo: Asset group create template select assets so hard, need be resolve next
def
get_context_data
(
self
,
**
kwargs
):
context
=
{
'app'
:
_
(
'Assets'
),
...
...
@@ -99,15 +101,22 @@ class AssetGroupListView(ListView):
return
self
.
queryset
class
AssetGroupDetailView
(
Detail
View
):
class
AssetGroupDetailView
(
SingleObjectMixin
,
List
View
):
template_name
=
'assets/asset_group_detail.html'
model
=
AssetGroup
context_object_name
=
'asset_group'
paginate_by
=
settings
.
CONFIG
.
DISPLAY_PER_PAGE
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
self
.
object
=
self
.
get_object
(
queryset
=
AssetGroup
.
objects
.
all
())
return
super
(
AssetGroupDetailView
,
self
)
.
get
(
request
,
*
args
,
**
kwargs
)
def
get_queryset
(
self
):
return
self
.
object
.
assets
.
all
()
def
get_context_data
(
self
,
**
kwargs
):
context
=
{
'app'
:
_
(
'Assets'
),
'action'
:
_
(
'Asset group detail'
)
'action'
:
_
(
'Asset group detail'
),
'asset_group'
:
self
.
object
,
}
kwargs
.
update
(
context
)
return
super
(
AssetGroupDetailView
,
self
)
.
get_context_data
(
**
kwargs
)
...
...
apps/users/hands.py
0 → 100644
View file @
d0ba1737
"""
jumpserver.__app__.hands.py
~~~~~~~~~~~~~~~~~
This app depends other apps api, function .. should be import or write mack here.
Other module of this app shouldn't connect with other app.
:copyright: (c) 2014-2016 by Jumpserver Team.
:license: GPL v2, see LICENSE for more details.
"""
apps/users/urls.py
View file @
d0ba1737
...
...
@@ -16,6 +16,7 @@ urlpatterns = [
name
=
'reset-password-success'
),
url
(
r'^user$'
,
views
.
UserListView
.
as_view
(),
name
=
'user-list'
),
url
(
r'^user/(?P<pk>[0-9]+)$'
,
views
.
UserDetailView
.
as_view
(),
name
=
'user-detail'
),
url
(
r'^user/(?P<pk>[0-9]+)/assets-perm$'
,
views
.
UserDetailView
.
as_view
(),
name
=
'user-detail'
),
url
(
r'^user/create$'
,
views
.
UserCreateView
.
as_view
(),
name
=
'user-create'
),
url
(
r'^user/(?P<pk>[0-9]+)/update$'
,
views
.
UserUpdateView
.
as_view
(),
name
=
'user-update'
),
url
(
r'^user/(?P<pk>[0-9]+)/delete$'
,
views
.
UserDeleteView
.
as_view
(),
name
=
'user-delete'
),
...
...
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