merge master

pull/530/head
wangyong 8 years ago
commit d96ac56460

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10 on 2016-08-21 09:52
# Generated by Django 1.10 on 2016-09-03 14:30
from __future__ import unicode_literals
from django.db import migrations, models
@ -18,11 +18,11 @@ class Migration(migrations.Migration):
name='Asset',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('ip', models.CharField(blank=True, max_length=32, verbose_name='\u4e3b\u673aIP')),
('ip', models.CharField(blank=True, max_length=32, verbose_name='\u8d44\u4ea7IP')),
('other_ip', models.CharField(blank=True, max_length=255, verbose_name='\u5176\u4ed6IP')),
('remote_card_ip', models.CharField(blank=True, max_length=16, verbose_name='\u8fdc\u63a7\u5361IP')),
('hostname', models.CharField(blank=True, max_length=128, unique=True, verbose_name='\u4e3b\u673a\u540d')),
('port', models.IntegerField(blank=True, verbose_name='\u7aef\u53e3\u53f7')),
('port', models.IntegerField(blank=True, verbose_name='\u7aef\u53e3')),
('username', models.CharField(blank=True, max_length=16, verbose_name='\u7ba1\u7406\u7528\u6237\u540d')),
('password', models.CharField(blank=True, max_length=256, verbose_name='\u5bc6\u7801')),
('mac_addr', models.CharField(blank=True, max_length=20, unique=True, verbose_name='MAC\u5730\u5740')),
@ -32,7 +32,7 @@ class Migration(migrations.Migration):
('disk', models.CharField(blank=True, max_length=1024, verbose_name='\u786c\u76d8')),
('os', models.CharField(blank=True, max_length=128, verbose_name='\u7cfb\u7edf\u4fe1\u606f')),
('cabinet_no', models.CharField(blank=True, max_length=32, verbose_name='\u673a\u67dc\u53f7')),
('cabinet_pos', models.IntegerField(blank=True, verbose_name='\u673a\u5668\u4f4d\u7f6e')),
('cabinet_pos', models.IntegerField(blank=True, null=True, verbose_name='\u8d44\u4ea7\u4f4d\u7f6e')),
('number', models.CharField(blank=True, max_length=32, unique=True, verbose_name='\u8d44\u4ea7\u7f16\u53f7')),
('sn', models.CharField(blank=True, max_length=128, unique=True, verbose_name='SN\u7f16\u53f7')),
('created_by', models.CharField(blank=True, max_length=32, verbose_name='\u521b\u5efa\u8005')),
@ -101,11 +101,11 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='asset',
name='status',
field=models.ManyToManyField(blank=True, related_name='asset_status_extend', to='assets.AssetExtend', verbose_name='\u673a\u5668\u72b6\u6001'),
field=models.ManyToManyField(blank=True, related_name='asset_status_extend', to='assets.AssetExtend', verbose_name='\u8d44\u4ea7\u72b6\u6001'),
),
migrations.AddField(
model_name='asset',
name='type',
field=models.ManyToManyField(blank=True, related_name='asset_type_extend', to='assets.AssetExtend', verbose_name='\u673a\u5668\u7c7b\u578b'),
field=models.ManyToManyField(blank=True, related_name='asset_type_extend', to='assets.AssetExtend', verbose_name='\u8d44\u4ea7\u7c7b\u578b'),
),
]

