Commit b531d9ee authored by wangyong's avatar wangyong

asset add html

parent fa07f4ee
......@@ -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:
......
......@@ -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'))
......
{% 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.groups|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
# 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.AssetAddView.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.AssetGroupAddView.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)),
]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment