From 0c0f05b6d9fd9c88c8063efba953549d4ea742e1 Mon Sep 17 00:00:00 2001
From: wangyong <864072399@qq.com>
Date: Tue, 3 Nov 2015 17:07:46 +0800
Subject: [PATCH] jasset base

---
 jasset/asset_api.py                 |  15 +++
 jasset/forms.py                     |  19 +++-
 jasset/models.py                    |  10 +-
 jasset/models_bak.py                | 151 +++++++++++++++++++++++++
 jasset/urls.py                      |   6 +-
 jasset/views.py                     | 141 ++++++++++++++++-------
 jumpserver/settings.py              |   2 +-
 templates/jasset/asset_add.html     |  59 +++++-----
 templates/jasset/asset_add_bak.html | 166 ++++++++++++++++++++++++++++
 templates/jasset/asset_detail.html  |  61 ++++++++++
 templates/jasset/asset_edit.html    | 114 ++++++++++++-------
 templates/jasset/asset_list.html    |  54 +++++++--
 templates/jasset/error.html         |  13 +++
 templates/jasset/group_add.html     |  66 +++++------
 templates/jasset/group_detail.html  |  32 +++---
 templates/jasset/group_edit.html    |  27 ++---
 templates/nav.html                  |   2 +-
 17 files changed, 726 insertions(+), 212 deletions(-)
 create mode 100644 jasset/models_bak.py
 create mode 100644 templates/jasset/asset_add_bak.html
 create mode 100644 templates/jasset/error.html

diff --git a/jasset/asset_api.py b/jasset/asset_api.py
index 6968efa7..10a0075e 100644
--- a/jasset/asset_api.py
+++ b/jasset/asset_api.py
@@ -32,6 +32,21 @@ def db_add_group(**kwargs):
             group_add_asset(group, asset_id)
 
 