@ -42,11 +42,11 @@ class AssetExtend(models.Model):
class Asset(models.Model):
ip = models.CharField(max_length=32, blank=True, verbose_name="主机IP")
ip = models.CharField(max_length=32, blank=True, verbose_name="资产IP")
other_ip = models.CharField(max_length=255, blank=True, verbose_name="其他IP")
remote_card_ip = models.CharField(max_length=16, blank=True, verbose_name=u'远控卡IP')
hostname = models.CharField(max_length=128, unique=True, blank=True, verbose_name=u"主机名")
port = models.IntegerField(blank=True, verbose_name=u"端口")
port = models.IntegerField(blank=True, verbose_name=u"端口")
group = models.ManyToManyField(AssetGroup, blank=True, verbose_name=u"所属主机组")
username = models.CharField(max_length=16, blank=True, verbose_name=u"管理用户名")
password = models.CharField(max_length=256, blank=True, verbose_name=u"密码")
@ -58,12 +58,12 @@ class Asset(models.Model):
disk = models.CharField(max_length=1024, blank=True, verbose_name=u'硬盘')
os = models.CharField(max_length=128, blank=True, verbose_name=u'系统信息')
cabinet_no = models.CharField(max_length=32, blank=True, verbose_name=u'机柜号')
cabinet_pos = models.IntegerField(max_length=4, null=True, blank=True, verbose_name=u'机器位置')
cabinet_pos = models.IntegerField(null=True, blank=True, verbose_name=u'资产位置')
number = models.CharField(max_length=32, blank=True, unique=True, verbose_name=u'资产编号')
status = models.ManyToManyField(AssetExtend, blank=True,
related_name="asset_status_extend", verbose_name="机器状态")
related_name="asset_status_extend", verbose_name="资产状态")
type = models.ManyToManyField(AssetExtend, blank=True,
related_name="asset_type_extend", verbose_name="机器类型")
related_name="asset_type_extend", verbose_name="资产类型")
env = models.ManyToManyField(AssetExtend, blank=True,
related_name="asset_env_extend", verbose_name="所属主机组环境")
sn = models.CharField(max_length=128, blank=True, unique=True, verbose_name=u"SN编号")

