diff --git a/jasset/views.py b/jasset/views.py index c10eaddfe..5adb4721d 100644 --- a/jasset/views.py +++ b/jasset/views.py @@ -427,34 +427,46 @@ def idc_list(request): @require_super_user def idc_edit(request): header_title, path1, path2 = u'编辑IDC', u'资产管理', u'编辑IDC' - edit = 1 idc_id = request.GET.get('id') - j_idc = IDC.objects.get(id=idc_id) - default = IDC.objects.get(name='默认').asset_set.all() - eposts = contact_list = Asset.objects.filter(idc=j_idc).order_by('ip') - posts = [g for g in default if g not in eposts] + idc = IDC.objects.filter(id=idc_id) + if idc: + idc = idc[0] + default = IDC.objects.get(name='默认').asset_set.all() + eposts = Asset.objects.filter(idc=idc).order_by('ip') + posts = [g for g in default if g not in eposts] + else: + emg = '此IDC不存在' + if request.method == 'POST': - j_group = request.POST.get('j_idc') + idc_id = request.POST.get('id') + j_idc = request.POST.get('j_idc') j_hosts = request.POST.getlist('j_hosts') j_comment = request.POST.get('j_comment') idc_default = request.POST.getlist('idc_default') - for host in j_hosts: - g = Asset.objects.get(id=host) - Asset.objects.filter(id=host).update(idc=j_idc) + idc = IDC.objects.filter(id=idc_id) + if idc: + idc.update(name=j_idc, comment=j_comment) + for host in j_hosts: + g = Asset.objects.get(id=host) + Asset.objects.filter(id=host).update(idc=idc) - for host in idc_default: - g = Asset.objects.get(id=host) - i = IDC.objects.get(name='默认') - Asset.objects.filter(id=host).update(idc=i) + for host in idc_default: + g = Asset.objects.get(id=host) + i = IDC.objects.get(name='默认') + Asset.objects.filter(id=host).update(idc=i) + else: + emg = '此IDC不存在' + return render_to_response('jasset/idc_edit.html', locals(), context_instance=RequestContext(request)) - return HttpResponseRedirect('/jasset/idc_list/' % idc_id) + return HttpResponseRedirect('/jasset/idc_list/?id=%s' % idc_id) - return render_to_response('jasset/idc_add.html', locals(), context_instance=RequestContext(request)) + return render_to_response('jasset/idc_edit.html', locals(), context_instance=RequestContext(request)) @require_super_user -def idc_del(request, offset): +def idc_del(request): + offset = request.GET.get('id', '') if offset == 'multi': len_list = request.POST.get("len_list") for i in range(int(len_list)): diff --git a/templates/jasset/idc_add.html b/templates/jasset/idc_add.html index a02f9eb47..5c184e7e2 100644 --- a/templates/jasset/idc_add.html +++ b/templates/jasset/idc_add.html @@ -35,43 +35,14 @@ {% endif %}
-
+
-
+
- {% if edit %} -
-
- -
- -
-
-
- - -
-
-
-
- -
-
-
- {% endif %} -
diff --git a/templates/jasset/idc_edit.html b/templates/jasset/idc_edit.html new file mode 100644 index 000000000..0751a4114 --- /dev/null +++ b/templates/jasset/idc_edit.html @@ -0,0 +1,109 @@ +{% extends 'base.html' %} +{% block content %} +{% include 'nav_cat_bar.html' %} +
+
+
+
+
+
填写IDC基本信息
+ +
+ +
+ {% if emg %} +
{{ emg }}
+ {% endif %} + {% if smg %} +
{{ smg }}
+ {% endif %} + +
+
+ + +
+
+ +
+
+
+
+ +
+
+ +
+ +
+
+
+ + +
+
+
+
+ +
+
+
+ +
+
+
+ + +
+
+ +
+
+
+
+
+ + + +{% endblock %} \ No newline at end of file diff --git a/templates/jasset/idc_list.html b/templates/jasset/idc_list.html index 78a4c5fd3..0e0254ddf 100644 --- a/templates/jasset/idc_list.html +++ b/templates/jasset/idc_list.html @@ -55,7 +55,7 @@ 详情 {% ifequal session_role_id 2 %} 编辑 - 删除 + 删除 {% endifequal %} @@ -92,7 +92,7 @@ if (confirm("确定删除")) { $.ajax({ type: "POST", - url: "/jasset/idc_del/multi/", + url: "/jasset/idc_del/?id=multi", data: {"id_list": id_list, "len_list": j}, success: function (data) { window.open("/jasset/idc_list/", "_self");