+def db_update_group(**kwargs):
+    """
+    add a asset group in database
+    数据库中更新资产
+    """
+    group_id = kwargs.pop('id')
+    asset_id_list = kwargs.pop('asset_select')
+    group = get_object(AssetGroup, id=group_id)
+
+    for asset_id in asset_id_list:
+            group_add_asset(group, asset_id)
+
+    AssetGroup.objects.filter(id=group_id).update(**kwargs)
+
+
 def db_asset_add(**kwargs):
     """
     add asset to db
diff --git a/jasset/forms.py b/jasset/forms.py
index 64839060..1fd36c40 100644
--- a/jasset/forms.py
+++ b/jasset/forms.py
@@ -5,10 +5,27 @@ from jasset.models import IDC, Asset, AssetGroup
 
 
 class AssetForm(forms.ModelForm):
+    active_choice = (
+        (1, "激活"),
+        (0, "禁用")
+    )
+    is_active = forms.ChoiceField(
+        label=u"是否激活", required=True, initial = 1,
+        widget=forms.RadioSelect, choices=active_choice
+    )
+
     class Meta:
         model = Asset
         fields = [
             "ip", "second_ip", "hostname", "port", "group", "username", "password", "use_default_auth",
             "idc", "mac", "remote_ip", "brand", "cpu", "memory", "disk", "system_type", "system_version",
             "cabinet", "position", "number", "status", "asset_type", "env", "sn", "is_active", "comment"
-            ]
\ No newline at end of file
+        ]
+
+
+class AssetGroupForm(forms.ModelForm):
+    class Meta:
+        model = AssetGroup
+        fields = [
+            "name", "comment"
+        ]
diff --git a/jasset/models.py b/jasset/models.py
index 76757d44..670f3f71 100644
--- a/jasset/models.py
+++ b/jasset/models.py
@@ -99,7 +99,7 @@ class Asset(models.Model):
     )
 
     ip = models.IPAddressField(unique=True, verbose_name=u"主机IP")
-    second_ip = models.IPAddressField(unique=True, blank=True, null=True, verbose_name=u"IP2")
+    second_ip = models.CharField(max_length=255, blank=True, null=True, verbose_name=u"å…¶ä»–IP")
     hostname = models.CharField(max_length=64, blank=True, null=True, verbose_name=u"主机名")
     port = models.IntegerField(max_length=6, verbose_name=u"端口号")
     group = models.ManyToManyField(AssetGroup, blank=True, null=True, verbose_name=u"所属主机组")
@@ -108,7 +108,7 @@ class Asset(models.Model):
     use_default_auth = models.BooleanField(default=True, verbose_name=u"使用默认管理账号")
     idc = models.ForeignKey(IDC, blank=True, null=True,  on_delete=models.SET_NULL, verbose_name=u'机房')
     mac = models.CharField(max_length=20, blank=True, null=True, verbose_name=u"MAC地址")
-    remote_ip = models.IPAddressField(unique=True, blank=True, null=True, verbose_name=u'远控卡')
+    remote_ip = models.CharField(max_length=16, blank=True, null=True, verbose_name=u'远控卡')
     brand = models.CharField(max_length=64, blank=True, null=True, verbose_name=u'硬件厂商型号')
     cpu = models.CharField(max_length=64, blank=True, null=True, verbose_name=u'CPU')
     memory = models.CharField(max_length=128, blank=True, null=True, verbose_name=u'内存')
@@ -118,9 +118,9 @@ class Asset(models.Model):
     cabinet = models.CharField(max_length=32, blank=True, null=True, verbose_name=u'机柜号')
     position = models.IntegerField(max_length=2, blank=True, null=True, verbose_name=u'机器位置')
     number = models.CharField(max_length=32, blank=True, null=True, verbose_name=u'资产编号')
-    status = models.IntegerField(max_length=2, choices=SERVER_STATUS, default=1, verbose_name=u"机器状态")
+    status = models.IntegerField(max_length=2, choices=SERVER_STATUS, blank=True, null=True, default=1, verbose_name=u"机器状态")
     asset_type = models.IntegerField(max_length=2, choices=ASSET_TYPE, blank=True, null=True, verbose_name=u"主机类型")
-    env = models.CharField(max_length=32, choices=ENVIRONMENT, blank=True, null=True, verbose_name=u"运行环境")
+    env = models.IntegerField(max_length=2, choices=ENVIRONMENT, blank=True, null=True, verbose_name=u"运行环境")
     sn = models.CharField(max_length=32, blank=True, null=True, verbose_name=u"SN编号")
     date_added = models.DateTimeField(auto_now=True, default=datetime.datetime.now(), null=True)
     is_active = models.BooleanField(default=True, verbose_name=u"是否激活")
@@ -152,4 +152,4 @@ class AssetAlias(models.Model):
     alias = models.CharField(max_length=100, blank=True, null=True)
 
     def __unicode__(self):
-        return self.alias
+        return self.alias
\ No newline at end of file
diff --git a/jasset/models_bak.py b/jasset/models_bak.py
new file mode 100644
index 00000000..9c9252a7
--- /dev/null
+++ b/jasset/models_bak.py
@@ -0,0 +1,151 @@
+# coding: utf-8
+
+import datetime
+from django.db import models
+from juser.models import User, UserGroup
+
+
+class AssetGroup(models.Model):
+    GROUP_TYPE = (
+        ('P', 'PRIVATE'),
+        ('A', 'ASSET'),
+    )
+    name = models.CharField(max_length=80, unique=True)
+    comment = models.CharField(max_length=160, blank=True, null=True)
+
+    def __unicode__(self):
+        return self.name
+
+    def get_asset(self):
+        return self.asset_set.all()
+
+    def get_asset_info(self, printable=False):
+        assets = self.get_asset()
+        ip_comment = {}
+        for asset in assets:
+            ip_comment[asset.ip] = asset.comment
+
+        for ip in sorted(ip_comment):
+            if ip_comment[ip]:
+                print '%-15s -- %s' % (ip, ip_comment[ip])
+            else:
+                print '%-15s' % ip
+        print ''
+
+    def get_asset_num(self):
+        return len(self.get_asset())
+
+    def get_user_group(self):
+        perm_list = self.perm_set.all()
+        user_group_list = []
+        for perm in perm_list:
+            user_group_list.append(perm.user_group)
+        return user_group_list
+
+    def get_user(self):
+        user_list = []
+        user_group_list = self.get_user_group()
+        for user_group in user_group_list:
+            user_list.extend(user_group.user_set.all())
+        return user_list
+
+    def is_permed(self, user=None, user_group=None):
+        if user:
+            if user in self.get_user():
+                return True
+
+        if user_group:
+            if user_group in self.get_user_group():
+                return True
+        return False
+
+
+class IDC(models.Model):
+    name = models.CharField(max_length=32, unique=True)
+    bandwidth = models.CharField(max_length=32, blank=True, null=True)
+    linkman = models.CharField(max_length=16, blank=True, null=True)
+    phone = models.CharField(max_length=32, blank=True, null=True)
+    address = models.CharField(max_length=128, blank=True, null=True)
+    network = models.TextField(blank=True, null=True)
+    date_added = models.DateField(auto_now=True, default=datetime.datetime.now())
+    operator = models.IntegerField(max_length=32, blank=True, null=True)
+    comment = models.CharField(max_length=128, blank=True, null=True)
+
+    def __unicode__(self):
+        return self.name
+
+
+class Asset(models.Model):
+    """
+    asset modle
+    """
+    ENVIRONMENT = (
+        (0, U'生产环境'),
+        (1, U'测试环境')
+    )
+    SERVER_STATUS = (
+        (0, u"已使用"),
+        (1, u"未使用"),
+        (2, u"报废")
+    )
+    ASSET_TYPE = (
+        (0, u"服务器"),
+        (2, u"网络设备"),
+        (3, u"å…¶ä»–")
+    )
+
+    ip = models.IPAddressField(unique=True)
+    second_ip = models.CharField(max_length=255, blank=True, null=True)
+    hostname = models.CharField(max_length=64, blank=True, null=True)
+    port = models.IntegerField(max_length=6)
+    group = models.ManyToManyField(AssetGroup, blank=True, null=True)
+    username = models.CharField(max_length=16, blank=True, null=True)
+    password = models.CharField(max_length=64, blank=True, null=True)
+    use_default_auth = models.BooleanField(default=True)
+    idc = models.ForeignKey(IDC, blank=True, null=True, on_delete=models.SET_NULL)
+    mac = models.CharField(max_length=20, blank=True, null=True)
+    remote_ip = models.IPAddressField(unique=True, blank=True, null=True)
+    brand = models.CharField(max_length=64, blank=True, null=True)
+    cpu = models.CharField(max_length=64, blank=True, null=True)
+    memory = models.CharField(max_length=128, blank=True, null=True)
+    disk = models.CharField(max_length=128, blank=True, null=True)
+    system_type = models.CharField(max_length=32, blank=True, null=True)
+    system_version = models.CharField(max_length=8, blank=True, null=True)
+    cabinet = models.CharField(max_length=32, blank=True, null=True)
+    position = models.IntegerField(max_length=2, blank=True, null=True)
+    number = models.CharField(max_length=32, blank=True, null=True)
+    status = models.IntegerField(max_length=2, choices=SERVER_STATUS, default=1)
+    asset_type = models.IntegerField(max_length=2, choices=ASSET_TYPE, blank=True, null=True)
+    env = models.CharField(max_length=32, choices=ENVIRONMENT, blank=True, null=True)
+    sn = models.CharField(max_length=32, blank=True, null=True)
+    date_added = models.DateTimeField(auto_now=True, default=datetime.datetime.now())
+    is_active = models.BooleanField(default=True)
+    comment = models.CharField(max_length=128, blank=True, null=True)
+
+    def __unicode__(self):
+        return self.ip
+
+    def get_user(self):
+        perm_list = []
+        asset_group_all = self.bis_group.all()
+        for asset_group in asset_group_all:
+            perm_list.extend(asset_group.perm_set.all())
+
+        user_group_list = []
+        for perm in perm_list:
+            user_group_list.append(perm.user_group)
+
+        user_permed_list = []
+        for user_group in user_group_list:
+            user_permed_list.extend(user_group.user_set.all())
+        user_permed_list = list(set(user_permed_list))
+        return user_permed_list
+
+
+class AssetAlias(models.Model):
+    user = models.ForeignKey(User)
+    asset = models.ForeignKey(Asset)
+    alias = models.CharField(max_length=100, null=True)
+
+    def __unicode__(self):
+        return self.alias
diff --git a/jasset/urls.py b/jasset/urls.py
index a3df6dbe..3f18f16f 100644
--- a/jasset/urls.py
+++ b/jasset/urls.py
@@ -16,9 +16,9 @@ urlpatterns = patterns('',
     # url(r"^host_detail/$", host_detail),
     # url(r"^dept_host_ajax/$", dept_host_ajax),
     # url(r"^show_all_ajax/$", show_all_ajax),
-    # url(r'^group_edit/$', group_edit),
-    # url(r'^group_list/$', group_list),
-    # url(r'^group_detail/$', group_detail),
+    url(r'^group_edit/$', group_edit),
+    url(r'^group_list/$', group_list),
+    url(r'^group_detail/$', group_detail),
     # url(r'^group_del_host/$', group_del_host),
 
     # url(r'^host_edit/batch/$', host_edit_batch),
diff --git a/jasset/views.py b/jasset/views.py
index d10448b4..c58d6617 100644
--- a/jasset/views.py
+++ b/jasset/views.py
@@ -37,13 +37,69 @@ def group_add(request):
 
         except ServerError:
             pass
+
         else:
             db_add_group(name=name, comment=comment, asset_select=asset_select)
-            msg = u"主机组 %s 添加成功" % name
+            smg = u"主机组 %s 添加成功" % name
 
     return my_render('jasset/group_add.html', locals(), request)
 
 
+@require_role('admin')
+def group_edit(request):
+    """
+    Edit asset group
+    编辑资产组
+    """
+    header_title, path1, path2 = u'编辑主机组', u'资产管理', u'编辑主机组'
+    group_id = request.GET.get('id', '')
+    group = get_object(AssetGroup, id=group_id)
+
+    asset_all = Asset.objects.all()
+    asset_select = Asset.objects.filter(group=group)
+    asset_no_select = [a for a in asset_all if a not in asset_select]
+
+    if request.method == 'POST':
+        name = request.POST.get('name', '')
+        asset_select = request.POST.getlist('asset_select', [])
+        comment = request.POST.get('comment', '')
+
+        try:
+            if not name:
+                emg = u'组名不能为空'
+                raise ServerError(emg)
+
+            if group.name != name:
+                asset_group_test = get_object(AssetGroup, name=name)
+                if asset_group_test:
+                    emg = u"该组名 %s 已存在" % name
+                    raise ServerError(emg)
+
+        except ServerError:
+            pass
+
+        else:
+            group.asset_set.clear()
+            db_update_group(id=group_id, name=name, comment=comment, asset_select=asset_select)
+            smg = u"主机组 %s 添加成功" % name
+
+        return HttpResponseRedirect('/jasset/group_list')
+
+    return my_render('jasset/group_edit.html', locals(), request)
+
+
+@require_role('admin')
+def group_detail(request):
+    """ 主机组详情 """
+    header_title, path1, path2 = u'主机组详情', u'资产管理', u'主机组详情'
+    group_id = request.GET.get('id', '')
+    group = get_object(AssetGroup, id=group_id)
+    asset_all = Asset.objects.filter(group=group).order_by('ip')
+
+    contact_list, p, contacts, page_range, current_page, show_first, show_end = pages(asset_all, request)
+    return my_render('jasset/group_detail.html', locals(), request)
+
+
 @require_role('admin')
 def group_list(request):
     """