@ -22,12 +22,6 @@
<div class="ibox-content">
<div class="panel blank-panel">
{# <div class="panel-options">#}
{# <ul class="nav nav-tabs">#}
{# <li class="active"><a href="{% url 'assets:asset-add' %}" class="text-center"><i class="fa fa-laptop"></i> 单台添加 </a></li>#}
{# <li><a href="{% url 'asset_add_batch' %}" class="text-center"><i class="fa fa-bar-chart-o"></i> 批量添加 </a></li>#}
{# </ul>#}
{# </div>#}
<div class="panel-body">
<div class="tab-content">
<div id="tab-1" class="ibox float-e-margins tab-pane active">
@ -40,90 +34,73 @@
<form id="assetForm" method="post" class="form-horizontal">
{% csrf_token %}
<h3 class="widget-head-color-box">基本信息</h3>
<h2 class="widget-head-color-box">基本信息</h2>
{{ form.hostname|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ form.ip|bootstrap_horizontal }}
<p class="col-sm-offset-2">Tips: 如果IP地址不填写, IP默认会设置与主机名一致</p>
{# <div class="hr-line-dashed"></div>#}
{# <div class="form-group">#}
{# <label for="j_group" class="col-sm-2 control-label">管理用户<span class="red-fonts"> *</span></label>#}
{# <div class="col-sm-2">#}
{# <div class="radio i-checks">#}
{# <label style="padding-left: 0">#}
{# <input type="checkbox" checked="checked" id="id_use_default_auth" name="use_default_auth"><span> 使用默认 </span>#}
{# </label>#}
{# </div>#}
{# </div>#}
{# </div>#}
{# <p class="col-sm-offset-2">Tips: 管理用户是服务器存在的root或拥有sudo的用户用来推送系统用户</p>#}
{# <div class="form-group" id="admin_account" style="display: none">#}
{# <label class="col-sm-2 control-label"> <span class="red-fonts"></span> </label>#}
{# <div class="col-sm-3">#}
{# <input type="text" placeholder="Username" name="username" class="form-control">#}
{# </div>#}
{##}
{# <label class="col-sm-1 control-label"> <span class="red-fonts"></span> </label>#}
{# <div class="col-sm-4">#}
{# <input type="password" placeholder="Password" name="password" class="form-control">#}
{# </div>#}
{# </div>#}
{# <p class="col-sm-offset-2">Tips: 如果IP地址不填写, IP默认会设置与主机名一致</p>#}
<div class="form-group" id="id_port">
<div class="hr-line-dashed"></div>
<label class="col-sm-2 control-label"> 端口<span class="red-fonts">*</span> </label>
<div class="col-sm-8">
<input type="text" placeholder="Port" name="port" class="form-control" value="{{ default_port }}">
<label class="col-sm-2 control-label">端口</label>
<div class="col-sm-9">
<input type="text" placeholder="" name="port" class="form-control">
</div>
</div>
{# <div class="hr-line-dashed"></div>#}
{# {{ form.group|bootstrap_horizontal }}#}
{# {{ af.is_active|bootstrap_horizontal }}#}
{# <div class="form-group" id="id_type">#}
{# <div class="hr-line-dashed"></div>#}
{# <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="hr-line-dashed"></div>
{{ form.comment|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
<h3>关联资产用户</h3>
<h2>关联资产用户</h2>
<div class="form-group">
<label for="j_group" class="col-sm-2 control-label">管理用户<span class="red-fonts"> *</span></label>
<div class="col-sm-8">
<label for="j_group" class="col-sm-2 control-label">管理用户</label>
<div class="col-sm-9">
<div class="radio i-checks">
<label><input type="radio" checked="checked" id="id_use_default_auth" name="use_default_auth"><span>使用预定义管理用户</span></label>
<label><input type="radio" checked="checked" id="id_use_default_auth" name="use_default_auth"><span>自定义</span></label>
<label><input type="radio" id="id_use_default_auth" name="use_default_auth"><span>自定义</span></label>
</div>
</div>
</div>
<p class="col-sm-offset-2">Tips: 管理用户是服务器存在的root或拥有sudo的用户用来推送系统用户</p>
<div class="form-group" id="admin_account" style="display: none">
<label class="col-sm-2 control-label"> <span class="red-fonts"></span> </label>
<div class="col-sm-3">
<input type="text" placeholder="Username" name="username" class="form-control">
</div>
<label class="col-sm-1 control-label"> <span class="red-fonts"></span> </label>
<div class="col-sm-4">
<input type="password" placeholder="Password" name="password" class="form-control">
<div class="form-group" id="id_port">
<div class="col-sm-offset-2 col-sm-9">
<input type="text" placeholder="请选择管理用户" name="manager_user" class="form-control">
</div>
</div>
<div class="form-group"><label class="col-sm-2 control-label"> 是否激活<span class="red-fonts"> *</span> </label>
<div class="col-sm-8">
<div class="radio i-checks">
<label> <input type="radio" checked="" value="1" name="is_active">激活 </label>
<label> <input type="radio" value="0" name="is_active"> 禁用</label>
</div>
<p class="col-sm-offset-2">Tips: 管理用户是服务器存在的root或拥有sudo的用户用来推送系统用户</p>
<div class="form-group">
<div class="hr-line-dashed"></div>
<label for="system_user" class="col-sm-2 control-label">系统用户</label>
<div class="col-sm-9">
<input type="text" placeholder="" name="system_user" class="form-control">
</div>
</div>
<div class="hr-line-dashed"></div>
<h2>所属</h2>
{{ form.idc|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
{{ form.group|bootstrap_horizontal }}
<div class="hr-line-dashed"></div>
<h2>标签</h2>
<div class="hr-line-dashed"></div>
<div class="form-group">
<div class="col-sm-4 col-sm-offset-2">
<div class="col-sm-4 col-sm-offset-5">
<button class="btn btn-white" type="reset"> 重置 </button>
<button class="btn btn-primary" type="submit"> 提交 </button>
</div>
@ -162,7 +139,7 @@
});
var required_fields = ["id_hostname", "id_port"];
var required_fields = ["id_ip", "id_hostname", "id_port"];
required_fields.forEach(function(field) {
$('label[for="' + field + '"]').parent().addClass("required");
});

@ -32,8 +32,4 @@ def pagination_range(total_page, current_num=1, display=5):
start = current_num - display/2 if current_num > display/2 else 1
end = start + display if start + display <= total_page else total_page + 1
return range(start, end)
return range(start, end)

@ -21,4 +21,3 @@ def get_object_or_none(model, **kwargs):
except model.DoesNotExist:
obj = None
return obj

@ -29,5 +29,3 @@ class UserGroupSerializer(serializers.ModelSerializer):
class Meta:
model = UserGroup
fields = '__all__'

@ -36,6 +36,3 @@ def user_avatar_url(user):
default_avatar = default_avatar_list[len(user.username) % len(default_avatar_list)]
return os.path.join(settings.MEDIA_URL, 'avatar', 'default', default_avatar)
return 'https://www.gravatar.com/avatar/c6812ab450230979465d7bf288eadce2a?s=120&d=identicon'

Loading…
Cancel
Save