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
9652460b
Commit
9652460b
authored
Jan 07, 2015
by
ibuler
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
fde3d19a
0ed08534
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
207 additions
and
8 deletions
+207
-8
models.py
jasset/models.py
+9
-1
urls.py
jasset/urls.py
+4
-0
views.py
jasset/views.py
+98
-4
settings.py
jumpserver/settings.py
+1
-1
jadd.html
templates/jasset/jadd.html
+0
-0
jlist.html
templates/jasset/jlist.html
+89
-0
user_add.html
templates/juser/user_add.html
+5
-1
nav.html
templates/nav.html
+1
-1
No files found.
jasset/models.py
View file @
9652460b
import
datetime
from
django.db
import
models
from
juser.models
import
Group
,
User
...
...
@@ -9,6 +10,13 @@ class IDC(models.Model):
def
__unicode__
(
self
):
return
self
.
name
class
Group
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
80
,
unique
=
True
)
comment
=
models
.
CharField
(
max_length
=
160
,
blank
=
True
,
null
=
True
)
def
__unicode__
(
self
):
return
self
.
name
class
Asset
(
models
.
Model
):
LOGIN_TYPE_CHOICES
=
(
...
...
@@ -26,7 +34,7 @@ class Asset(models.Model):
password_common
=
models
.
CharField
(
max_length
=
80
,
blank
=
True
,
null
=
True
)
username_super
=
models
.
CharField
(
max_length
=
20
,
blank
=
True
,
null
=
True
)
password_super
=
models
.
CharField
(
max_length
=
80
,
blank
=
True
,
null
=
True
)
date_added
=
models
.
IntegerField
(
max_length
=
12
)
date_added
=
models
.
DateTimeField
(
auto_now
=
True
,
default
=
datetime
.
datetime
.
now
(),
null
=
True
)
is_active
=
models
.
BooleanField
(
default
=
True
)
comment
=
models
.
CharField
(
max_length
=
100
,
blank
=
True
,
null
=
True
)
...
...
jasset/urls.py
View file @
9652460b
...
...
@@ -5,4 +5,7 @@ from jasset.views import *
urlpatterns
=
patterns
(
''
,
url
(
r'^$'
,
index
),
url
(
r'jadd'
,
jadd
),
url
(
r'jlist'
,
jlist
),
url
(
r'jadd_idc'
,
jadd_idc
),
url
(
r'jlist_idc'
,
jlist_idc
),
)
\ No newline at end of file
jasset/views.py
View file @
9652460b
#coding:utf-8
# coding:utf-8
import
datetime
from
django.shortcuts
import
render
from
django.http
import
HttpResponse
from
django.template
import
RequestContext
from
django.shortcuts
import
render_to_response
from
django.http
import
HttpResponseRedirect
from
django.core.paginator
import
Paginator
,
EmptyPage
,
PageNotAnInteger
from
models
import
IDC
,
Asset
,
Group
from
connect
import
PyCrypt
,
KEY
def
index
(
request
):
return
render_to_response
(
'jasset/jasset.html'
,)
return
render_to_response
(
'jasset/jasset.html'
,
)
def
jadd
(
request
):
global
j_passwd
groups
=
[]
cryptor
=
PyCrypt
(
KEY
)
eidc
=
IDC
.
objects
.
all
()
egroup
=
Group
.
objects
.
all
()
is_actived
=
{
'active'
:
1
,
'no_active'
:
0
}
login_typed
=
{
'LDAP'
:
'L'
,
'SSH_KEY'
:
'S'
,
'PASSWORD'
:
'P'
,
'MAP'
:
'M'
}
if
request
.
method
==
'POST'
:
j_ip
=
request
.
POST
.
get
(
'j_ip'
)
j_idc
=
request
.
POST
.
get
(
'j_idc'
)
j_port
=
request
.
POST
.
get
(
'j_port'
)
j_type
=
request
.
POST
.
get
(
'j_type'
)
j_group
=
request
.
POST
.
getlist
(
'j_group'
)
j_active
=
request
.
POST
.
get
(
'j_active'
)
j_comment
=
request
.
POST
.
get
(
'j_comment'
)
if
j_type
==
'MAP'
:
j_user
=
request
.
POST
.
get
(
'j_user'
)
j_password
=
cryptor
.
encrypt
(
request
.
POST
.
get
(
'j_password'
))
j_root
=
request
.
POST
.
get
(
'j_root'
)
j_passwd
=
cryptor
.
encrypt
(
request
.
POST
.
get
(
'j_passwd'
))
j_idc
=
IDC
.
objects
.
get
(
name
=
j_idc
)
for
group
in
j_group
:
c
=
Group
.
objects
.
get
(
name
=
group
)
groups
.
append
(
c
)
if
Asset
.
objects
.
filter
(
ip
=
str
(
j_ip
)):
emg
=
u'该IP已存在!'
return
render_to_response
(
'jasset/jadd.html'
,
{
'emg'
:
emg
,
'j_ip'
:
j_ip
})
elif
j_type
==
'MAP'
:
a
=
Asset
(
ip
=
j_ip
,
port
=
j_port
,
login_type
=
login_typed
[
j_type
],
idc
=
j_idc
,
is_active
=
int
(
is_actived
[
j_active
]),
comment
=
j_comment
,
username_common
=
j_user
,
password_common
=
j_password
,
username_super
=
j_root
,
password_super
=
j_passwd
,)
else
:
a
=
Asset
(
ip
=
j_ip
,
port
=
j_port
,
login_type
=
login_typed
[
j_type
],
idc
=
j_idc
,
is_active
=
int
(
is_actived
[
j_active
]),
comment
=
j_comment
)
a
.
save
()
a
.
group
=
groups
a
.
save
()
return
render_to_response
(
'jasset/jadd.html'
,
{
'header_title'
:
u'添加主机 | Add Host'
,
'path1'
:
'资产管理'
,
'path2'
:
'添加主机'
,
'eidc'
:
eidc
,
'egroup'
:
egroup
,
}
)
def
jlist
(
request
):
posts
=
contact_list
=
Asset
.
objects
.
all
()
.
order_by
(
'ip'
)
print
posts
paginator
=
Paginator
(
contact_list
,
5
)
try
:
page
=
int
(
request
.
GET
.
get
(
'page'
,
'1'
))
except
ValueError
:
page
=
1
try
:
contacts
=
paginator
.
page
(
page
)
except
(
EmptyPage
,
InvalidPage
):
contacts
=
paginator
.
page
(
paginator
.
num_pages
)
return
render_to_response
(
'jasset/jlist.html'
,
{
"contacts"
:
contacts
,
'p'
:
paginator
,
'posts'
:
posts
,
'header_title'
:
u'查看主机 | List Host'
,
'path1'
:
'资产管理'
,
'path2'
:
'查看主机'
,
},
context_instance
=
RequestContext
(
request
))
def
jadd_idc
(
request
):
pass
def
jlist_idc
(
request
):
pass
\ No newline at end of file
return
render_to_response
(
'jasset/jadd.html'
,)
\ No newline at end of file
jumpserver/settings.py
View file @
9652460b
...
...
@@ -111,7 +111,7 @@ USE_I18N = True
USE_L10N
=
True
USE_TZ
=
Tru
e
USE_TZ
=
Fals
e
# Static files (CSS, JavaScript, Images)
...
...
templates/jasset/jadd.html
View file @
9652460b
This diff is collapsed.
Click to expand it.
templates/jasset/jlist.html
0 → 100644
View file @
9652460b
{% extends 'base.html' %}
{% block content %}
{% include 'nav_cat_bar.html' %}
<div
class=
"wrapper wrapper-content animated fadeInRight"
>
<div
class=
"row"
>
<div
class=
"col-lg-10"
>
<div
class=
"ibox float-e-margins"
>
<div
class=
"ibox-title"
>
<h5>
主机详细信息列表
</h5>
<div
class=
"ibox-tools"
>
<a
class=
"collapse-link"
>
<i
class=
"fa fa-chevron-up"
></i>
</a>
<a
class=
"dropdown-toggle"
data-toggle=
"dropdown"
href=
"#"
>
<i
class=
"fa fa-wrench"
></i>
</a>
<ul
class=
"dropdown-menu dropdown-user"
>
<li><a
href=
"#"
>
未启用 1
</a>
</li>
<li><a
href=
"#"
>
未启用 2
</a>
</li>
</ul>
<a
class=
"close-link"
>
<i
class=
"fa fa-times"
></i>
</a>
</div>
</div>
<div
class=
"ibox-content"
>
<div
class=
""
>
<a
onclick=
"fnClickAddRow();"
href=
"javascript:void(0);"
class=
"btn btn-primary "
>
添加
</a>
</div>
<table
class=
"table table-striped table-bordered table-hover "
id=
"editable"
>
<thead>
<tr>
<th>
IP地址
</th>
<th>
端口号
</th>
<th>
登录方式
</th>
<th>
所属IDC
</th>
<th>
所属业务组
</th>
<th>
添加时间
</th>
<th>
备注
</th>
</tr>
</thead>
<tbody>
{% for post in contacts.object_list %}
<tr
class=
"gradeX"
>
<td>
{{ post.ip }}
</td>
<td>
{{ post.port }}
</td>
<td>
{{ post.login_type}}
</td>
<td
class=
"center"
>
{{ post.idc.name }}
</td>
<td
class=
"center"
>
{% for group in post.group.all %}
{{ group }}
{% endfor %}
</td>
<td
class=
"center"
>
{{ post.date_added }}
</td>
<td
class=
"center"
>
{{ post.comment }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
<ul
class=
"pagination"
>
{% if contacts.has_previous %}
<li><a
href=
"?page={{ contacts.previous_page_number }}"
>
«
</a></li>
{% endif %}
{% for page in p.page_range %}
{% ifequal offset1 page %}
<li
class=
"active"
><a
href=
"?page={{ page }}"
title=
"第{{ page }}页"
>
{{ page }}
</a></li>
{% else %}
<li><a
href=
"?page={{ page }}"
title=
"第{{ page }}页"
>
{{ page }}
</a></li>
{% endifequal %}
{% endfor %}
{% if contacts.has_next %}
<li><a
href=
"?page={{ contacts.next_page_number }}"
>
»
</a></li>
{% endif %}
</ul>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
\ No newline at end of file
templates/juser/user_add.html
View file @
9652460b
...
...
@@ -101,7 +101,7 @@
<div
class=
"form-group"
>
<div
class=
"col-sm-4 col-sm-offset-2"
>
<button
class=
"btn btn-white"
type=
"submit"
>
取消
</button>
<button
class=
"btn btn-primary"
type=
"submit"
>
确认保存
</button>
<button
id=
"submit_button"
class=
"btn btn-primary"
type=
"submit"
>
确认保存
</button>
</div>
</div>
</form>
...
...
@@ -110,4 +110,7 @@
</div>
</div>
</div>
</script>
{% endblock %}
\ No newline at end of file
templates/nav.html
View file @
9652460b
...
...
@@ -23,7 +23,7 @@
<li>
<a
href=
"mailbox.html"
><i
class=
"fa fa-cube"
></i>
<span
class=
"nav-label"
>
资产管理
</span><span
class=
"fa arrow"
></span></a>
<ul
class=
"nav nav-second-level"
>
<li><a
href=
"/
asset/show
list/"
>
查看资产
</a></li>
<li><a
href=
"/
jasset/j
list/"
>
查看资产
</a></li>
<li><a
href=
"/jasset/jadd/"
>
添加资产
</a></li>
<li><a
href=
"/idc/showlist/"
>
查看机房
</a></li>
<li><a
href=
"/idc/add/"
>
添加机房
</a></li>
...
...
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