@@ -88,20 +144,8 @@ def asset_add(request):
     asset_group_all = AssetGroup.objects.all()
     af = AssetForm()
     if request.method == 'POST':
+        af_post = AssetForm(request.POST)
         ip = request.POST.get('ip')
-        port = request.POST.get('port')
-        groups = request.POST.getlist('groups')
-        use_default_auth = True if request.POST.getlist('use_default_auth', []) else False
-        is_active = True if request.POST.get('is_active') else False
-        comment = request.POST.get('comment')
-
-        if not use_default_auth:
-            username = request.POST.get('username')
-            password = request.POST.get('password')
-            password_encode = CRYPTOR.encrypt(password)
-        else:
-            username = None
-            password_encode = None
 
         try:
             if Asset.objects.filter(ip=str(ip)):
@@ -110,13 +154,15 @@ def asset_add(request):
 
         except ServerError:
             pass
-        else:
-            db_asset_add(
-                ip=ip, port=port, use_default_auth=use_default_auth, is_active=is_active, comment=comment,
-                groups=groups, username=username, password=password_encode
-            )
 
-            msg = u'主机 %s 添加成功' % ip
+        else:
+            if af_post.is_valid():
+                asset_save = af_post.save(commit=False)
+                asset_save.save()
+                af_post.save_m2m()
+                msg = u'主机 %s 添加成功' % ip
+            else:
+                esg = u'主机 %s 添加失败' % ip
 
     return my_render('jasset/asset_add.html', locals(), request)
 #
@@ -269,32 +315,38 @@ def asset_del(request):
 
 @require_role(role='super')
 def asset_edit(request):
-    """ 修改主机 """
+    """
+    edit a asset
+    修改主机
+    """
     header_title, path1, path2 = u'修改资产', u'资产管理', u'修改资产'
 
     asset_id = request.GET.get('id', '')
     if not asset_id:
         return HttpResponse('没有该主机')
     asset = get_object(Asset, id=asset_id)
-
+    af = AssetForm(instance=asset)
     if request.method == 'POST':
-        ip = request.POST.get('ip')
-        port = request.POST.get('port')
-        groups = request.POST.getlist('groups')
-        use_default_auth = True if request.POST.getlist('use_default_auth', []) else False
-        is_active = True if request.POST.get('is_active') else False
-        comment = request.POST.get('comment')
-
-        if not use_default_auth:
-            username = request.POST.get('username')
-            password = request.POST.get('password')
-            if password == asset.password:
-                password_encode = password
-            else:
-                password_encode = CRYPTOR.encrypt(password)
-        else:
-            username = None
-            password_encode = None
+        af_post = AssetForm(request.POST, instance=asset)
+        ip = request.POST.get('ip', '')
+
+        # ip = request.POST.get('ip')
+        # port = request.POST.get('port')
+        # groups = request.POST.getlist('groups')
+        # use_default_auth = True if request.POST.getlist('use_default_auth', []) else False
+        # is_active = True if request.POST.get('is_active') else False
+        # comment = request.POST.get('comment')
+
+        # if not use_default_auth:
+        #     username = request.POST.get('username')
+        #     password = request.POST.get('password')
+        #     if password == asset.password:
+        #         password_encode = password
+        #     else:
+        #         password_encode = CRYPTOR.encrypt(password)
+        # else:
+        #     username = None
+        #     password_encode = None
 
         try:
             asset_test = get_object(Asset, ip=ip)
@@ -304,10 +356,13 @@ def asset_edit(request):
         except ServerError:
             pass
         else:
-            db_asset_update(id=asset_id, ip=ip, port=port, use_default_auth=use_default_auth,
-                            username=username, password=password_encode,
-                            is_active=is_active, comment=comment)
-            msg = u'主机 %s 修改成功' % ip
+            if af_post.is_valid():
+                af_save = af_post.save(commit=False)
+                af_save.save()
+                af_post.save_m2m()
+                msg = u'主机 %s 修改成功' % ip
+            else:
+                emg = u'主机 %s 修改失败' % ip
             return HttpResponseRedirect('/jasset/asset_detail/?id=%s' % asset_id)
 
     return my_render('jasset/asset_edit.html', locals(), request)
