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
b531d9ee
Commit
b531d9ee
authored
Sep 04, 2016
by
wangyong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
asset add html
parent
fa07f4ee
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
105 deletions
+39
-105
forms.py
apps/assets/forms.py
+5
-0
models.py
apps/assets/models.py
+6
-6
asset_add.html
apps/assets/templates/assets/asset_add.html
+21
-88
urls.py
apps/assets/urls.py
+7
-11
No files found.
apps/assets/forms.py
View file @
b531d9ee
...
...
@@ -2,6 +2,7 @@
from
django
import
forms
from
.models
import
IDC
,
Asset
,
AssetGroup
from
django.utils.translation
import
gettext_lazy
as
_
class
AssetForm
(
forms
.
ModelForm
):
...
...
@@ -15,6 +16,10 @@ class AssetForm(forms.ModelForm):
"number"
,
"status"
,
"type"
,
"env"
,
"sn"
,
"is_active"
,
"comment"
]
widgets
=
{
'groups'
:
forms
.
SelectMultiple
(
attrs
=
{
'class'
:
'select2'
,
'data-placeholder'
:
_
(
'Join assetgroups'
)}),
}
class
AssetGroupForm
(
forms
.
ModelForm
):
class
Meta
:
...
...
apps/assets/models.py
View file @
b531d9ee
...
...
@@ -114,12 +114,12 @@ class Asset(models.Model):
cabinet_no
=
models
.
CharField
(
max_length
=
32
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'Cabinet number'
))
cabinet_pos
=
models
.
IntegerField
(
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'Cabinet position'
))
number
=
models
.
CharField
(
max_length
=
32
,
null
=
True
,
blank
=
True
,
unique
=
True
,
verbose_name
=
_
(
'Asset number'
))
status
=
models
.
ManyToManyField
(
AssetExtend
,
null
=
True
,
blank
=
True
,
related_name
=
"asset_status_extend"
,
verbose_name
=
_
(
'Asset status'
))
type
=
models
.
ManyToManyField
(
AssetExtend
,
null
=
True
,
blank
=
True
,
related_name
=
"asset_type_extend"
,
verbose_name
=
_
(
'Asset type'
))
env
=
models
.
ManyToManyField
(
AssetExtend
,
null
=
True
,
blank
=
True
,
related_name
=
"asset_env_extend"
,
verbose_name
=
_
(
'Asset environment'
))
status
=
models
.
ForeignKey
(
AssetExtend
,
related_name
=
"asset_extend_status"
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'Asset status'
))
type
=
models
.
ForeignKey
(
AssetExtend
,
related_name
=
"asset_extend_type"
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'Asset type'
))
env
=
models
.
ForeignKey
(
AssetExtend
,
related_name
=
"asset_extend_env"
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'Asset environment'
))
sn
=
models
.
CharField
(
max_length
=
128
,
null
=
True
,
blank
=
True
,
unique
=
True
,
verbose_name
=
_
(
'Serial number'
))
created_by
=
models
.
CharField
(
max_length
=
32
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'Created by'
))
is_active
=
models
.
BooleanField
(
default
=
True
,
verbose_name
=
_
(
'Is active'
))
...
...
apps/assets/templates/assets/asset_add.html
View file @
b531d9ee
{% extends 'base.html' %}
{% load static %}
{% load bootstrap %}
{% block custom_head_css_js %}
<link
href=
"{% static "
css
/
plugins
/
select2
/
select2
.
min
.
css
"
%}"
rel=
"stylesheet"
>
<script
src=
"{% static "
js
/
plugins
/
select2
/
select2
.
full
.
min
.
js
"
%}"
></script>
{% endblock %}
{% block content %}
<div
class=
"wrapper wrapper-content animated fadeInRight"
>
<div
class=
"row"
>
...
...
@@ -40,12 +45,14 @@
</div>
</div>
<div
class=
"form-group"
id=
"id_type"
>
<label
class=
"col-sm-2 control-label"
>
资产类型
</label>
<div
class=
"col-sm-9"
>
<input
type=
"text"
placeholder=
""
name=
"type"
class=
"form-control"
>
</div>
</div>
{#
<div
class=
"form-group"
id=
"id_type"
>
#}
{#
<label
class=
"col-sm-2 control-label"
>
资产类型
</label>
#}
{#
<div
class=
"col-sm-9"
>
#}
{#
<input
type=
"text"
placeholder=
""
name=
"type"
class=
"form-control"
>
#}
{#
</div>
#}
{#
</div>
#}
{{ form.type|bootstrap_horizontal }}
{{ form.comment|bootstrap_horizontal }}
...
...
@@ -79,7 +86,7 @@
<h3>
所属
</h3>
{{ form.idc|bootstrap_horizontal }}
{{ form.group|bootstrap_horizontal }}
{{ form.group
s
|bootstrap_horizontal }}
<div
class=
"hr-line-dashed"
></div>
<h3>
标签
</h3>
...
...
@@ -103,85 +110,10 @@
</div>
{% endblock %}
{% block self_footer_js %}
{#
<script>
#
}
{
#
$
(
'document'
).
ready
(
function
(){
#
}
{
#
var
check_default
=
"{{ default_setting.name }}"
;
#
}
{
#
console
.
log
(
check_default
);
#
}
{
#
if
(
check_default
!=
'default'
){
#
}
{
#
$
(
'#id_use_default_auth'
).
attr
(
'disabled'
,
true
);
#
}
{
#
$
(
'#id_use_default_auth'
).
attr
(
'checked'
,
false
);
#
}
{
#
$
(
'#admin_account'
).
css
(
'display'
,
'block'
);
#
}
{
#
}
else
{
#
}
{
#
$
(
'#id_use_default_auth'
).
click
(
function
(){
#
}
{
#
if
(
$
(
this
).
is
(
':checked'
)){
#
}
{
#
$
(
'#admin_account'
).
css
(
'display'
,
'none'
);
#
}
{
#
}
#
}
{
#
else
{
#
}
{
#
$
(
'#admin_account'
).
css
(
'display'
,
'block'
);
#
}
{
#
}
#
}
{
#
})
#
}
{
#
}
#
}
{
##
}
{
#
});
#
}
{
##
}
{
#
var
required_fields
=
[
"id_ip"
,
"id_hostname"
,
"id_port"
];
#
}
{
#
required_fields
.
forEach
(
function
(
field
)
{
#
}
{
#
$
(
'label[for="'
+
field
+
'"]'
).
parent
().
addClass
(
"required"
);
#
}
{
#
});
#
}
{
##
}
{
#
$
(
'#assetForm'
).
validator
({
#
}
{
#
timely
:
2
,
#
}
{
#
theme
:
"yellow_right_effect"
,
#
}
{
#
rules
:
{
#
}
{
#
check_ip
:
[
/^
(\d{1,2}
|1
\d\d
|2
[
0-4
]\d
|25
[
0-5
])(\.(\d{1,2}
|1
\d\d
|2
[
0-4
]\d
|25
[
0-5
])){3}
$/
,
'ip地址不正确'
],
#
}
{
#
check_port
:
[
/^
\d{1,5}
$/
,
'端口号不正确'
],
#
}
{
#
use_default_auth
:
function
()
{
#
}
{
#
var
str1
=
$
(
"#id_use_default_auth"
).
is
(
":checked"
);
#
}
{
#
if
(
str1
==
true
){
#
}
{
#
var
decide
=
false
;
#
}
{
#
}
else
{
#
}
{
#
var
decide
=
true
;
#
}
{
#
}
#
}
{
#
return
decide
}
#
}
{
#
},
#
}
{
#
fields
:
{
#
}
{
#
"ip"
:
{
#
}
{
#
rule
:
"check_ip;"
,
#
}
{
#
tip
:
"输入IP"
,
#
}
{
#
ok
:
""
,
#
}
{
#
msg
:
{
required
:
"必须填写!"
}
#
}
{
#
},
#
}
{
#
"hostname"
:
{
#
}
{
#
rule
:
"required;length[0~53]"
,
#
}
{
#
tip
:
"填写主机名"
,
#
}
{
#
ok
:
""
,
#
}
{
#
msg
:
{
required
:
"必须填写!"
}
#
}
{
#
},
#
}
{
#
"port"
:
{
#
}
{
#
rule
:
"required"
,
#
}
{
#
tip
:
"输入端口号"
,
#
}
{
#
ok
:
""
,
#
}
{
#
msg
:
{
required
:
"必须填写!"
}
#
}
{
#
},
#
}
{
#
"username"
:
{
#
}
{
#
rule
:
"required(use_default_auth)"
,
#
}
{
#
tip
:
"输入用户名"
,
#
}
{
#
ok
:
""
,
#
}
{
#
msg
:
{
required
:
"必须填写!"
}
#
}
{
#
},
#
}
{
#
"password"
:
{
#
}
{
#
rule
:
"required(use_default_auth);length[0~64]"
,
#
}
{
#
tip
:
"输入密码"
,
#
}
{
#
ok
:
""
,
#
}
{
#
msg
:
{
required
:
"必须填写!"
}
#
}
{
#
}
#
}
{
#
},
#
}
{
#
valid
:
function
(
form
)
{
#
}
{
#
form
.
submit
();
#
}
{
#
}
#
}
{
#
});
#
}
{
##
}
{
#
</script>
#}
{% block custom_foot_js %}
<script>
$
(
document
).
ready
(
function
()
{
$
(
'.select2'
).
select2
();
})
</script>
{% endblock %}
\ No newline at end of file
apps/assets/urls.py
View file @
b531d9ee
# coding:utf-8
from
django.conf.urls
import
url
,
include
from
.views
import
*
# from .api import (
# AssetGroupViewSet, AssetViewSet, IDCViewSet
# )
from
django.conf.urls
import
url
,
include
import
views
# from rest_framework import routers
# router = routers.DefaultRouter()
...
...
@@ -14,18 +12,16 @@ import views
app_name
=
'assets'
urlpatterns
=
[
url
(
r'^$'
,
AssetListView
.
as_view
(),
name
=
'asset-list'
),
url
(
r'^(?P<pk>[0-9]+)/delete/$'
,
AssetDeleteView
.
as_view
(),
name
=
'asset-delete'
),
url
(
r'^(?P<pk>[0-9]+)/detail/$'
,
AssetDetailView
.
as_view
(),
name
=
'asset-detail'
),
url
(
r'^asset'
,
views
.
AssetListView
.
as_view
(),
name
=
'asset-list'
),
# url(r'^$', views.AssetListView.as_view(), name='asset-index'),
# url(r'^asset', views.AssetListView.as_view(), name='asset-list'),
url
(
r'^asset/add$'
,
views
.
AssetAddView
.
as_view
(),
name
=
'asset-add'
),
url
(
r'^asset/(?P<pk>[0-9]+)$'
,
views
.
AssetDetailView
.
as_view
(),
name
=
'asset-detail'
),
url
(
r'^asset/(?P<pk>[0-9]+)$/edit'
,
views
.
AssetEditView
.
as_view
(),
name
=
'asset-edit'
),
url
(
r'^asset/(?P<pk>[0-9]+)/delete$'
,
views
.
AssetDeleteView
.
as_view
(),
name
=
'asset-delete'
),
url
(
r'^asset-group'
,
views
.
AssetGroupListView
.
as_view
(),
name
=
'assetgroup-list'
),
url
(
r'^asset-group/add$'
,
views
.
Asset
AddView
.
as_view
(),
name
=
'asset
-add'
),
url
(
r'^asset-group/(?P<pk>[0-9]+)$'
,
views
.
AssetDetailView
.
as_view
(),
name
=
'asset-detail'
),
url
(
r'^asset-group/(?P<pk>[0-9]+)$/edit'
,
views
.
AssetEditView
.
as_view
(),
name
=
'asset-edit'
),
url
(
r'^asset-group/(?P<pk>[0-9]+)/delete$'
,
views
.
AssetDeleteView
.
as_view
(),
name
=
'asset-delete'
),
url
(
r'^asset-group'
,
views
.
AssetGroupListView
.
as_view
(),
name
=
'asset
-
group-list'
),
url
(
r'^asset-group/add$'
,
views
.
Asset
GroupAddView
.
as_view
(),
name
=
'asset-group
-add'
),
url
(
r'^asset-group/(?P<pk>[0-9]+)$'
,
views
.
AssetDetailView
.
as_view
(),
name
=
'asset-
group-
detail'
),
url
(
r'^asset-group/(?P<pk>[0-9]+)$/edit'
,
views
.
AssetEditView
.
as_view
(),
name
=
'asset-
group-
edit'
),
url
(
r'^asset-group/(?P<pk>[0-9]+)/delete$'
,
views
.
AssetDeleteView
.
as_view
(),
name
=
'asset-
group-
delete'
),
# url(r'^api/v1.0/', include(router.urls)),
]
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