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
a4bd3524
Commit
a4bd3524
authored
Apr 11, 2015
by
halcyon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
idc
parent
2e254af9
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
134 additions
and
41 deletions
+134
-41
views.py
jasset/views.py
+20
-8
idc_add.html
templates/jasset/idc_add.html
+2
-31
idc_edit.html
templates/jasset/idc_edit.html
+110
-0
idc_list.html
templates/jasset/idc_list.html
+2
-2
No files found.
jasset/views.py
View file @
a4bd3524
...
...
@@ -427,34 +427,46 @@ def idc_list(request):
@require_super_user
def
idc_edit
(
request
):
header_title
,
path1
,
path2
=
u'编辑IDC'
,
u'资产管理'
,
u'编辑IDC'
edit
=
1
idc_id
=
request
.
GET
.
get
(
'id'
)
j_idc
=
IDC
.
objects
.
get
(
id
=
idc_id
)
idc
=
IDC
.
objects
.
filter
(
id
=
idc_id
)
if
idc
:
idc
=
idc
[
0
]
default
=
IDC
.
objects
.
get
(
name
=
'默认'
)
.
asset_set
.
all
()
eposts
=
contact_list
=
Asset
.
objects
.
filter
(
idc
=
j_
idc
)
.
order_by
(
'ip'
)
eposts
=
Asset
.
objects
.
filter
(
idc
=
idc
)
.
order_by
(
'ip'
)
posts
=
[
g
for
g
in
default
if
g
not
in
eposts
]
else
:
emg
=
'此IDC不存在'
if
request
.
method
==
'POST'
:
j_group
=
request
.
POST
.
get
(
'j_idc'
)
idc_id
=
request
.
POST
.
get
(
'id'
)
j_idc
=
request
.
POST
.
get
(
'j_idc'
)
j_hosts
=
request
.
POST
.
getlist
(
'j_hosts'
)
j_comment
=
request
.
POST
.
get
(
'j_comment'
)
idc_default
=
request
.
POST
.
getlist
(
'idc_default'
)
idc
=
IDC
.
objects
.
filter
(
id
=
idc_id
)
if
idc
:
idc
.
update
(
name
=
j_idc
,
comment
=
j_comment
)
for
host
in
j_hosts
:
g
=
Asset
.
objects
.
get
(
id
=
host
)
Asset
.
objects
.
filter
(
id
=
host
)
.
update
(
idc
=
j_
idc
)
Asset
.
objects
.
filter
(
id
=
host
)
.
update
(
idc
=
idc
)
for
host
in
idc_default
:
g
=
Asset
.
objects
.
get
(
id
=
host
)
i
=
IDC
.
objects
.
get
(
name
=
'默认'
)
Asset
.
objects
.
filter
(
id
=
host
)
.
update
(
idc
=
i
)
else
:
emg
=
'此IDC不存在'
return
render_to_response
(
'jasset/idc_edit.html'
,
locals
(),
context_instance
=
RequestContext
(
request
))
return
HttpResponseRedirect
(
'/jasset/idc_list/'
%
idc_id
)
return
HttpResponseRedirect
(
'/jasset/idc_list/
?id=
%
s
'
%
idc_id
)
return
render_to_response
(
'jasset/idc_
add
.html'
,
locals
(),
context_instance
=
RequestContext
(
request
))
return
render_to_response
(
'jasset/idc_
edit
.html'
,
locals
(),
context_instance
=
RequestContext
(
request
))
@require_super_user
def
idc_del
(
request
,
offset
):
def
idc_del
(
request
):
offset
=
request
.
GET
.
get
(
'id'
,
''
)
if
offset
==
'multi'
:
len_list
=
request
.
POST
.
get
(
"len_list"
)
for
i
in
range
(
int
(
len_list
)):
...
...
templates/jasset/idc_add.html
View file @
a4bd3524
...
...
@@ -35,43 +35,14 @@
{% endif %}
<form
id=
"assetForm"
method=
"post"
class=
"form-horizontal"
>
<div
class=
"form-group"
><label
class=
"col-sm-2 control-label"
>
IDC名
<span
class=
"red-fonts"
>
*
</span></label>
<div
class=
"col-sm-8"
><input
type=
"text"
value=
"{{
j_
idc.name }}"
placeholder=
"北京联通"
name=
"j_idc"
class=
"form-control"
></div>
<div
class=
"col-sm-8"
><input
type=
"text"
value=
"{{ idc.name }}"
placeholder=
"北京联通"
name=
"j_idc"
class=
"form-control"
></div>
</div>
<div
class=
"hr-line-dashed"
></div>
<div
class=
"form-group"
><label
class=
"col-sm-2 control-label"
>
备注
</label>
<div
class=
"col-sm-8"
><input
type=
"text"
value=
"{{
j_
idc.comment }}"
placeholder=
"核心联通机房"
name=
"j_comment"
class=
"form-control"
></div>
<div
class=
"col-sm-8"
><input
type=
"text"
value=
"{{ idc.comment }}"
placeholder=
"核心联通机房"
name=
"j_comment"
class=
"form-control"
></div>
</div>
{% if edit %}
<div
class=
"hr-line-dashed"
></div>
<div
class=
"form-group"
>
<label
for=
"groups"
class=
"col-lg-2 control-label"
>
主机
</label>
<div
class=
"col-sm-3"
>
<select
id=
"groups"
name=
"idc_default"
size=
"12"
class=
"form-control m-b"
multiple
>
{% for post in posts %}
<option
value=
"{{ post.id }}"
>
{{ post.ip }}
</option>
{% endfor %}
</select>
</div>
<div
class=
"col-sm-1"
>
<div
class=
"btn-group"
style=
"margin-top: 50px;"
>
<button
type=
"button"
class=
"btn btn-white"
onclick=
"move('groups', 'groups_selected')"
><i
class=
"fa fa-chevron-right"
></i></button>
<button
type=
"button"
class=
"btn btn-white"
onclick=
"move_left('groups_selected', 'groups')"
><i
class=
"fa fa-chevron-left"
></i>
</button>
</div>
</div>
<div
class=
"col-sm-3"
>
<div>
<select
id=
"groups_selected"
name=
"j_hosts"
class=
"form-control m-b"
size=
"12"
multiple
>
{% for post in eposts %}
<option
value=
"{{ post.id }}"
>
{{ post.ip }}
</option>
{% endfor %}
</select>
</div>
</div>
</div>
{% endif %}
<div
class=
"hr-line-dashed"
></div>
<div
class=
"form-group"
>
<div
class=
"col-sm-4 col-sm-offset-5"
>
...
...
templates/jasset/idc_edit.html
0 → 100644
View file @
a4bd3524
{% 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
id=
"ibox-content"
class=
"ibox-title"
>
<h5>
填写IDC基本信息
</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"
>
{% if emg %}
<div
class=
"alert alert-warning text-center"
>
{{ emg }}
</div>
{% endif %}
{% if smg %}
<div
class=
"alert alert-success text-center"
>
{{ smg }}
</div>
{% endif %}
<form
id=
"assetForm"
method=
"post"
class=
"form-horizontal"
>
<div
class=
"form-group"
><label
class=
"col-sm-2 control-label"
>
IDC名
<span
class=
"red-fonts"
>
*
</span></label>
<div
class=
"col-sm-8"
>
<input
name=
"id"
type=
"text"
value=
"{{ idc.id }}"
style=
"display: none;"
>
<input
type=
"text"
value=
"{{ idc.name }}"
placeholder=
"北京联通"
name=
"j_idc"
class=
"form-control"
>
</div>
</div>
<div
class=
"hr-line-dashed"
></div>
<div
class=
"form-group"
><label
class=
"col-sm-2 control-label"
>
备注
</label>
<div
class=
"col-sm-8"
><input
type=
"text"
value=
"{{ idc.comment }}"
placeholder=
"核心联通机房"
name=
"j_comment"
class=
"form-control"
></div>
</div>
<div
class=
"hr-line-dashed"
></div>
<div
class=
"form-group"
>
<label
for=
"groups"
class=
"col-lg-2 control-label"
>
主机
</label>
<div
class=
"col-sm-3"
>
<select
id=
"groups"
name=
"idc_default"
size=
"12"
class=
"form-control m-b"
multiple
>
{% for post in posts %}
<option
value=
"{{ post.id }}"
>
{{ post.ip }}
</option>
{% endfor %}
</select>
</div>
<div
class=
"col-sm-1"
>
<div
class=
"btn-group"
style=
"margin-top: 50px;"
>
<button
type=
"button"
class=
"btn btn-white"
onclick=
"move('groups', 'groups_selected')"
><i
class=
"fa fa-chevron-right"
></i></button>
<button
type=
"button"
class=
"btn btn-white"
onclick=
"move_left('groups_selected', 'groups')"
><i
class=
"fa fa-chevron-left"
></i>
</button>
</div>
</div>
<div
class=
"col-sm-3"
>
<div>
<select
id=
"groups_selected"
name=
"j_hosts"
class=
"form-control m-b"
size=
"12"
multiple
>
{% for post in eposts %}
<option
value=
"{{ post.id }}"
>
{{ post.ip }}
</option>
{% endfor %}
</select>
</div>
</div>
</div>
<div
class=
"hr-line-dashed"
></div>
<div
class=
"form-group"
>
<div
class=
"col-sm-4 col-sm-offset-5"
>
<button
class=
"btn btn-white"
type=
"submit"
>
重置
</button>
<button
class=
"btn btn-primary"
type=
"sumbit"
>
提交
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<script>
$
(
'#assetForm'
).
validator
({
timely
:
2
,
theme
:
"yellow_right_effect"
,
fields
:
{
"j_idc"
:
{
rule
:
"required"
,
tip
:
"输入IDC名"
,
ok
:
""
,
msg
:
{
required
:
"IDC名必须填写!"
},
data
:
{
'data-ok'
:
"主机名可以使用"
,
'data-msg-required'
:
'主机名已正确'
}
}
},
valid
:
function
(
form
)
{
form
.
submit
();
}
});
</script>
{% endblock %}
\ No newline at end of file
templates/jasset/idc_list.html
View file @
a4bd3524
...
...
@@ -55,7 +55,7 @@
<a
href=
"/jasset/idc_detail/?id={{ post.id }}"
class=
"iframe btn btn-xs btn-primary"
>
详情
</a>
{% ifequal session_role_id 2 %}
<a
href=
"/jasset/idc_edit/?id={{ post.id }}"
class=
"btn btn-xs btn-info"
>
编辑
</a>
<a
href=
"/jasset/idc_del/{{ post.id }}"
class=
"btn btn-xs btn-danger"
>
删除
</a>
<a
href=
"/jasset/idc_del/
?id=
{{ post.id }}"
class=
"btn btn-xs btn-danger"
>
删除
</a>
{% endifequal %}
</td>
</tr>
...
...
@@ -92,7 +92,7 @@
if
(
confirm
(
"确定删除"
))
{
$
.
ajax
({
type
:
"POST"
,
url
:
"/jasset/idc_del/
multi/
"
,
url
:
"/jasset/idc_del/
?id=multi
"
,
data
:
{
"id_list"
:
id_list
,
"len_list"
:
j
},
success
:
function
(
data
)
{
window
.
open
(
"/jasset/idc_list/"
,
"_self"
);
...
...
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