last bug?

This commit is contained in:
halcyon
2015-04-19 18:36:41 +08:00
parent c8d91884c8
commit 86e334e4fa
15 changed files with 947 additions and 909 deletions

View File

@@ -9,6 +9,7 @@ urlpatterns = patterns('',
url(r'^search/$', host_search),
url(r"^host_detail/$", host_detail),
url(r"^dept_host_ajax/$", dept_host_ajax),
url(r"^show_all_ajax/$", show_all_ajax),
url(r'^idc_add/$', idc_add),
url(r'^idc_list/$', idc_list),
url(r'^idc_edit/$', idc_edit),

View File

@@ -105,15 +105,23 @@ def batch_host_edit(host_info, j_user='', j_password=''):
groups, depts = [], []
is_active = {u'': '1', u'': '2'}
login_types = {'LDAP': 'L', 'MAP': 'M'}
for group in j_group[0].split():
c = BisGroup.objects.get(name=group.strip())
groups.append(c)
for d in j_dept[0].split():
p = DEPT.objects.get(name=d.strip())
depts.append(p)
a = Asset.objects.get(id=j_id)
if '...' in j_group[0].split():
groups = a.bis_group.all()
else:
for group in j_group[0].split():
c = BisGroup.objects.get(name=group.strip())
groups.append(c)
if '...' in j_dept[0].split():
depts = a.dept.all()
else:
for d in j_dept[0].split():
p = DEPT.objects.get(name=d.strip())
depts.append(p)
j_type = login_types[j_type]
j_idc = IDC.objects.get(name=j_idc)
a = Asset.objects.get(id=j_id)
if j_type == 'M':
if a.password != j_password:
j_password = cryptor.decrypt(j_password)
@@ -140,7 +148,6 @@ def batch_host_edit(host_info, j_user='', j_password=''):
def db_host_delete(request, host_id):
""" 删除主机操作 """
print host_id
if is_group_admin(request) and not validate(request, asset=[host_id]):
return httperror(request, '删除失败, 您无权删除!')
@@ -197,7 +204,6 @@ def host_add(request):
host_info = [j_ip, j_port, j_idc, j_type, j_group, [j_dept], j_active, j_comment]
if is_group_admin(request) and not validate(request, asset_group=j_group, edept=[j_dept]):
print j_dept
return httperror(request, u'添加失败,您无权操作!')
if Asset.objects.filter(ip=str(j_ip)):
@@ -430,8 +436,7 @@ def host_del(request, offset):
host_id = request.POST.get(key)
db_host_delete(request, host_id)
else:
host_id = int(offset)
db_host_delete(request, host_id)
db_host_delete(request, offset)
return HttpResponseRedirect('/jasset/host_list/')
@@ -886,6 +891,16 @@ def dept_host_ajax(request):
return my_render('jasset/dept_host_ajax.html', locals(), request)
def show_all_ajax(request):
""" 批量修改主机时, 部门和组全部显示 """
env = request.GET.get('env', '')
get_id = request.GET.get('id', '')
host = Asset.objects.filter(id=get_id)
if host:
host = host[0]
return my_render('jasset/show_all_ajax.html', locals(), request)
@require_login
def host_search(request):
""" 搜索主机 """