diff --git a/jumpserver/settings.py b/jumpserver/settings.py
index f6afa68f..6c4110a1 100644
--- a/jumpserver/settings.py
+++ b/jumpserver/settings.py
@@ -54,7 +54,7 @@ INSTALLED_APPS = (
     'django.contrib.messages',
     'django.contrib.staticfiles',
     'django.contrib.humanize',
-    "bootstrapform",
+    'bootstrapform',
     'jumpserver',
     'juser',
     'jasset',
diff --git a/templates/jasset/asset_add.html b/templates/jasset/asset_add.html
index 53c15374..d36ca880 100644
--- a/templates/jasset/asset_add.html
+++ b/templates/jasset/asset_add.html
@@ -39,27 +39,26 @@
                                     {% if msg %}
                                         <div class="alert alert-success text-center">{{ msg }}</div>
                                     {% endif %}
+
                                     <form id="assetForm" method="post" class="form-horizontal">
-                                        <!--<div class="form-group"><label class="col-sm-2 control-label"> IP地址<span class="red-fonts">*</span> </label>-->
-                                            <!--<div class="col-sm-8"><input type="text" name="ip" placeholder="IP" class="form-control"></div>-->
-                                        <!--</div>-->
+
                                         {{ af.ip|bootstrap_horizontal }}
 
                                         <div class="hr-line-dashed"></div>
-                                        <div class="form-group">
-                                            <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">
-                                            </div>
-                                        </div>
+                                        {{ af.port|bootstrap_horizontal }}
+
+                                        <div class="hr-line-dashed"></div>
+                                        {{ af.idc|bootstrap_horizontal }}
+
+{#                                        {{ af.use_default_auth|bootstrap_horizontal }}#}
 
                                         <div class="hr-line-dashed"></div>
                                         <div class="form-group">
-                                            <label for="j_group" class="col-sm-2 control-label">使用默认管理账号</label>
-                                            <div class="col-sm-1">
+                                            <label for="j_group" class="col-sm-2 control-label">管理账号</label>
+                                            <div class="col-sm-2">
                                                 <div class="radio i-checks">
                                                     <label>
-                                                        <input type="checkbox" checked="" value="1" id="use_default_auth" name="use_default_auth">
+                                                        <input type="checkbox" checked="" id="id_use_default_auth" name="use_default_auth"><span> 使用默认 </span>
                                                     </label>
                                                 </div>
                                             </div>
@@ -78,31 +77,23 @@
                                         </div>
 
                                         <div class="hr-line-dashed"></div>
-                                        <div class="form-group">
-                                            <label for="groups" class="col-sm-2 control-label">所属主机组</label>
-                                            <div class="col-sm-8">
-                                                <select id="groups" name="groups" class="form-control m-b" multiple size="10">
-                                                    {% for asset_group in asset_group_all %}
-                                                        <option type="checkbox" value="{{ asset_group.id }}">{{ asset_group.name }} {% if asset_group.comment %} --- {{ asset_group.comment }} {% endif %}</option>
-                                                    {% endfor %}
-                                                </select>
-                                            </div>
-                                        </div>
+                                        {{ af.group|bootstrap_horizontal }}
 
                                         <div class="hr-line-dashed"></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>
-                                            </div>
-                                        </div>
+                                        {{ af.is_active|bootstrap_horizontal }}
+
+{#                                        <div class="hr-line-dashed"></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="" name="is_active">激活 </label>#}
+{#                                                    <label> <input type="radio" name="is_active"> 禁用</label>#}
+{#                                                </div>#}
+{#                                            </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" placeholder="comment" name="comment" class="form-control"></div>
-                                        </div>
+                                        {{ af.comment|bootstrap_horizontal }}
 
                                         <div class="hr-line-dashed"></div>
                                         <div class="form-group">
@@ -127,7 +118,7 @@
 <script>
 
 $('document').ready(function(){
-    $('#use_default_auth').click(function(){
+    $('#id_use_default_auth').click(function(){
         if ($(this).is(':checked')){
             $('#admin_account').css('display', 'none')
         }
diff --git a/templates/jasset/asset_add_bak.html b/templates/jasset/asset_add_bak.html
new file mode 100644
index 00000000..397d60ae
--- /dev/null
+++ b/templates/jasset/asset_add_bak.html
@@ -0,0 +1,166 @@
+{% extends 'base.html' %}
+{% load mytags %}
+{% 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> 填写资产基本信息 </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>
+                        <a class="close-link">
+                            <i class="fa fa-times"></i>
+                        </a>
+                    </div>
+                </div>
+
+                <div class="ibox-content">
+                    <div class="panel blank-panel">
+                        <div class="panel-options">
+                            <ul class="nav nav-tabs">
+                                <li class="active"><a href="/jasset/asset_add/" class="text-center"><i class="fa fa-laptop"></i> 单台添加 </a></li>
+                                <li><a href="/jasset/host_add_multi" 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">
+                                    {% if error %}
+                                        <div class="alert alert-warning text-center">{{ error }}</div>
+                                    {% endif %}
+                                    {% if msg %}
+                                        <div class="alert alert-success text-center">{{ msg }}</div>
+                                    {% endif %}
+                                    <form id="assetForm" method="post" class="form-horizontal">
+                                        <div class="form-group"><label class="col-sm-2 control-label"> IP地址<span class="red-fonts">*</span> </label>
+                                            <div class="col-sm-8"><input type="text" name="ip" placeholder="IP" class="form-control"></div>
+                                        </div>
+
+                                        <div class="hr-line-dashed"></div>
+                                        <div class="form-group">
+                                            <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">
+                                            </div>
+                                        </div>
+
+                                        <div class="hr-line-dashed"></div>
+                                        <div class="form-group">
+                                            <label for="j_group" class="col-sm-2 control-label">管理账号</label>
+                                            <div class="col-sm-2">
+                                                <div class="radio i-checks">
+                                                    <label>
+                                                        <input type="checkbox" checked="" value="1" id="use_default_auth" name="use_default_auth"><span> 使用默认 </span>
+                                                    </label>
+                                                </div>
+                                            </div>
+                                        </div>
+
+                                        <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>
+
+                                        <div class="hr-line-dashed"></div>
+                                        <div class="form-group">
+                                            <label for="groups" class="col-sm-2 control-label">所属主机组</label>
+                                            <div class="col-sm-8">
+                                                <select id="groups" name="groups" class="form-control m-b" multiple size="10">
+                                                    {% for asset_group in asset_group_all %}
+                                                        <option type="checkbox" value="{{ asset_group.id }}">{{ asset_group.name }} {% if asset_group.comment %} --- {{ asset_group.comment }} {% endif %}</option>
+                                                    {% endfor %}
+                                                </select>
+                                            </div>
+                                        </div>
+
+                                        <div class="hr-line-dashed"></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>
+                                            </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" placeholder="comment" name="comment" class="form-control"></div>
+                                        </div>
+
+                                        <div class="hr-line-dashed"></div>
+                                        <div class="form-group">
+                                            <div class="col-sm-4 col-sm-offset-2">
+                                                <button class="btn btn-white" type="reset"> 重置 </button>
+                                                <button class="btn btn-primary" type="submit"> 提交 </button>
+                                            </div>
+                                        </div>
+                                    </form>
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+{% endblock %}
+
+{% block self_footer_js %}
+<script>
+
+$('document').ready(function(){
+    $('#use_default_auth').click(function(){
+        if ($(this).is(':checked')){
+            $('#admin_account').css('display', 'none')
+        }
+        else {
+            $('#admin_account').css('display', 'block')
+        }
+    })
+});
+
+$('#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}$/, '端口号不正确'],
+    },
+    fields: {
+        "ip": {
+            rule: "required;check_ip",
+            tip: "输入IP",
+            ok: "",
+            msg: {required: "必须填写!"}
+        },
+        "port": {
+            rule: "required;check_port",
+            tip: "输入端口号",
+            ok: "",
+            msg: {required: "必须填写!"}
+        }
+    },
+    valid: function(form) {
+        form.submit();
+    }
+});
+
+</script>
+
+{% endblock %}
\ No newline at end of file
diff --git a/templates/jasset/asset_detail.html b/templates/jasset/asset_detail.html
index b6ad773e..fb41f600 100644
--- a/templates/jasset/asset_detail.html
+++ b/templates/jasset/asset_detail.html
@@ -33,6 +33,14 @@
                                         <td class="text-navy">IP</td>
                                         <td>{{ asset.ip }}</td>
                                     </tr>
+                                    <tr>
+                                        <td class="text-navy">主机名</td>
+                                        <td>{{ asset.hostname }}</td>
+                                    </tr>
+                                    <tr>
+                                        <td class="text-navy">远控IP</td>
+                                        <td>{{ asset.remote_ip }}</td>
+                                    </tr>
                                     <tr>
                                         <td class="text-navy">端口</td>
                                         <td>{{ asset.port }}</td>
@@ -42,6 +50,11 @@
                                         <td class="text-navy">主机组</td>
                                         <td>
                                              <table class="table">
+                                                 {% for asset_group in asset.group.all %}
+                                                    <tr>
+                                                        <td>{{ asset_group.name }}</td>
+                                                    </tr>
+                                                 {% endfor %}
                                              </table>
                                         </td>
                                     </tr>
@@ -49,6 +62,54 @@
                                         <td class="text-navy">使用默认管理账号</td>
                                         <td>{{ asset.use_default_auth|bool2str }}</td>
                                     </tr>
+                                    <tr>
+                                        <td class="text-navy">机房</td>
+                                        <td>{{ asset.idc.name }}</td>
+                                    </tr>
+                                    <tr>
+                                        <td class="text-navy">硬件厂商型号</td>
+                                        <td>{{ asset.brand }}</td>
+                                    </tr>
+                                    <tr>
+                                        <td class="text-navy">CPU</td>
+                                        <td>{{ asset.cpu }}</td>
+                                    </tr>
+                                    <tr>
+                                        <td class="text-navy">内存</td>
+                                        <td>{{ asset.memory }}</td>
+                                    </tr>
+                                    <tr>
+                                        <td class="text-navy">硬盘</td>
+                                        <td>{{ asset.disk }}</td>
+                                    </tr>
+                                    <tr>
+                                        <td class="text-navy">资产编号</td>
+                                        <td>{{ asset.number }}</td>
+                                    </tr>
+                                    <tr>
+                                        <td class="text-navy">SN</td>
+                                        <td>{{ asset.sn }}</td>
+                                    </tr>
+                                    <tr>
+                                        <td class="text-navy">主机类型</td>
+                                        <td>{{ asset.get_asset_type_display }}</td>
+                                    </tr>
+                                    <tr>
+                                        <td class="text-navy">运行环境</td>
+                                        <td>{{ asset.get_env_display }}</td>
+                                    </tr>
+                                    <tr>
+                                        <td class="text-navy">机器状态</td>
+                                        <td>{{ asset.get_status_display }}</td>
+                                    </tr>
+                                    <tr>
+                                        <td class="text-navy">机柜号</td>
+                                        <td>{{ asset.cabinet }}</td>
+                                    </tr>
+                                    <tr>
+                                        <td class="text-navy">机柜位置</td>
+                                        <td>{{ asset.position }}</td>
+                                    </tr>
                                     <tr>
                                         <td class="text-navy">激活</td>
                                         <td>{{ asset.is_active|bool2str }}</td>
diff --git a/templates/jasset/asset_edit.html b/templates/jasset/asset_edit.html
index 22ddecdf..28d7f9bc 100644
--- a/templates/jasset/asset_edit.html
+++ b/templates/jasset/asset_edit.html
@@ -1,5 +1,6 @@
 {% extends 'base.html' %}
 {% load mytags %}
+{% load bootstrap %}
 {% block content %}
 {% include 'nav_cat_bar.html' %}
 <div class="wrapper wrapper-content animated fadeInRight">
@@ -32,73 +33,102 @@
                                         <div class="alert alert-success text-center">{{ msg }}</div>
                                     {% endif %}
                                     <form id="assetForm" method="post" class="form-horizontal">
-                                        <div class="form-group"><label class="col-sm-2 control-label"> IP地址<span class="red-fonts">*</span> </label>
-                                            <div class="col-sm-8"><input type="text" name="ip" value="{{ asset.ip }}" class="form-control"></div>
-                                        </div>
+
+                                        {{ af.ip|bootstrap_horizontal }}
 
                                         <div class="hr-line-dashed"></div>
-                                        <div class="form-group">
-                                            <label class="col-sm-2 control-label"> 端口号<span class="red-fonts">*</span> </label>
-                                            <div class="col-sm-8">
-                                                <input type="text" value="{{ asset.port }}" name="port" class="form-control">
-                                            </div>
-                                        </div>
+                                        {{ af.hostname|bootstrap_horizontal }}
+
+                                        <div class="hr-line-dashed"></div>
+                                        {{ af.remote_ip|bootstrap_horizontal }}
+
+                                        <div class="hr-line-dashed"></div>
+                                        {{ af.port|bootstrap_horizontal }}
 
                                         <div class="hr-line-dashed"></div>
                                         <div class="form-group">
-                                            <label for="j_group" class="col-sm-2 control-label">使用默认管理账号</label>
-                                            <div class="col-sm-1">
+                                            <label for="j_group" class="col-sm-2 control-label">管理账号</label>
+                                            <div class="col-sm-2">
                                                 <div class="radio i-checks">
                                                     <label>
-                                                        <input type="checkbox" {% ifequal asset.use_default_auth 1 %} checked="" {% endifequal %} value="1" id="use_default_auth" name="use_default_auth">
+                                                        <input type="checkbox" checked="" id="id_use_default_auth" name="use_default_auth"><span> 使用默认 </span>
                                                     </label>
                                                 </div>
                                             </div>
                                         </div>
 
-                                        <div class="form-group" id="admin_account" {% ifequal asset.use_default_auth 1 %} style="display: none" {% endifequal %}>
+                                        <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" {% ifnotequal asset.use_default_auth 1 %} value="{{ asset.username }}" {% endifnotequal %} name="username" class="form-control">
+                                                <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" {% ifnotequal asset.use_default_auth 1 %} value="{{ asset.password }}" {% endifnotequal %}  name="password" class="form-control">
+                                                <input type="password" placeholder="Password" name="password" class="form-control">
                                             </div>
                                         </div>
 
+
                                         <div class="hr-line-dashed"></div>
-                                        <div class="form-group">
-                                            <label for="groups" class="col-sm-2 control-label">所属主机组</label>
-                                            <div class="col-sm-8">
-                                                <select id="groups" name="groups" class="form-control m-b" multiple size="10">
-                                                    {% for g in egroup %}
-                                                        <option type="checkbox" value="{{ g.id }}">{{ g.name }} {% if g.comment %} --- {{ g.comment }} {% endif %}</option>
-                                                    {% endfor %}
-                                                </select>
-                                            </div>
-                                        </div>
+                                        {{ af.group|bootstrap_horizontal }}
 
                                         <div class="hr-line-dashed"></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">
-                                                    {% ifequal asset.is_active 1 %}
-                                                        <label> <input type="radio" checked="" value="1" name="is_active">激活 </label>
-                                                        <label> <input type="radio"  value="0" name="is_active"> 禁用</label>
-                                                    {% else %}
-                                                        <label> <input type="radio"  value="1" name="is_active">激活 </label>
-                                                        <label> <input type="radio"  checked="" value="0" name="is_active"> 禁用</label>
-                                                    {% endifequal %}
-                                                </div>
-                                            </div>
-                                        </div>
+                                        {{ af.idc|bootstrap_horizontal }}
+
+                                       <div class="hr-line-dashed"></div>
+                                        {{ af.brand|bootstrap_horizontal }}
 
                                         <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="{{ asset.comment }}" name="comment" class="form-control"></div>
-                                        </div>
+                                        {{ af.cpu|bootstrap_horizontal }}
+
+                                        <div class="hr-line-dashed"></div>
+                                        {{ af.memory|bootstrap_horizontal }}
+
+                                        <div class="hr-line-dashed"></div>
+                                        {{ af.disk|bootstrap_horizontal }}
+
+                                        <div class="hr-line-dashed"></div>
+                                        {{ af.number|bootstrap_horizontal }}
+
+                                        <div class="hr-line-dashed"></div>
+                                        {{ af.sn|bootstrap_horizontal }}
+
+                                        <div class="hr-line-dashed"></div>
+                                        {{ af.cabinet|bootstrap_horizontal }}
+
+                                        <div class="hr-line-dashed"></div>
+                                        {{ af.position|bootstrap_horizontal }}
+
+                                        <div class="hr-line-dashed"></div>
+                                        {{ af.asset_type|bootstrap_horizontal }}
+
+                                        <div class="hr-line-dashed"></div>
+                                        {{ af.env|bootstrap_horizontal }}
+
+                                        <div class="hr-line-dashed"></div>
+                                        {{ af.status|bootstrap_horizontal }}
+
+                                        <div class="hr-line-dashed"></div>
+                                        {{ af.is_active|bootstrap_horizontal }}
+
+{#                                        <div class="hr-line-dashed"></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">#}
+{#                                                    {% ifequal asset.is_active 1 %}#}
+{#                                                        <label> <input type="radio" checked="" value="1" name="is_active">激活 </label>#}
+{#                                                        <label> <input type="radio"  value="0" name="is_active"> 禁用</label>#}
+{#                                                    {% else %}#}
+{#                                                        <label> <input type="radio"  value="1" name="is_active">激活 </label>#}
+{#                                                        <label> <input type="radio"  checked="" value="0" name="is_active"> 禁用</label>#}
+{#                                                    {% endifequal %}#}
+{#                                                </div>#}
+{#                                            </div>#}
+{#                                        </div>#}
+
+                                       <div class="hr-line-dashed"></div>
+                                        {{ af.comment|bootstrap_horizontal }}
 
                                         <div class="hr-line-dashed"></div>
                                         <div class="form-group">
@@ -123,7 +153,7 @@
 <script>
 
 $('document').ready(function(){
-    $('#use_default_auth').click(function(){
+    $('#id_use_default_auth').click(function(){
         if ($(this).is(':checked')){
             $('#admin_account').css('display', 'none')
         }
diff --git a/templates/jasset/asset_list.html b/templates/jasset/asset_list.html
index 6b1812b4..1f7c8c84 100644
--- a/templates/jasset/asset_list.html
+++ b/templates/jasset/asset_list.html
@@ -23,8 +23,48 @@
                 </div>
 
                 <div class="ibox-content">
+                    <div class="col-sm-2" style="padding-left: 0px">
+                        <label>
+                            <select name="change_idc" class="form-control m-b" onchange="change_info()">
+                                <option value="">IDC机房</option>
+                                {% for i in idcs %}
+                                    <option value="{{i.name}}"> {{ i }}</option>
+                                {% endfor %}
+                            </select>
+                        </label>
+                    </div>
+                    <div class="col-sm-2">
+                        <label>
+                            <select name="change_project" class="form-control m-b" onchange="change_info()">
+                                <option value="all">主机组</option>
+                                {% for i in projects %}
+                                    <option value="{{ i.name }}"> {{ i.name }} </option>
+                                {% endfor %}
+                            </select>
+                        </label>
+                    </div>
+
+                    <div class="col-sm-2">
+                        <label>
+                            <select name="change_type" class="form-control m-b" onchange="change_info()">
+                                <option value="">所有类型</option>
+                                {% for i in server_type %}
+                                    <option value="{{ i.0 }}"> {{ i.1 }}</option>
+                                {% endfor %}
+                            </select>
+                        </label>
+                    </div>
+                    <div class="col-sm-2">
+                        <label>
+                            <select name="change_type" class="form-control m-b" onchange="change_info()">
+                                <option value="">状态</option>
+                                {% for i in server_type %}
+                                    <option value="{{ i.0 }}"> {{ i.1 }}</option>
+                                {% endfor %}
+                            </select>
+                        </label>
+                    </div>
                     <div>
-                        <a target="_blank" href="/jasset/asset_add/" class="btn btn-sm btn-primary "> 添加 </a>
                         <form id="search_form" method="get" action="" class="pull-right mail-search">
                             <div class="input-group">
                                 <input type="text" class="form-control input-sm" id="search_input" name="keyword" placeholder="Search">
@@ -46,11 +86,11 @@
                                     <input id="checkall" type="checkbox" class="i-checks" name="checkall" value="checkall" data-editable='false' onclick="check_all('contents_form')">
                                 </th>
                                 <th class="text-center" name="ip"> IP地址 </th>
-                                <th class="text-center"> 端口号 </th>
+                                <th class="text-center"> 主机名 </th>
+                                <th class="text-center"> IDC </th>
                                 <th class="text-center"> 所属主机组 </th>
+                                <th class="text-center"> 配置信息 </th>
                                 <th class="text-center"> 使用默认管理 </th>
-                                <th class="text-center"> 激活 </th>
-                                <th class="text-center" name="comment"> 备注 </th>
                                 <th class="text-center"> 操作 </th>
                             </tr>
                         </thead>
@@ -61,11 +101,11 @@
                                     <input name="id" value="{{ asset.id }}" type="checkbox" class="i-checks">
                                 </td>
                                 <td class="text-center"> {{ asset.ip }} </td>
-                                <td class="text-center"> {{ asset.port }} </td>
+                                <td class="text-center"> {{ asset.hostname }} </td>
+                                <td class="text-center"> {{ asset.idc.name }} </td>
                                 <td class="text-center">{{ asset.port }}</td>
+                                <td class="text-center">{{ asset.cpu }}|{{ asset.memory }}|{{ asset.disk }}</td>
                                 <td class="text-center"> {{ asset.use_default_auth|bool2str }} </td>
-                                <td class="text-center"> {{ asset.is_active|bool2str }} </td>
-                                <td class="text-center"> {{ asset.comment }} </td>
                                 <td class="text-center" data-editable='false'>
                                     <a href="/jasset/asset_detail/?id={{ asset.id }}" class="btn btn-xs btn-primary">详情</a>
                                     {% ifnotequal session_role_id 0 %}
diff --git a/templates/jasset/error.html b/templates/jasset/error.html
new file mode 100644
index 00000000..4fa21424
--- /dev/null
+++ b/templates/jasset/error.html
@@ -0,0 +1,13 @@
+{% for field in af %}
+<div class="alert alert-warning text-center"> {{ field.errors }}</div>
+{{ field.label_tag }}: {{ field }}
+{% endfor %}
+
+
+{% if af.errors %}
+<ul>
+{% for error in af.errors %}
+<li><strong>{{ error }}</strong></li>
+{% endfor %}
+</ul>
+{% endif %}
\ No newline at end of file
diff --git a/templates/jasset/group_add.html b/templates/jasset/group_add.html
index b13695d4..f5013ae1 100644
--- a/templates/jasset/group_add.html
+++ b/templates/jasset/group_add.html
@@ -22,7 +22,7 @@
         <div class="col-lg-10">
             <div class="ibox float-e-margins">
                 <div id="ibox-content" class="ibox-title">
-                    <h5> 填写资产组基本信息 </h5>
+                    <h5> 填写主机组基本信息 </h5>
                     <div class="ibox-tools">
                         <a class="collapse-link">
                             <i class="fa fa-chevron-up"></i>
@@ -30,37 +30,34 @@
                         <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>
 
-{#                <select id="assets_total" name="assets" class="form-control m-b" size="12" multiple style="display: none">#}
-{#                    {% for asset in assets_all %}#}
-{#                        <option value="{{ asset.id }}">{{ asset.ip }}</option>#}
-{#                    {% endfor %}#}
-{#                </select>#}
-{##}
-{#                <select id="asset_select_total" name="j_hosts" class="form-control m-b" size="12"  multiple style="display: none">#}
-{#                    {% for asset in eposts %}#}
-{#                    <option value="{{ asset.id }}">{{ asset.ip }}</option>#}
-{#                    {% endfor %}#}
-{#                </select>#}
+                <select id="assets_total" name="assets" class="form-control m-b" size="12" multiple style="display: none">
+                    {% for asset in asset_all %}
+                        <option value="{{ asset.id }}">{{ asset.ip }}</option>
+                    {% endfor %}
+                </select>
 
                 <div class="ibox-content">
-                    {% if error %}
-                        <div class="alert alert-warning text-center">{{ error }}</div>
+                    {% if emg %}
+                        <div class="alert alert-warning text-center">{{ emg }}</div>
                     {% endif %}
-                    {% if msg %}
-                        <div class="alert alert-success text-center">{{ msg }}</div>
+                    {% 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"> 主机组名<span class="red-fonts">*</span></label>
-                            <div class="col-sm-8">
-                                <input type="text" placeholder="Name" name="name" class="form-control">
-                            </div>
+                        <div class="form-group"><label class="col-sm-2 control-label"> 主机组名<span class="red-fonts">*</span></label>
+                            <div class="col-sm-8" name="group_id" value="{{ post.id }}"><input type="text" value="{{ group.name }}" placeholder="Name" name="name" class="form-control"></div>
                         </div>
 
                         <div class="hr-line-dashed"></div>
@@ -83,7 +80,7 @@
                                 <div>
                                     <select id="assets" name="assets" class="form-control m-b" size="12" multiple>
                                         {% for asset in asset_all %}
-                                        <option value="{{ asset.id }}">{{ asset.ip }}</option>
+                                            <option value="{{ asset.id }}">{{ asset.ip }}</option>
                                         {% endfor %}
                                     </select>
                                 </div>
@@ -92,7 +89,7 @@
                             <div class="col-sm-1">
                                 <div class="btn-group" style="margin-top: 60px;">
                                     <button type="button" class="btn btn-white" onclick="move('assets', 'asset_select', 'assets_total', 'asset_select_total'  )"><i class="fa fa-chevron-right"></i></button>
-                                    <button type="button" class="btn btn-white" onclick="move('asset_select', 'assets', 'asset_select_total', 'assets_total')"><i class="fa fa-chevron-left"></i> </button>
+                                    <button type="button" class="btn btn-white" onclick="move_left('asset_select', 'assets', 'asset_select_total', 'assets_total')"><i class="fa fa-chevron-left"></i> </button>
                                 </div>
                             </div>
 
@@ -104,18 +101,15 @@
                         </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" placeholder="Comment" name="comment" class="form-control">
-                            </div>
+                        <div class="form-group"><label class="col-sm-2 control-label"> 备注 </label>
+                            <div class="col-sm-8"><input type="text" value="" placeholder="comment" name="comment" class="form-control"></div>
                         </div>
 
                         <div class="hr-line-dashed"></div>
                         <div class="form-group">
-                            <div class="col-sm-4 col-sm-offset-2">
-                                <button class="btn btn-white" type="reset"> 重置 </button>
-                                <button class="btn btn-primary" type="submit" onclick="on_submit('groups_selected')  "> 提交 </button>
+                            <div class="col-sm-4 col-sm-offset-5">
+                                <button class="btn btn-white" type="submit"> 重置 </button>
+                                <button class="btn btn-primary" id="submit_button" type="submit" onclick="on_submit('groups_selected')  "> 提交 </button>
                             </div>
                         </div>
                     </form>
@@ -159,16 +153,6 @@
             })
         }
 
-//    $('#search').keyup(function() {
-//        var $rows = $('#hosts option');
-//        var val = $.trim($(this).val()).replace(/ +/g, ' ').toLowerCase();
-//
-//        $rows.show().filter(function() {
-//            var text = $(this).text().replace(/\s+/g, ' ').toLowerCase();
-//            return !~text.indexOf(val);
-//        }).hide();
-//    });
-
     function change_dept(dept_id){
     $.get('/jasset/dept_host_ajax/',
             {'id': dept_id},
diff --git a/templates/jasset/group_detail.html b/templates/jasset/group_detail.html
index 0f31d3cf..e31a5d69 100644
--- a/templates/jasset/group_detail.html
+++ b/templates/jasset/group_detail.html
@@ -30,7 +30,7 @@
 
                 <div class="ibox-content">
                     <div class="">
-                        <a target="_blank" href="/jasset/host_add" class="btn btn-sm btn-primary"> 添加主机 </a>
+                        <a target="_blank" href="/jasset/asset_add" class="btn btn-sm btn-primary"> 添加主机 </a>
                         <b class="pull-right">提示: 此页面删除只从本主机组中剔除主机               </b>
                     </div>
 
@@ -41,9 +41,8 @@
                                 <th class="text-center"><input id="checkall" type="checkbox" class="i-checks" name="checkall" value="checkall" data-editable='false' onclick="check_all('contents_form')"></th>
                                 <th class="text-center" name="j_ip"> IP地址 </th>
                                 <th class="text-center"> 端口号 </th>
-                                <th class="text-center" name="j_type"> 登录方式 </th>
                                 <th class="text-center" name="j_idc"> 所属IDC </th>
-                                <th class="text-center" id="group_id" value="{{ group.id }}"> 所属业务组 </th>
+                                <th class="text-center" id="group_id" value="{{ group.id }}"> 所属主机组 </th>
                                 <th class="text-center"> 是否激活 </th>
                                 <th class="text-center" name="j_time"> 添加时间 </th>
                                 <th class="text-center" name="j_comment"> 备注 </th>
@@ -51,21 +50,20 @@
                             </tr>
                         </thead>
                         <tbody>
-                        {% for post in contacts.object_list %}
+                        {% for asset in contacts.object_list %}
                             <tr class="gradeX">
-                                <td class="text-center" name="j_id" value="{{ post.id }}" data-editable='false'><input name="id" value="{{ post.id }}" type="checkbox" class="i-checks"></td>
-                                <td class="text-center" name="j_ip"> {{ post.ip }} </td>
-                                <td class="text-center" name="j_port"> {{ post.port }} </td>
-                                <td class="text-center" name="j_type"> {{ post.login_type|get_login_type }} </td>
-                                <td class="text-center" name="j_idc"> {{ post.idc.name }} </td>
-                                <td class="text-center" name="j_group">{{ post.bis_group.all | group_str2 }}</td>
-                                <td class="text-center" name="j_active"> {{ post.is_active|bool2str }} </td>
-                                <td class="text-center"> {{ post.date_added|date:"Y-m-d H:i:s" }} </td>
-                                <td class="text-center" name="j_comment"> {{ post.comment }} </td>
+                                <td class="text-center" name="j_id" value="{{ asset.id }}" data-editable='false'><input name="id" value="{{ asset.id }}" type="checkbox" class="i-checks"></td>
+                                <td class="text-center" name="j_ip"> {{ asset.ip }} </td>
+                                <td class="text-center" name="j_port"> {{ asset.port }} </td>
+                                <td class="text-center" name="j_idc"> {{ asset.idc.name }} </td>
+                                <td class="text-center" name="j_group">{{ asset.bis_group.all | group_str2 }}</td>
+                                <td class="text-center" name="j_active"> {{ asset.is_active|bool2str }} </td>
+                                <td class="text-center"> {{ asset.date_added|date:"Y-m-d H:i:s" }} </td>
+                                <td class="text-center" name="j_comment"> {{ asset.comment }} </td>
                                 <td class="text-center" data-editable='false'>
-                                    <a href="/jasset/host_detail/?id={{ post.id }}" class="iframe btn btn-xs btn-primary">详情</a>
-                                    <a href="/jasset/host_edit/?id={{ post.id }}" class="btn btn-xs btn-info">编辑</a>
-                                    <a href="/jasset/group_del_host/?id={{ post.id }}&gid={{ group.id }}" class="btn btn-xs btn-danger">删除</a>
+                                    <a href="/jasset/host_detail/?id={{ asset.id }}" class="iframe btn btn-xs btn-primary">详情</a>
+                                    <a href="/jasset/host_edit/?id={{ asset.id }}" class="btn btn-xs btn-info">编辑</a>
+                                    <a href="/jasset/group_del_host/?id={{ asset.id }}&gid={{ group.id }}" class="btn btn-xs btn-danger">删除</a>
                                 </td>
                             </tr>
                         {% endfor %}
@@ -165,7 +163,7 @@
         selectData = GetTableDataBox();
         if (selectData[1] != 0) {
             $.ajax({
-                type: "post",
+                type: "asset",
                 url: "/jasset/host_edit/batch/",
                 data: {"editable": selectData[0], "len_table": selectData[1]},
                 success: function (data) {
diff --git a/templates/jasset/group_edit.html b/templates/jasset/group_edit.html
index 2f142a2e..e9054cca 100644
--- a/templates/jasset/group_edit.html
+++ b/templates/jasset/group_edit.html
@@ -43,13 +43,13 @@
                     </div>
 
                  <select id="assets_total" name="assets" class="form-control m-b" size="12" multiple style="display: none">
-                    {% for asset in posts %}
+                    {% for asset in asset_all %}
                         <option value="{{ asset.id }}">{{ asset.ip }}</option>
                     {% endfor %}
                 </select>
 
-                <select id="asset_select_total" name="j_hosts" class="form-control m-b" size="12"  multiple style="display: none">
-                    {% for asset in eposts %}
+                <select id="asset_select_total" name="asset_select" class="form-control m-b" size="12"  multiple style="display: none">
+                    {% for asset in asset_select %}
                     <option value="{{ asset.id }}">{{ asset.ip }}</option>
                     {% endfor %}
                 </select>
@@ -63,14 +63,7 @@
                     {% endif %}
                     <form id="assetForm" method="post" class="form-horizontal">
                         <div class="form-group"><label class="col-sm-2 control-label"> 主机组名<span class="red-fonts">*</span></label>
-                            <div class="col-sm-8" name="group_id" value="{{ post.id }}"><input type="text" value="{{ group.name }}" placeholder="网站" name="j_group" class="form-control"></div>
-                        </div>
-
-                        <div class="hr-line-dashed"></div>
-                        <div class="form-group">
-                            <label for="j_dept" class="col-lg-2 control-label">所属部门<span class="red-fonts" style="">*</span></label>
-                                <input type="text" name="j_dept" value="{{  group.dept.id }}" style="display: none">
-                                <div class="col-sm-8"><input type="text"  value="{{  group.dept.name }}" class="form-control" readonly="readonly"></div>
+                            <div class="col-sm-8" name="group_id" value="{{ group.id }}"><input type="text" value="{{ group.name }}" placeholder="Name" name="name" class="form-control"></div>
                         </div>
 
                        <div class="hr-line-dashed"></div>
@@ -92,8 +85,8 @@
                             <div class="col-sm-4">
                                 <div>
                                     <select id="assets" name="assets" class="form-control m-b" size="12" multiple>
-                                        {% for post in posts %}
-                                        <option value="{{ post.id }}">{{ post.ip }}</option>
+                                        {% for asset in asset_no_select %}
+                                        <option value="{{ asset.id }}">{{ asset.ip }}</option>
                                         {% endfor %}
                                     </select>
                                 </div>
@@ -108,9 +101,9 @@
 
                             <div class="col-sm-3">
                                 <div>
-                                    <select id="asset_select" name="j_hosts" class="form-control m-b" size="12"  multiple>
-                                        {% for asset in eposts %}
-                                        <option value="{{ asset.id }}">{{ asset.ip }}</option>
+                                    <select id="asset_select" name="asset_select" class="form-control m-b" size="12"  multiple>
+                                        {% for asset in asset_select %}
+                                            <option value="{{ asset.id }}">{{ asset.ip }}</option>
                                         {% endfor %}
                                     </select>
                                 </div>
@@ -119,7 +112,7 @@
 
                         <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="{{ group.comment }}" placeholder=包括web组所有主机 name="j_comment" class="form-control"></div>
+                            <div class="col-sm-8"><input type="text" value="{{ group.comment }}" name="comment" class="form-control"></div>
                         </div>
 
                         <div class="hr-line-dashed"></div>
diff --git a/templates/nav.html b/templates/nav.html
index 7eb758c3..ee268ee2 100644
--- a/templates/nav.html
+++ b/templates/nav.html
@@ -21,7 +21,7 @@
                     <li class="group_add"><a href="/jasset/group_add/">添加资产组</a></li>
                     <li class="group_list group_detail group_edit"><a href="/jasset/group_list/">查看资产组</a></li>
                     <li class="asset_add asset_add_multi"><a href="/jasset/asset_add/">添加资产</a></li>
-                    <li class="host_list host_detail host_edit"><a href="/jasset/asset_list/">查看资产<span class="label label-info pull-right">{{ host_active_num }}/{{ host_total_num}}</span></a></li>
+                    <li class="asset_list asset_detail asset_edit"><a href="/jasset/asset_list/">查看资产<span class="label label-info pull-right">{{ host_active_num }}/{{ host_total_num}}</span></a></li>
                 </ul>
             </li>
             <li id="jperm">
-- 
2.18.0