首页 文章 精选 留言 我的

精选列表

搜索[基础搭建],共10000篇文章
优秀的个人博客,低调大师

Django 搭建CMDB系统完整[10](网络设备、安全设备、存储设备)

cmdb/urls.py from cmdbapp import machinaroomviews,serverviews,networkdeviceviews,securitydeviceviews,storagedeviceviews urlpatterns = [ url(r'^static/(?P<path>.*)',machinaroomviews.main_page,name='main_page'), url(r'^base',machinaroomviews.base,name='base'), url(r'^search_machinaroom.html',machinaroomviews.add_machinaroom,name='add_machinaroom'), url(r'^edit_machinaroom.html',machinaroomviews.edit_machinaroom,name='edit_machinaroom'), url(r'^del_machinaroom.html',machinaroomviews.del_machinaroom,name='del_machinaroom'), url(r'^batdel_machinaroom.html',machinaroomviews.batdel_machinaroom,name='batdel_machinaroom'), url(r'^excel_machinaroom.html',machinaroomviews.excel_machinaroom,name='excel_machinaroom'), url(r'^login/',serverviews.search_server,name='search_server'), url(r'^add_server.html',serverviews.edit_server,name="edit_server"), url(r'^del_server.html',serverviews.del_server,name='del_server'), url(r'^batdel_server.html',serverviews.batdel_server,name='batdel_server'), url(r'^excel_server.html',serverviews.excel_server,name='excel_server'), url(r'^search_networkdevice.html',networkdeviceviews.add_networkdevice,name="add_networkdevice"), url(r'^edit_networkdevice.html',securitydeviceviews.search_securitydevice,name='search_securitydevice'), url(r'^add_securitydevice.html',securitydeviceviews.edit_securitydevice,name="edit_securitydevice"), url(r'^del_securitydevice.html',securitydeviceviews.del_securitydevice,name='del_securitydevice'), url(r'^batdel_securitydevice.html',securitydeviceviews.batdel_securitydevice,name='batdel_securitydevice'), url(r'^excel_securitydevice.html',securitydeviceviews.excel_securitydevice,name='excel_securitydevice'), url(r'^search_storagedevice.html',storagedeviceviews.add_storagedevice,name="add_storagedevice"), url(r'^edit_storagedevice.html$',storagedeviceviews.edit_storagedevice,name="edit_storagedevice"), url(r'^del_storagedevice.html',storagedeviceviews.del_storagedevice,name='del_storagedevice'), url(r'^batdel_storagedevice.html',storagedeviceviews.batdel_storagedevice,name='batdel_storagedevice'), url(r'^excel_storagedevice.html',storagedeviceviews.excel_storagedevice,name='excel_storagedevice'), ] cmdbapp/networkdeviceviews.py securitydeviceviews.py storagedeviceviews.py -- coding: utf-8 -- from future import unicode_literals from django.shortcuts import render,render_to_response from django.core.paginator import Paginator,InvalidPage,EmptyPage from cmdbapp.models import * from django.http import HttpResponse from django.http import HttpResponseRedirect from xlwt import * import StringIO def search_networkdevice(request): error = False each_page = 8 mname=request.GET.get('mname','').strip() sname=request.GET.get('sname','').strip() ip=request.GET.get('ip','').strip() os=request.GET.get('os','').strip() status=int(request.GET.get('status',100)) if mname=='' and sname=='' and ip=='' and os=='' and status==100: record_list = Networkdevice.objects.all() paginator = Paginator(record_list,each_page) try: page = int(request.GET.get('page', '1')) except ValueError: page = 1 try: contacts = paginator.page(page) except (EmptyPage, InvalidPage): contacts = paginator.page(paginator.num_pages) return render_to_response('search_networkdevice.html',{'networkdevicelist':contacts,"mname":mname,"sname":sname,"ip":ip,"os":os,"status":status}) else: q={} if mname!='' and sname=='' and ip=='' and os=='' and status==100: a=Machinaroom.objects.filter(name__icontains=mname).values("id") q['machinaroom__in']=a if sname!='': q['hostname__icontains']=sname if ip!='': q['ip__icontains']=ip if os!='': q['model_icontains']=os if status!=100: q['status']=status record_list = Networkdevice.objects.filter(**q) paginator = Paginator(record_list,each_page) try: page = int(request.GET.get('page', '1')) except ValueError: page = 1 try: contacts = paginator.page(page) except (EmptyPage, InvalidPage): contacts = paginator.page(paginator.num_pages) return render_to_response('search_networkdevice.html',{'networkdevicelist':contacts,"mname":mname,"sname":sname,"ip":ip,"os":os,"status":status}) def add_networkdevice(request): if request.method=='GET': objs=Machinaroom.objects.all() return render_to_response("add_networkdevice.html",{"machinaroomlist":objs}) else: hostname=request.POST.get("networkdevicehostname","") model=request.POST.get("networkdevicemodel","") ip=request.POST.get("networkdeviceip","") memo=request.POST.get("networkdevicememo","") port_num=request.POST.get('networkdeviceport_num','') status=request.POST.get("networkdevicestatus",0) machinaroomid=request.POST.get("networkdevicemachinaroom") machinaroom=Machinaroom.objects.get(id=int(machinaroomid)) uu=Networkdevice(hostname=hostname,model=model,ip=ip,memo=memo,port_num=port_num,status=status,machinaroom=machinaroom) uu.save() return HttpResponseRedirect("add_networkdevice.html") def edit_networkdevice(request): if request.method=='GET': obj=Networkdevice.objects.get(id=int(request.GET.get('id'))) objs=Machinaroom.objects.all() return render_to_response('edit_networkdevice.html',{'networkdevice':obj,'machinaroomlist':objs}) else: id=request.POST.get("id") hostname=request.POST.get("networkdevicehostname","") model=request.POST.get("networkdevicemodel","") ip=request.POST.get("networkdeviceip","") memo=request.POST.get("networkdevicememo","") status=request.POST.get("networkdevicestatus",0) machinaroomid=request.POST.get("networkdevicemachinaroom") machinaroom=Machinaroom.objects.get(id=int(machinaroomid)) uu=Networkdevice.objects.filter(id=id).update(hostname=hostname,model=model,ip=ip,memo=memo,status=status,machinaroom=machinaroom) return HttpResponseRedirect("edit_networkdevice.html?id="+id) def del_networkdevice(request): id=request.GET.get('id') iid=int(id) Networkdevice.objects.filter(id=iid).delete() mname=request.GET.get('mname','').strip() sname=request.GET.get('sname','').strip() ip=request.GET.get('ip','').strip() os=request.GET.get('os','').strip() status=request.GET.get('status',100) page=request.GET.get('page','1') return HttpResponseRedirect('search_networkdevice.html?mname='+mname+"&&page="+page+"&&sname="+sname+"&&ip="+ip+"&&os="+os+"&&status="+status) def batdel_networkdevice(request): ids=request.GET.get('ids') b=ids.split(',') arr = map(int,b) for aaa in arr: Networkdevice.objects.filter(id=aaa).delete() mname=request.GET.get('mname') sname=request.GET.get('sname','').strip() ip=request.GET.get('ip','').strip() os=request.GET.get('os','').strip() status=request.GET.get('status',100) return HttpResponseRedirect('search_networkdevice.html?mname='+mname+"&&sname="+sname+"&&ip="+ip+"&&os="+os+"&&status="+status) def excel_networkdevice(request): mname=request.GET.get('mname','').strip() sname=request.GET.get('sname','').strip() ip=request.GET.get('ip','').strip() os=request.GET.get('os','').strip() status=int(request.GET.get('status',100)) if mname=='' and sname=='' and ip=='' and os=='' and status==100: list_obj = Networkdevice.objects.all() else: q={} if mname!='' and sname=='' and ip=='' and os=='' and status==100: a=Machinaroom.objects.filter(name__icontains=mname).values("id") q['machinaroom__in']=a if sname!='': q['hostname__icontains']=sname if ip!='': q['ip__icontains']=ip if os!='': q['model__icontains']=os if status!=100: q['status']=status list_obj = Networkdevice.objects.filter(**q) if list_obj: # 创建工作薄 ws = Workbook(encoding='utf-8') w = ws.add_sheet(u"网络设备清单") w.write(0, 0, "id") w.write(0, 1, u"设备名字") w.write(0, 2, u"制造商/型号") w.write(0, 3, u"IP") w.write(0, 4, u"端口数量") w.write(0,5,u"备注") w.write(0,6,u"状态") w.write(0,7,u"机房") # 写入数据 excel_row = 1 for obj in list_obj: data_id = obj.id data_hostname = obj.hostname data_model = obj.model data_ip = obj.ip data_port_num = obj.port_num data_memo=obj.memo if obj.status == 0: data_status='在线' elif obj.status == 1: data_status='已下线' elif obj.status == 2: data_status='未知' elif obj.status == 3: data_status='故障' else: data_status='备用' data_machinaroom=obj.machinaroom.name w.write(excel_row, 0, data_id) w.write(excel_row, 1, data_hostname) w.write(excel_row, 2, data_model) w.write(excel_row, 3, data_ip) w.write(excel_row, 4, data_port_num) w.write(excel_row, 5, data_memo) w.write(excel_row, 6, data_status) w.write(excel_row, 7, data_machinaroom) excel_row += 1 sio = StringIO.StringIO() ws.save(sio) sio.seek(0) response = HttpResponse(sio.getvalue(), content_type='application/vnd.ms-excel') response['Content-Disposition'] = 'attachment; filename=服务器清单-'+mname+sname+ip+os+'.xls' response.write(sio.getvalue()) return response -- coding: utf-8 -- from future import unicode_literals from django.shortcuts import render,render_to_response from django.core.paginator import Paginator,InvalidPage,EmptyPage from cmdbapp.models import * from django.http import HttpResponse from django.http import HttpResponseRedirect from xlwt import * import StringIO def search_securitydevice(request): error = False each_page = 8 mname=request.GET.get('mname','').strip() sname=request.GET.get('sname','').strip() ip=request.GET.get('ip','').strip() model=request.GET.get('model','').strip() type=request.GET.get('type','').strip() status=int(request.GET.get('status',100)) if mname=='' and sname=='' and ip=='' and model=='' and type=='' and status==100: record_list = Securitydevice.objects.all() paginator = Paginator(record_list,each_page) try: page = int(request.GET.get('page', '1')) except ValueError: page = 1 try: contacts = paginator.page(page) except (EmptyPage, InvalidPage): contacts = paginator.page(paginator.num_pages) return render_to_response('search_securitydevice.html',{'securitydevicelist':contacts,"mname":mname,"sname":sname,"ip":ip,"model":model,"type":type,"status":status}) else: q={} if mname!='' and sname=='' and ip=='' and model=='' and type=='' and status==100: a=Machinaroom.objects.filter(name__icontains=mname).values("id") q['machinaroom__in']=a if sname!='': q['hostname__icontains']=sname if ip!='': q['ip__icontains']=ip if model!='': q['model_icontains']=model if type!='': q['type_icontains']=type if status!=100: q['status']=status record_list = Securitydevice.objects.filter(**q) paginator = Paginator(record_list,each_page) try: page = int(request.GET.get('page', '1')) except ValueError: page = 1 try: contacts = paginator.page(page) except (EmptyPage, InvalidPage): contacts = paginator.page(paginator.num_pages) return render_to_response('search_securitydevice.html',{'securitydevicelist':contacts,"mname":mname,"sname":sname,"ip":ip,"model":model,"type":type,"status":status}) def add_securitydevice(request): if request.method=='GET': objs=Machinaroom.objects.all() return render_to_response("add_securitydevice.html",{"machinaroomlist":objs}) else: hostname=request.POST.get("securitydevicehostname","") model=request.POST.get("securitydevicemodel","") ip=request.POST.get("securitydeviceip","") memo=request.POST.get("securitydevicememo","") port_num=request.POST.get('securitydeviceport_num',0) status=request.POST.get("securitydevicestatus",0) machinaroomid=request.POST.get("securitydevicemachinaroom") machinaroom=Machinaroom.objects.get(id=int(machinaroomid)) type=request.POST.get("securitydevicetype","") uu=Securitydevice(hostname=hostname,model=model,ip=ip,type=type,memo=memo,port_num=port_num,status=status,machinaroom=machinaroom) uu.save() return HttpResponseRedirect("add_securitydevice.html") def edit_securitydevice(request): if request.method=='GET': obj=Securitydevice.objects.get(id=int(request.GET.get('id'))) objs=Machinaroom.objects.all() return render_to_response('edit_securitydevice.html',{'securitydevice':obj,'machinaroomlist':objs}) else: id=request.POST.get("id") hostname=request.POST.get("securitydevicehostname","") model=request.POST.get("securitydevicemodel","") ip=request.POST.get("securitydeviceip","") memo=request.POST.get("securitydevicememo","") status=request.POST.get("securitydevicestatus",0) port_num=request.POST.get("securitydeviceport_num",0) machinaroomid=request.POST.get("securitydevicemachinaroom") machinaroom=Machinaroom.objects.get(id=int(machinaroomid)) type=request.POST.get("securitydevicetype","") uu=Securitydevice.objects.filter(id=id).update(hostname=hostname,model=model,type=type,ip=ip,port_num=port_num,memo=memo,status=status,machinaroom=machinaroom) return HttpResponseRedirect("edit_securitydevice.html?id="+id) def del_securitydevice(request): id=request.GET.get('id') iid=int(id) Securitydevice.objects.filter(id=iid).delete() mname=request.GET.get('mname','').strip() sname=request.GET.get('sname','').strip() ip=request.GET.get('ip','').strip() model=request.GET.get('model','').strip() type=request.GET.get('type','').strip() status=request.GET.get('status',100) page=request.GET.get('page','1') return HttpResponseRedirect('search_securitydevice.html?mname='+mname+"&&page="+page+"&&sname="+sname+"&&ip="+ip+"&&model="+model+"&&type="+type+"&&status="+status) def batdel_securitydevice(request): ids=request.GET.get('ids') b=ids.split(',') arr = map(int,b) for aaa in arr: Securitydevice.objects.filter(id=aaa).delete() mname=request.GET.get('mname') sname=request.GET.get('sname','').strip() ip=request.GET.get('ip','').strip() model=request.GET.get('model','').strip() type=request.GET.get('type','').strip() status=request.GET.get('status',100) return HttpResponseRedirect('search_securitydevice.html?mname='+mname+"&&sname="+sname+"&&ip="+ip+"&&model="+model+"&&type="+type+"&&status="+status) def excel_securitydevice(request): mname=request.GET.get('mname','').strip() sname=request.GET.get('sname','').strip() ip=request.GET.get('ip','').strip() model=request.GET.get('model','').strip() type=request.GET.get('type','').strip() status=int(request.GET.get('status',100)) if mname=='' and sname=='' and ip=='' and model=='' and type=='' and status==100: list_obj = Securitydevice.objects.all() else: q={} if mname!='' and sname=='' and ip=='' and model=='' and type=='' and status==100: a=Machinaroom.objects.filter(name__icontains=mname).values("id") q['machinaroom__in']=a if sname!='': q['hostname__icontains']=sname if ip!='': q['ip__icontains']=ip if model!='': q['model__icontains']=model if type!='': q['type_icontains']=type if status!=100: q['status']=status list_obj = Securitydevice.objects.filter(**q) if list_obj: # 创建工作薄 ws = Workbook(encoding='utf-8') w = ws.add_sheet(u"网络设备清单") w.write(0, 0, "id") w.write(0, 1, u"设备名字") w.write(0, 2, u"制造商/型号") w.write(0, 3, u"IP") w.write(0, 4, u"端口数量") w.write(0,5,u"类型") w.write(0,6,u"备注") w.write(0,7,u"状态") w.write(0,8,u"机房") # 写入数据 excel_row = 1 for obj in list_obj: data_id = obj.id data_hostname = obj.hostname data_model = obj.model data_ip = obj.ip data_port_num = obj.port_num data_type=obj.type data_memo=obj.memo if obj.status == 0: data_status='在线' elif obj.status == 1: data_status='已下线' elif obj.status == 2: data_status='未知' elif obj.status == 3: data_status='故障' else: data_status='备用' data_machinaroom=obj.machinaroom.name w.write(excel_row, 0, data_id) w.write(excel_row, 1, data_hostname) w.write(excel_row, 2, data_model) w.write(excel_row, 3, data_ip) w.write(excel_row, 4, data_port_num) w.write(excel_row, 5, data_type) w.write(excel_row, 6, data_memo) w.write(excel_row, 7, data_status) w.write(excel_row, 8, data_machinaroom) excel_row += 1 sio = StringIO.StringIO() ws.save(sio) sio.seek(0) response = HttpResponse(sio.getvalue(), content_type='application/vnd.ms-excel') response['Content-Disposition'] = 'attachment; filename=服务器清单-'+mname+sname+ip+'.xls' response.write(sio.getvalue()) return response -- coding: utf-8 -- from future import unicode_literals from django.shortcuts import render,render_to_response from django.core.paginator import Paginator,InvalidPage,EmptyPage from cmdbapp.models import * from django.http import HttpResponse from django.http import HttpResponseRedirect from xlwt import * import StringIO def search_storagedevice(request): error = False each_page = 8 mname=request.GET.get('mname','').strip() sname=request.GET.get('sname','').strip() ip=request.GET.get('ip','').strip() model=request.GET.get('model','').strip() status=int(request.GET.get('status',100)) if mname=='' and sname=='' and ip=='' and model=='' and status==100: record_list = Storagedevice.objects.all() paginator = Paginator(record_list,each_page) try: page = int(request.GET.get('page', '1')) except ValueError: page = 1 try: contacts = paginator.page(page) except (EmptyPage, InvalidPage): contacts = paginator.page(paginator.num_pages) return render_to_response('search_storagedevice.html',{'storagedevicelist':contacts,"mname":mname,"sname":sname,"ip":ip,"model":model,"status":status}) else: q={} if mname!='' and sname=='' and ip=='' and model=='' and type=='' and status==100: a=Machinaroom.objects.filter(name__icontains=mname).values("id") q['machinaroom__in']=a if sname!='': q['hostname__icontains']=sname if ip!='': q['ip__icontains']=ip if model!='': q['model_icontains']=mode if status!=100: q['status']=status record_list = Storagedevice.objects.filter(**q) paginator = Paginator(record_list,each_page) try: page = int(request.GET.get('page', '1')) except ValueError: page = 1 try: contacts = paginator.page(page) except (EmptyPage, InvalidPage): contacts = paginator.page(paginator.num_pages) return render_to_response('search_storagedevice.html',{'storagedevicelist':contacts,"mname":mname,"sname":sname,"ip":ip,"model":model,"status":status}) def add_storagedevice(request): if request.method=='GET': objs=Machinaroom.objects.all() return render_to_response("add_storagedevice.html",{"machinaroomlist":objs}) else: hostname=request.POST.get("storagedevicehostname","") model=request.POST.get("storagedevicemodel","") ip=request.POST.get("storagedeviceip","") memo=request.POST.get("storagedevicememo","") disk=request.POST.get('storagedevicedisk','') status=request.POST.get("storagedevicestatus",0) machinaroomid=request.POST.get("storagedevicemachinaroom") machinaroom=Machinaroom.objects.get(id=int(machinaroomid)) uu=Storagedevice(hostname=hostname,model=model,ip=ip,memo=memo,disk=disk,status=status,machinaroom=machinaroom) uu.save() return HttpResponseRedirect("add_storagedevice.html") def edit_storagedevice(request): if request.method=='GET': obj=Storagedevice.objects.get(id=int(request.GET.get('id'))) objs=Machinaroom.objects.all() return render_to_response('edit_storagedevice.html',{'storagedevice':obj,'machinaroomlist':objs}) else: id=request.POST.get("id") hostname=request.POST.get("storagedevicehostname","") model=request.POST.get("storagedevicemodel","") ip=request.POST.get("storagedeviceip","") memo=request.POST.get("storagedevicememo","") status=request.POST.get("storagedevicestatus",0) machinaroomid=request.POST.get("storagedevicemachinaroom") machinaroom=Machinaroom.objects.get(id=int(machinaroomid)) disk=request.POST.get("storagedevicedisk","") uu=Storagedevice.objects.filter(id=id).update(hostname=hostname,model=model,disk=disk,ip=ip,memo=memo,status=status,machinaroom=machinaroom) return HttpResponseRedirect("edit_storagedevice.html?id="+id) def del_storagedevice(request): id=request.GET.get('id') iid=int(id) Storagedevice.objects.filter(id=iid).delete() mname=request.GET.get('mname','').strip() sname=request.GET.get('sname','').strip() ip=request.GET.get('ip','').strip() model=request.GET.get('model','').strip() status=request.GET.get('status',100) page=request.GET.get('page','1') return HttpResponseRedirect('search_storagedevice.html?mname='+mname+"&&page="+page+"&&sname="+sname+"&&ip="+ip+"&&model="+model+"&&status="+status) def batdel_storagedevice(request): ids=request.GET.get('ids') b=ids.split(',') arr = map(int,b) for aaa in arr: Storagedevice.objects.filter(id=aaa).delete() mname=request.GET.get('mname') sname=request.GET.get('sname','').strip() ip=request.GET.get('ip','').strip() model=request.GET.get('model','').strip() status=request.GET.get('status',100) return HttpResponseRedirect('search_storagedevice.html?mname='+mname+"&&sname="+sname+"&&ip="+ip+"&&model="+model+"&&status="+status) def excel_storagedevice(request): mname=request.GET.get('mname','').strip() sname=request.GET.get('sname','').strip() ip=request.GET.get('ip','').strip() model=request.GET.get('model','').strip() status=int(request.GET.get('status',100)) if mname=='' and sname=='' and ip=='' and model=='' and status==100: list_obj = Storagedevice.objects.all() else: q={} if mname!='' and sname=='' and ip=='' and model=='' and status==100: a=Machinaroom.objects.filter(name__icontains=mname).values("id") q['machinaroom__in']=a if sname!='': q['hostname__icontains']=sname if ip!='': q['ip__icontains']=ip if model!='': q['model__icontains']=model if status!=100: q['status']=status list_obj = Storagedevice.objects.filter(**q) if list_obj: # 创建工作薄 ws = Workbook(encoding='utf-8') w = ws.add_sheet(u"网络设备清单") w.write(0, 0, "id") w.write(0, 1, u"设备名字") w.write(0, 2, u"制造商/型号") w.write(0, 3, u"IP") w.write(0, 4, u"容量信息") w.write(0,5,u"备注") w.write(0,6,u"状态") w.write(0,7,u"机房") # 写入数据 excel_row = 1 for obj in list_obj: data_id = obj.id data_hostname = obj.hostname data_model = obj.model data_ip = obj.ip data_disk = obj.disk data_memo=obj.memo if obj.status == 0: data_status='在线' elif obj.status == 1: data_status='已下线' elif obj.status == 2: data_status='未知' elif obj.status == 3: data_status='故障' else: data_status='备用' data_machinaroom=obj.machinaroom.name w.write(excel_row, 0, data_id) w.write(excel_row, 1, data_hostname) w.write(excel_row, 2, data_model) w.write(excel_row, 3, data_ip) w.write(excel_row, 4, data_disk) w.write(excel_row, 5, data_memo) w.write(excel_row, 6, data_status) w.write(excel_row, 7, data_machinaroom) excel_row += 1 sio = StringIO.StringIO() ws.save(sio) sio.seek(0) response = HttpResponse(sio.getvalue(), content_type='application/vnd.ms-excel') response['Content-Disposition'] = 'attachment; filename=服务器清单-'+mname+sname+ip+'.xls' response.write(sio.getvalue()) return response 修改 models.py -- coding: utf-8 -- from future import unicode_literals from django.db import models class Machinaroom(models.Model): id=models.AutoField(primary_key=True) name=models.CharField(max_length=200,default=u'机房') location=models.CharField(max_length=200,default=u'厦门') vpnurl=models.URLField(default="") memo = models.CharField(u'备注', max_length=200,default="") def unicode(self): return self.name class Server(models.Model): """ 服务器信息 """ machinaroom= models.ForeignKey(Machinaroom) hostname = models.CharField(max_length=128, unique=True) model = models.CharField('制造商/型号', max_length=128, default="") ip = models.CharField('IP', max_length=128, default="") os = models.CharField('操作系统', max_length=128, default="") cpu = models.CharField('CPU', max_length=128, default="") memory=models.CharField('memory', max_length=128, default="") disk=models.CharField('硬盘信息',max_length=200, default="") status_choices = ((0, '在线'), (1, '已下线'), (2, '未知'), (3, '故障'), (4, '备用'), ) status = models.SmallIntegerField(choices=status_choices, default=0) memo = models.CharField(u'备注', max_length=200,default="") id =models.AutoField(primary_key=True) class Meta: verbose_name_plural = "服务器表" def __str__(self): return self.hostname class Networkdevice(models.Model): status_choices = ((0, '在线'), (1, '已下线'), (2, '未知'), (3, '故障'), (4, '备用'), ) status = models.SmallIntegerField(choices=status_choices, default=0) id =models.AutoField(primary_key=True) machinaroom= models.ForeignKey(Machinaroom) hostname = models.CharField(max_length=128, unique=True) port_num = models.SmallIntegerField(u'端口个数', default=0) model = models.CharField(u'型号', max_length=128, default="") ip = models.CharField(max_length=128, default="") memo = models.CharField(u'备注', max_length=200,default="") class Meta: verbose_name = '网络设备' verbose_name_plural = "网络设备" def __str__(self): return self.hostname class Securitydevice(models.Model): status_choices = ((0, '在线'), (1, '已下线'), (2, '未知'), (3, '故障'), (4, '备用'), ) status = models.SmallIntegerField(choices=status_choices, default=0) id =models.AutoField(primary_key=True) machinaroom= models.ForeignKey(Machinaroom) type=models.CharField(u'类型', max_length=128, default="") hostname = models.CharField(max_length=128, unique=True) port_num = models.SmallIntegerField(u'端口个数', default=0) model = models.CharField(u'型号', max_length=128, default="") memo = models.CharField(u'备注', max_length=200,default="") ip = models.CharField(max_length=128, default="") class Meta: verbose_name = '安全设备' verbose_name_plural = "安全设备" def __str__(self): return self.hostname class Storagedevice(models.Model): """存储设备""" machinaroom= models.ForeignKey(Machinaroom) model = models.CharField(u'型号', max_length=128, default="") id =models.AutoField(primary_key=True) hostname = models.CharField(max_length=128, unique=True,default="") ip = models.CharField(max_length=128, default="") status_choices = ((0, '在线'), (1, '已下线'), (2, '未知'), (3, '故障'), (4, '备用'), ) status = models.SmallIntegerField(choices=status_choices, default=0) disk=models.CharField('容量信息',max_length=200, default="") memo = models.TextField(u'备注', default="") class Meta: verbose_name = '存储设备' verbose_name_plural = "存储设备" def __str__(self): return self.model class Software(models.Model): sub_assset_type_choices = ( (0, 'OS'), (1, '办公\开发软件'), (2, '业务软件'), ) sub_asset_type = models.SmallIntegerField(choices=sub_assset_type_choices, verbose_name="服务器类型", default=0) license_num = models.IntegerField(verbose_name="授权数",default=0) version = models.CharField(u'软件/系统版本', max_length=64, help_text=u'eg. CentOS release 6.5 (Final)', unique=True) id =models.AutoField(primary_key=True) def __str__(self): return self.version class Meta: verbose_name = '软件/系统' verbose_name_plural = "软件/系统" class Manufactory(models.Model): """厂商""" id =models.AutoField(primary_key=True) manufactory = models.CharField(u'厂商名称', max_length=64, unique=True) support_num = models.CharField(u'支持电话', max_length=30, default="") memo = models.CharField(u'备注', max_length=128, default="") def __str__(self): return self.manufactory class Meta: verbose_name = '厂商' verbose_name_plural = "厂商" templates/add_networkdevice.html add_securitydevice.html add_storagedevice.html edit_networkdevice.html edit_securitydevice.html edit_storagedevice.html search_networkdevice.html search_securitydevice.html search_storagedevice.html <!DOCTYPE html> <html> <head> <title>CMDB</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script type="text/javascript" src="/static/scripts/jquery/jquery-1.7.1.js"></script> <link href="/static/style/authority/basic_layout.css" rel="stylesheet" type="text/css"> <link href="/static/style/authority/common_style.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="/static/scripts/authority/commonAll.js"></script> <script type="text/javascript" src="/static/scripts/jquery/jquery-1.4.4.min.js"></script> <script src="/static/scripts/My97DatePicker/WdatePicker.js" type="text/javascript" defer="defer"></script> <script type="text/javascript" src="/static/scripts/artDialog/artDialog.js?skin=default"></script> </head> <body> <form id="addnetworkdeviceform" name="addnetworkdeviceform" action="add_networkdevice.html" method="post"> <div id="container"> <div id="nav_links"> 当前位置:服务器资产管理><span style="color: #1A5CC6;">新增网络设备</span> <div id="page_close"> <a href="javascript:parent.$.fancybox.close();"> <img src="/static/images/common/page_close.png" width="20" height="20" style="vertical-align: text-top;"/> </a> </div> </div> <div class="ui_content"> <table cellspacing="0" cellpadding="0" width="100%" align="left" border="0"> <tr> <td class="ui_text_rt">设备名字</td> <td class="ui_text_lt"> <input type="text" id="networkdevicehostname" name="networkdevicehostname" value="" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">制造商/型号</td> <td class="ui_text_lt"> <input type="text" id="networkdevicemodel" name="networkdevicemodel" value="" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">IP</td> <td class="ui_text_lt"> <input type="text" id="networkdeviceip" name="networkdeviceip" value="" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">端口数量</td> <td class="ui_text_lt"> <input type="text" id="networkdeviceport_num" name="networkdeviceport_num" value="" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">备注</td> <td class="ui_text_lt"> <input type="text" id="networkdevicememo" name="networkdevicememo" value="" class="ui_input_txt02" /> </td> </tr> <tr> </tr> <tr> <td class="ui_text_rt">状态</td> <td class="ui_text_lt"> <select name="networkdevicestatus" id="networkdevicestatus" class="ui_select01" > <option value=0>在线</option> <option value=1>已下线</option> <option value=2>未知</option> <option value=3>故障</option> <option value=4>备用</option> </select> </td> </tr> <tr> <td class="ui_text_rt">所属机房</td> <td class="ui_text_lt"> <select name="networkdevicemachinaroom" id="networkdevicemachinaroom" class="ui_select01"> {% for mr in machinaroomlist %} <option value={{ mr.id }}>{{ mr.name }}</option> {% endfor %} </select> </td> </tr> <tr> <td></td> <td class="ui_text_lt"> <input id="submitbutton" type="submit" value="提交" class="ui_input_btn01"/> <input id="cancelbutton" type="cancel" value="取消" class="ui_input_btn01"/> </td> </tr> </table> </div> </div> </form> </body> </html> <!DOCTYPE html> <html> <head> <title>CMDB</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script type="text/javascript" src="/static/scripts/jquery/jquery-1.7.1.js"></script> <link href="/static/style/authority/basic_layout.css" rel="stylesheet" type="text/css"> <link href="/static/style/authority/common_style.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="/static/scripts/authority/commonAll.js"></script> <script type="text/javascript" src="/static/scripts/jquery/jquery-1.4.4.min.js"></script> <script src="/static/scripts/My97DatePicker/WdatePicker.js" type="text/javascript" defer="defer"></script> <script type="text/javascript" src="/static/scripts/artDialog/artDialog.js?skin=default"></script> </head> <body> <form id="addsecuritydeviceform" name="addsecuritydeviceform" action="add_securitydevice.html" method="post"> <div id="container"> <div id="nav_links"> 当前位置:服务器资产管理><span style="color: #1A5CC6;">新增安全设备</span> <div id="page_close"> <a href="javascript:parent.$.fancybox.close();"> <img src="/static/images/common/page_close.png" width="20" height="20" style="vertical-align: text-top;"/> </a> </div> </div> <div class="ui_content"> <table cellspacing="0" cellpadding="0" width="100%" align="left" border="0"> <tr> <td class="ui_text_rt">设备名字</td> <td class="ui_text_lt"> <input type="text" id="securitydevicehostname" name="securitydevicehostname" value="" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">制造商/型号</td> <td class="ui_text_lt"> <input type="text" id="securitydevicemodel" name="securitydevicemodel" value="" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">IP</td> <td class="ui_text_lt"> <input type="text" id="securitydeviceip" name="securitydeviceip" value="" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">端口数量</td> <td class="ui_text_lt"> <input type="text" id="securitydeviceport_num" name="securitydeviceport_num" value="" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">类型</td> <td class="ui_text_lt"> <input type="text" id="securitydevicetype" name="securitydevicetype" value="" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">备注</td> <td class="ui_text_lt"> <input type="text" id="securitydevicememo" name="securitydevicememo" value="" class="ui_input_txt02" /> </td> </tr> <tr> </tr> <tr> <td class="ui_text_rt">状态</td> <td class="ui_text_lt"> <select name="securitydevicestatus" id="securitydevicestatus" class="ui_select01" > <option value=0>在线</option> <option value=1>已下线</option> <option value=2>未知</option> <option value=3>故障</option> <option value=4>备用</option> </select> </td> </tr> <tr> <td class="ui_text_rt">所属机房</td> <td class="ui_text_lt"> <select name="securitydevicemachinaroom" id="securitydevicemachinaroom" class="ui_select01"> {% for mr in machinaroomlist %} <option value={{ mr.id }}>{{ mr.name }}</option> {% endfor %} </select> </td> </tr> <tr> <td></td> <td class="ui_text_lt"> <input id="submitbutton" type="submit" value="提交" class="ui_input_btn01"/> <input id="cancelbutton" type="cancel" value="取消" class="ui_input_btn01"/> </td> </tr> </table> </div> </div> </form> </body> </html> <!DOCTYPE html> <html> <head> <title>CMDB</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script type="text/javascript" src="/static/scripts/jquery/jquery-1.7.1.js"></script> <link href="/static/style/authority/basic_layout.css" rel="stylesheet" type="text/css"> <link href="/static/style/authority/common_style.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="/static/scripts/authority/commonAll.js"></script> <script type="text/javascript" src="/static/scripts/jquery/jquery-1.4.4.min.js"></script> <script src="/static/scripts/My97DatePicker/WdatePicker.js" type="text/javascript" defer="defer"></script> <script type="text/javascript" src="/static/scripts/artDialog/artDialog.js?skin=default"></script> </head> <body> <form id="addstoragedeviceform" name="addstoragedeviceform" action="add_storagedevice.html" method="post"> <div id="container"> <div id="nav_links"> 当前位置:服务器资产管理><span style="color: #1A5CC6;">新增存储设备</span> <div id="page_close"> <a href="javascript:parent.$.fancybox.close();"> <img src="/static/images/common/page_close.png" width="20" height="20" style="vertical-align: text-top;"/> </a> </div> </div> <div class="ui_content"> <table cellspacing="0" cellpadding="0" width="100%" align="left" border="0"> <tr> <td class="ui_text_rt">设备名字</td> <td class="ui_text_lt"> <input type="text" id="storagedevicehostname" name="storagedevicehostname" value="" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">制造商/型号</td> <td class="ui_text_lt"> <input type="text" id="storagedevicemodel" name="storagedevicemodel" value="" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">IP</td> <td class="ui_text_lt"> <input type="text" id="storagedeviceip" name="storagedeviceip" value="" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">容量信息</td> <td class="ui_text_lt"> <input type="text" id="storagedevicedisk" name="storagedevicedisk" value="" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">备注</td> <td class="ui_text_lt"> <input type="text" id="storagedevicememo" name="storagedevicememo" value="" class="ui_input_txt02" /> </td> </tr> <tr> </tr> <tr> <td class="ui_text_rt">状态</td> <td class="ui_text_lt"> <select name="storagedevicestatus" id="storagedevicestatus" class="ui_select01" > <option value=0>在线</option> <option value=1>已下线</option> <option value=2>未知</option> <option value=3>故障</option> <option value=4>备用</option> </select> </td> </tr> <tr> <td class="ui_text_rt">所属机房</td> <td class="ui_text_lt"> <select name="storagedevicemachinaroom" id="storagedevicemachinaroom" class="ui_select01"> {% for mr in machinaroomlist %} <option value={{ mr.id }}>{{ mr.name }}</option> {% endfor %} </select> </td> </tr> <tr> <td></td> <td class="ui_text_lt"> <input id="submitbutton" type="submit" value="提交" class="ui_input_btn01"/> <input id="cancelbutton" type="cancel" value="取消" class="ui_input_btn01"/> </td> </tr> </table> </div> </div> </form> </body> </html> <!DOCTYPE html> <html> <head> <title>CMDB</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script type="text/javascript" src="/static/scripts/jquery/jquery-1.7.1.js"></script> <link href="/static/style/authority/basic_layout.css" rel="stylesheet" type="text/css"> <link href="/static/style/authority/common_style.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="/static/scripts/authority/commonAll.js"></script> <script type="text/javascript" src="/static/scripts/jquery/jquery-1.4.4.min.js"></script> <script src="/static/scripts/My97DatePicker/WdatePicker.js" type="text/javascript" defer="defer"></script> <script type="text/javascript" src="/static/scripts/artDialog/artDialog.js?skin=default"></script> </head> <body> <form id="editnetworkdeviceform" name="editnetworkdeviceform" action="edit_networkdevice.html" method="post"> <div id="container"> <div id="nav_links"> 当前位置:服务器资产管理><span style="color: #1A5CC6;">编辑网络设备</span> <div id="page_close"> <a href="javascript:parent.$.fancybox.close();"> <img src="/static/images/common/page_close.png" width="20" height="20" style="vertical-align: text-top;"/> </a> </div> </div> <div class="ui_content"><input style="visibility:hidden" value={{ networkdevice.id }} type="text" name="id" id="id" /> <table cellspacing="0" cellpadding="0" width="100%" align="left" border="0"> <tr> <td class="ui_text_rt">设备名字</td> <td class="ui_text_lt"> <input type="text" id="networkdevicehostname" name="networkdevicehostname" value="{{ networkdevice.hostname }}" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">制造商/型号</td> <td class="ui_text_lt"> <input type="text" id="networkdevicemodel" name="networkdevicemodel" value="{{ networkdevice.model }}" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">IP</td> <td class="ui_text_lt"> <input type="text" id="networkdeviceip" name="networkdeviceip" value="{{ networkdevice.ip }}" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">端口数量</td> <td class="ui_text_lt"> <input type="text" id="networkdeviceport_num" name="networkdeviceport_num" value="{{ networkdevice.port_num }}" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">备注</td> <td class="ui_text_lt"> <input type="text" id="networkdevicememo" name="networkdevicememo" value="{{ networkdevice.memo }}" class="ui_input_txt02" /> </td> </tr> <tr> </tr> <tr> <td class="ui_text_rt">状态</td> <td class="ui_text_lt"> <select name="networkdevicestatus" id="networkdevicestatus" class="ui_select01" > <option value=0>在线</option> <option value=1>已下线</option> <option value=2>未知</option> <option value=3>故障</option> <option value=4>备用</option> </select> </td> </tr> <tr> <td class="ui_text_rt">所属机房</td> <td class="ui_text_lt"> <select name="networkdevicemachinaroom" id="networkdevicemachinaroom" class="ui_select01"> {% for mr in machinaroomlist %} <option value={{ mr.id }}>{{ mr.name }}</option> {% endfor %} </select> </td> </tr> <tr> <td>&nbsp;</td> <td class="ui_text_lt"> &nbsp;<input id="submitbutton" type="submit" value="提交" class="ui_input_btn01"/> &nbsp;<input id="cancelbutton" type="cancel" value="取消" class="ui_input_btn01"/> </td> </tr> </table> </div> </div> </form> </body> </html> <!DOCTYPE html> <html> <head> <title>CMDB</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script type="text/javascript" src="/static/scripts/jquery/jquery-1.7.1.js"></script> <link href="/static/style/authority/basic_layout.css" rel="stylesheet" type="text/css"> <link href="/static/style/authority/common_style.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="/static/scripts/authority/commonAll.js"></script> <script type="text/javascript" src="/static/scripts/jquery/jquery-1.4.4.min.js"></script> <script src="/static/scripts/My97DatePicker/WdatePicker.js" type="text/javascript" defer="defer"></script> <script type="text/javascript" src="/static/scripts/artDialog/artDialog.js?skin=default"></script> </head> <body> <form id="editsecuritydeviceform" name="editsecuritydeviceform" action="edit_securitydevice.html" method="post"> <div id="container"> <div id="nav_links"> 当前位置:服务器资产管理><span style="color: #1A5CC6;">编辑安全设备</span> <div id="page_close"> <a href="javascript:parent.$.fancybox.close();"> <img src="/static/images/common/page_close.png" width="20" height="20" style="vertical-align: text-top;"/> </a> </div> </div> <div class="ui_content"><input style="visibility:hidden" value={{ securitydevice.id }} type="text" name="id" id="id" /> <table cellspacing="0" cellpadding="0" width="100%" align="left" border="0"> <tr> <td class="ui_text_rt">设备名字</td> <td class="ui_text_lt"> <input type="text" id="securitydevicehostname" name="securitydevicehostname" value="{{ securitydevice.hostname }}" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">制造商/型号</td> <td class="ui_text_lt"> <input type="text" id="securitydevicemodel" name="securitydevicemodel" value="{{ securitydevice.model }}" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">IP</td> <td class="ui_text_lt"> <input type="text" id="securitydeviceip" name="securitydeviceip" value="{{ securitydevice.ip }}" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">端口数量</td> <td class="ui_text_lt"> <input type="text" id="securitydeviceport_num" name="securitydeviceport_num" value="{{ securitydevice.port_num }}" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">类型</td> <td class="ui_text_lt"> <input type="text" id="securitydevicetype" name="securitydevicetype" value="{{ securitydevice.type }}" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">备注</td> <td class="ui_text_lt"> <input type="text" id="securitydevicememo" name="securitydevicememo" value="{{ securitydevice.memo }}" class="ui_input_txt02" /> </td> </tr> <tr> </tr> <tr> <td class="ui_text_rt">状态</td> <td class="ui_text_lt"> <select name="securitydevicestatus" id="securitydevicestatus" class="ui_select01" > <option value=0>在线</option> <option value=1>已下线</option> <option value=2>未知</option> <option value=3>故障</option> <option value=4>备用</option> </select> </td> </tr> <tr> <td class="ui_text_rt">所属机房</td> <td class="ui_text_lt"> <select name="securitydevicemachinaroom" id="securitydevicemachinaroom" class="ui_select01"> {% for mr in machinaroomlist %} <option value={{ mr.id }}>{{ mr.name }}</option> {% endfor %} </select> </td> </tr> <tr> <td>&nbsp;</td> <td class="ui_text_lt"> &nbsp;<input id="submitbutton" type="submit" value="提交" class="ui_input_btn01"/> &nbsp;<input id="cancelbutton" type="cancel" value="取消" class="ui_input_btn01"/> </td> </tr> </table> </div> </div> </form> </body> </html> <!DOCTYPE html> <html> <head> <title>CMDB</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script type="text/javascript" src="/static/scripts/jquery/jquery-1.7.1.js"></script> <link href="/static/style/authority/basic_layout.css" rel="stylesheet" type="text/css"> <link href="/static/style/authority/common_style.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="/static/scripts/authority/commonAll.js"></script> <script type="text/javascript" src="/static/scripts/jquery/jquery-1.4.4.min.js"></script> <script src="/static/scripts/My97DatePicker/WdatePicker.js" type="text/javascript" defer="defer"></script> <script type="text/javascript" src="/static/scripts/artDialog/artDialog.js?skin=default"></script> </head> <body> <form id="editstoragedeviceform" name="editstoragedeviceform" action="edit_storagedevice.html" method="post"> <div id="container"> <div id="nav_links"> 当前位置:服务器资产管理><span style="color: #1A5CC6;">编辑存储设备</span> <div id="page_close"> <a href="javascript:parent.$.fancybox.close();"> <img src="/static/images/common/page_close.png" width="20" height="20" style="vertical-align: text-top;"/> </a> </div> </div> <div class="ui_content"><input style="visibility:hidden" value={{ storagedevice.id }} type="text" name="id" id="id" /> <table cellspacing="0" cellpadding="0" width="100%" align="left" border="0"> <tr> <td class="ui_text_rt">设备名字</td> <td class="ui_text_lt"> <input type="text" id="storagedevicehostname" name="storagedevicehostname" value="{{ storagedevice.hostname }}" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">制造商/型号</td> <td class="ui_text_lt"> <input type="text" id="storagedevicemodel" name="storagedevicemodel" value="{{ storagedevice.model }}" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">IP</td> <td class="ui_text_lt"> <input type="text" id="storagedeviceip" name="storagedeviceip" value="{{ storagedevice.ip }}" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">硬盘信息</td> <td class="ui_text_lt"> <input type="text" id="storagedevicedisk" name="storagedevicedisk" value="{{ storagedevice.disk }}" class="ui_input_txt02" /> </td> </tr> <tr> <td class="ui_text_rt">备注</td> <td class="ui_text_lt"> <input type="text" id="storagedevicememo" name="storagedevicememo" value="{{ storagedevice.memo }}" class="ui_input_txt02" /> </td> </tr> <tr> </tr> <tr> <td class="ui_text_rt">状态</td> <td class="ui_text_lt"> <select name="storagedevicestatus" id="storagedevicestatus" class="ui_select01" > <option value=0>在线</option> <option value=1>已下线</option> <option value=2>未知</option> <option value=3>故障</option> <option value=4>备用</option> </select> </td> </tr> <tr> <td class="ui_text_rt">所属机房</td> <td class="ui_text_lt"> <select name="storagedevicemachinaroom" id="storagedevicemachinaroom" class="ui_select01"> {% for mr in machinaroomlist %} <option value={{ mr.id }}>{{ mr.name }}</option> {% endfor %} </select> </td> </tr> <tr> <td>&nbsp;</td> <td class="ui_text_lt"> &nbsp;<input id="submitbutton" type="submit" value="提交" class="ui_input_btn01"/> &nbsp;<input id="cancelbutton" type="cancel" value="取消" class="ui_input_btn01"/> </td> </tr> </table> </div> </div> </form> </body> </html> {% extends 'base.html' %} {% block title %} <script type="text/javascript" src="/static/scripts/jquery/jquery-1.7.1.js"></script> <link href="/static/style/authority/basic_layout.css" rel="stylesheet" type="text/css"> <link href="/static/style/authority/common_style.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="/static/scripts/authority/commonAll.js"></script> <script type="text/javascript" src="/static/scripts/fancybox/jquery.fancybox-1.3.4.js"></script> <script type="text/javascript" src="/static/scripts/fancybox/jquery.fancybox-1.3.4.pack.js"></script> <link rel="stylesheet" type="text/css" href="/static/style/authority/jquery.fancybox-1.3.4.css" media="screen"></link> <script type="text/javascript" src="/static/scripts/artDialog/artDialog.js?skin=default"></script> <div id="container"> <div class="ui_content"> <div class="ui_text_indent"> <div id="box_border"> <div id="box_top">搜索</div> 机房名字<input type="text" id="mname" name="mname" value="{{ mname }}" class="ui_input_txt03" /> 设备名字<input type="text" id="sname" name="sname" value="{{ sname }}" class="ui_input_txt03" /> ip地址<input type="text" id="ip" name="ip" value="{{ ip }}" class="ui_input_txt03" /> 制造商/型号<input type="text" id="os" name="ip" value="{{ os }}" class="ui_input_txt03" /> 状态 <select id="status" name="status" class="ui_select02"> <option value=100 selected = "selected">所有</option> <option value=0 {% if status == 0 %} selected = "selected" {% endif %}>在线</option> <option value=1 {% if status == 1 %} selected = "selected" {% endif %}>已下线</option> <option value=2 {% if status == 2 %} selected = "selected" {% endif %}>未知</option> <option value=3 {% if status == 3 %} selected = "selected" {% endif %}>故障</option> <option value=4 {% if status == 4 %} selected = "selected" {% endif %}>备用</option> </select> </div> <div id="box_bottom"> <div class="pagination"> <span class="current"> {% if networkdevicelist.has_previous %} <a href="javascript:void(0)" onclick="search_networkdevice({{ networkdevicelist.previous_page_number }});">上一页</a> {% endif %} <span class="current"> Page {{ networkdevicelist.number }} of {{ networkdevicelist.paginator.num_pages }}. </span> {% if networkdevicelist.has_next %} <a href="javascript:void(0)" onclick="search_networkdevice({{ networkdevicelist.next_page_number }});">下一页</a> {% endif %} </span> </div> <input type="button" value="查询" class="ui_input_btn01" onclick="search_networkdevice(1);"/> <input type="button" value="新增" class="ui_input_btn01" onclick="add_networkdevice();" /> <input type="button" value="删除" class="ui_input_btn01" onclick="batdel_networkdevice();" /> <input type="button" value="导出EXCEL" class="ui_input_btn01" onclick="excel_networkdevice();" /> </div> </form> </div> </div> {% endblock %} {% block content %} <div class="ui_content"> <div class="ui_tb"> <table class="table" cellspacing="0" cellpadding="0" width="100%" align="center" border="0"> <tr> <th width="30"><input type="checkbox" id="id" name="id" /> </th> <th>设备名字</th> <th>制造商/型号</th> <th>IP</th> <th>端口数</th> <th>备注</th> <th>状态</th> <th>机房</th> <th>操作</th> </tr> {% for s in networkdevicelist.object_list %} <tr> <td><input type="checkbox" name="idcheck" value={{ s.id }} class="acb" /></td> <td>{{ s.hostname }}</td> <td>{{ s.model }}</td> <td>{{ s.ip }}</td> <td>{{ s.port_num }}</td> <td>{{ s.memo }}</td> <td>{% if s.status == 0 %} 在线 {% elif s.status == 1 %} 已下线 {% elif s.status == 2 %} 未知 {% elif s.status == 3 %} 故障 {% elif s.status == 4 %} 备用 {% endif %} </td> <td>{{ s.machinaroom.name }}</td> <td> <a href="javascript:void(0)" onclick="edit_networkdevice('{{ s.id }}')" class="edit">编辑</a> <a href="javascript:void(0)" onclick="del_networkdevice({{ s.id }},{{ networkdevicelist.number }});">删除</a> </td> </tr> {% endfor %} </table> </div> </div> </div> <script type="text/javascript"> function search_networkdevice(page){ var mname = document.getElementById("mname").value; var sname = document.getElementById("sname").value; var ip= document.getElementById("ip").value; var os= document.getElementById("os").value; var status = document.getElementById("status").value; var myurl="search_networkdevice.html"+"?"+"mname="+mname+"&&sname="+sname+"&&ip="+ip+"&&os="+os+"&&status="+status+"&&page="+page; window.location.assign(encodeURI(myurl)) } function add_networkdevice(){ var width = 400; var height = 500; var left = parseInt((screen.availWidth/2) - (width/2));//屏幕居中 var top = parseInt((screen.availHeight/2) - (height/2)); var windowFeatures = "width=" + width + ",height=" + height + ",status,resizable,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top; newWindow = window.open("add_networkdevice.html", "subWind", windowFeatures); } function edit_networkdevice(id){ var width = 400; var height = 500; var left = parseInt((screen.availWidth/2) - (width/2));//屏幕居中 var top = parseInt((screen.availHeight/2) - (height/2)); var windowFeatures = "width=" + width + ",height=" + height + ",status,resizable,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top; newWindow = window.open("edit_networkdevice.html?id="+id, "subWind", windowFeatures); } function del_networkdevice(id,page){ if(window.confirm('确定要删除该记录吗?')){ var text1= document.getElementById("mname").value; var sname=document.getElementById("sname").value; var ip=document.getElementById("ip").value; var os=document.getElementById("os").value; var status=document.getElementById("status").value; var myurl="del_networkdevice.html"+"?"+"id="+id+"&&mname="+text1+"&&page="+page+"&&ip="+ip+"&&os="+os+"&&status="+status+"&&sname="+sname; window.location.assign(encodeURI(myurl)) return true; }else{ //alert("取消"); return false; } } function batdel_networkdevice(){ if(window.confirm('确定要删除记录吗?')){ obj = document.getElementsByName("idcheck"); var text1= document.getElementById("mname").value; var sname=document.getElementById("sname").value; var ip=document.getElementById("ip").value; var os=document.getElementById("os").value; var status=document.getElementById("status").value; check_val = []; for(k in obj){ if(obj[k].checked) check_val.push(obj[k].value); } var myurl="batdel_networkdevice.html"+"?"+"ids="+check_val+"&&mname="+text1+"&&ip="+ip+"&&os="+os+"&&status="+status+"&&sname="+sname; window.location.assign(encodeURI(myurl)) return true; }else{ return false; } } function excel_networkdevice(){ var text1 = document.getElementById("mname").value; var sname=document.getElementById("sname").value; var ip=document.getElementById("ip").value; var os=document.getElementById("os").value; var status=document.getElementById("status").value; var myurl="excel_networkdevice.html"+"?mname="+text1+"&&ip="+ip+"&&os="+os+"&&status="+status+"&&sname="+sname; window.location.assign(encodeURI(myurl)) } </script> {% endblock %} {% extends 'base.html' %} {% block title %} <script type="text/javascript" src="/static/scripts/jquery/jquery-1.7.1.js"></script> <link href="/static/style/authority/basic_layout.css" rel="stylesheet" type="text/css"> <link href="/static/style/authority/common_style.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="/static/scripts/authority/commonAll.js"></script> <script type="text/javascript" src="/static/scripts/fancybox/jquery.fancybox-1.3.4.js"></script> <script type="text/javascript" src="/static/scripts/fancybox/jquery.fancybox-1.3.4.pack.js"></script> <link rel="stylesheet" type="text/css" href="/static/style/authority/jquery.fancybox-1.3.4.css" media="screen"></link> <script type="text/javascript" src="/static/scripts/artDialog/artDialog.js?skin=default"></script> <div id="container"> <div class="ui_content"> <div class="ui_text_indent"> <div id="box_border"> <div id="box_top">搜索</div> 机房名字<input type="text" id="mname" name="mname" value="{{ mname }}" class="ui_input_txt04" /> 设备名字<input type="text" id="sname" name="sname" value="{{ sname }}" class="ui_input_txt04" /> ip地址<input type="text" id="ip" name="ip" value="{{ ip }}" class="ui_input_txt04" /> 制造商/型号<input type="text" id="model" name="model" value="{{ model }}" class="ui_input_txt04" /> 类型<input type="text" id="type" name="type" value="{{ type }}" class="ui_input_txt04" /> 状态 <select id="status" name="status" class="ui_select02"> <option value=100 selected = "selected">所有</option> <option value=0 {% if status == 0 %} selected = "selected" {% endif %}>在线</option> <option value=1 {% if status == 1 %} selected = "selected" {% endif %}>已下线</option> <option value=2 {% if status == 2 %} selected = "selected" {% endif %}>未知</option> <option value=3 {% if status == 3 %} selected = "selected" {% endif %}>故障</option> <option value=4 {% if status == 4 %} selected = "selected" {% endif %}>备用</option> </select> </div> <div id="box_bottom"> <div class="pagination"> <span class="current"> {% if securitydevicelist.has_previous %} <a href="javascript:void(0)" onclick="search_securitydevice({{ securitydevicelist.previous_page_number }});">上一页</a> {% endif %} <span class="current"> Page {{ securitydevicelist.number }} of {{ securitydevicelist.paginator.num_pages }}. </span> {% if securitydevicelist.has_next %} <a href="javascript:void(0)" onclick="search_securitydevice({{ securitydevicelist.next_page_number }});">下一页</a> {% endif %} </span> </div> <input type="button" value="查询" class="ui_input_btn01" onclick="search_securitydevice(1);"/> <input type="button" value="新增" class="ui_input_btn01" onclick="add_securitydevice();" /> <input type="button" value="删除" class="ui_input_btn01" onclick="batdel_securitydevice();" /> <input type="button" value="导出EXCEL" class="ui_input_btn01" onclick="excel_securitydevice();" /> </div> </form> </div> </div> {% endblock %} {% block content %} <div class="ui_content"> <div class="ui_tb"> <table class="table" cellspacing="0" cellpadding="0" width="100%" align="center" border="0"> <tr> <th width="30"><input type="checkbox" id="id" name="id" /> </th> <th>设备名字</th> <th>制造商/型号</th> <th>IP</th> <th>端口数</th> <th>类型</th> <th>备注</th> <th>状态</th> <th>机房</th> <th>操作</th> </tr> {% for s in securitydevicelist.object_list %} <tr> <td><input type="checkbox" name="idcheck" value={{ s.id }} class="acb" /></td> <td>{{ s.hostname }}</td> <td>{{ s.model }}</td> <td>{{ s.ip }}</td> <td>{{ s.port_num }}</td> <td>{{ s.type }}</td> <td>{{ s.memo }}</td> <td>{% if s.status == 0 %} 在线 {% elif s.status == 1 %} 已下线 {% elif s.status == 2 %} 未知 {% elif s.status == 3 %} 故障 {% elif s.status == 4 %} 备用 {% endif %} </td> <td>{{ s.machinaroom.name }}</td> <td> <a href="javascript:void(0)" onclick="edit_securitydevice('{{ s.id }}')" class="edit">编辑</a> <a href="javascript:void(0)" onclick="del_securitydevice({{ s.id }},{{ securitydevicelist.number }});">删除</a> </td> </tr> {% endfor %} </table> </div> </div> </div> <script type="text/javascript"> function search_securitydevice(page){ var mname = document.getElementById("mname").value; var sname = document.getElementById("sname").value; var ip= document.getElementById("ip").value; var model= document.getElementById("model").value; var type=document.getElementById("type").value; var status = document.getElementById("status").value; var myurl="search_securitydevice.html"+"?"+"mname="+mname+"&&sname="+sname+"&&ip="+ip+"&&model="+model+"&&type="+type+"&&status="+status+"&&page="+page; window.location.assign(encodeURI(myurl)) } function add_securitydevice(){ var width = 400; var height = 500; var left = parseInt((screen.availWidth/2) - (width/2));//屏幕居中 var top = parseInt((screen.availHeight/2) - (height/2)); var windowFeatures = "width=" + width + ",height=" + height + ",status,resizable,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top; newWindow = window.open("add_securitydevice.html", "subWind", windowFeatures); } function edit_securitydevice(id){ var width = 400; var height = 500; var left = parseInt((screen.availWidth/2) - (width/2));//屏幕居中 var top = parseInt((screen.availHeight/2) - (height/2)); var windowFeatures = "width=" + width + ",height=" + height + ",status,resizable,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top; newWindow = window.open("edit_securitydevice.html?id="+id, "subWind", windowFeatures); } function del_securitydevice(id,page){ if(window.confirm('确定要删除该记录吗?')){ var text1= document.getElementById("mname").value; var sname=document.getElementById("sname").value; var ip=document.getElementById("ip").value; var model=document.getElementById("model").value; var type=document.getElementById("type").value; var status=document.getElementById("status").value; var myurl="del_securitydevice.html"+"?"+"id="+id+"&&mname="+text1+"&&page="+page+"&&ip="+ip+"&&model="+model+"&&type="+type+"&&status="+status+"&&sname="+sname; window.location.assign(encodeURI(myurl)) return true; }else{ //alert("取消"); return false; } } function batdel_securitydevice(){ if(window.confirm('确定要删除记录吗?')){ obj = document.getElementsByName("idcheck"); var text1= document.getElementById("mname").value; var sname=document.getElementById("sname").value; var ip=document.getElementById("ip").value; var model=document.getElementById("model").value; var type=document.getElementById("type").value; var status=document.getElementById("status").value; check_val = []; for(k in obj){ if(obj[k].checked) check_val.push(obj[k].value); } var myurl="batdel_securitydevice.html"+"?"+"ids="+check_val+"&&mname="+text1+"&&ip="+ip+"&&model="+model+"&&type="+type+"&&status="+status+"&&sname="+sname; window.location.assign(encodeURI(myurl)) return true; }else{ return false; } } function excel_securitydevice(){ var text1 = document.getElementById("mname").value; var sname=document.getElementById("sname").value; var ip=document.getElementById("ip").value; var model=document.getElementById("model").value; var type=document.getElementById("type").value; var status=document.getElementById("status").value; var myurl="excel_securitydevice.html"+"?mname="+text1+"&&ip="+ip+"&&model="+model+"&&type="+type+"&&status="+status+"&&sname="+sname; window.location.assign(encodeURI(myurl)) } </script> {% endblock %} {% extends 'base.html' %} {% block title %} <script type="text/javascript" src="/static/scripts/jquery/jquery-1.7.1.js"></script> <link href="/static/style/authority/basic_layout.css" rel="stylesheet" type="text/css"> <link href="/static/style/authority/common_style.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="/static/scripts/authority/commonAll.js"></script> <script type="text/javascript" src="/static/scripts/fancybox/jquery.fancybox-1.3.4.js"></script> <script type="text/javascript" src="/static/scripts/fancybox/jquery.fancybox-1.3.4.pack.js"></script> <link rel="stylesheet" type="text/css" href="/static/style/authority/jquery.fancybox-1.3.4.css" media="screen"></link> <script type="text/javascript" src="/static/scripts/artDialog/artDialog.js?skin=default"></script> <div id="container"> <div class="ui_content"> <div class="ui_text_indent"> <div id="box_border"> <div id="box_top">搜索</div> 机房名字<input type="text" id="mname" name="mname" value="{{ mname }}" class="ui_input_txt03" /> 设备名字<input type="text" id="sname" name="sname" value="{{ sname }}" class="ui_input_txt03" /> ip地址<input type="text" id="ip" name="ip" value="{{ ip }}" class="ui_input_txt03" /> 制造商/型号<input type="text" id="model" name="model" value="{{ model }}" class="ui_input_txt03" /> 状态 <select id="status" name="status" class="ui_select02"> <option value=100 selected = "selected">所有</option> <option value=0 {% if status == 0 %} selected = "selected" {% endif %}>在线</option> <option value=1 {% if status == 1 %} selected = "selected" {% endif %}>已下线</option> <option value=2 {% if status == 2 %} selected = "selected" {% endif %}>未知</option> <option value=3 {% if status == 3 %} selected = "selected" {% endif %}>故障</option> <option value=4 {% if status == 4 %} selected = "selected" {% endif %}>备用</option> </select> </div> <div id="box_bottom"> <div class="pagination"> <span class="current"> {% if storagedevicelist.has_previous %} <a href="javascript:void(0)" onclick="search_storagedevice({{ storagedevicelist.previous_page_number }});">上一页</a> {% endif %} <span class="current"> Page {{ storagedevicelist.number }} of {{ storagedevicelist.paginator.num_pages }}. </span> {% if storagedevicelist.has_next %} <a href="javascript:void(0)" onclick="search_storagedevice({{ storagedevicelist.next_page_number }});">下一页</a> {% endif %} </span> </div> <input type="button" value="查询" class="ui_input_btn01" onclick="search_storagedevice(1);"/> <input type="button" value="新增" class="ui_input_btn01" onclick="add_storagedevice();" /> <input type="button" value="删除" class="ui_input_btn01" onclick="batdel_storagedevice();" /> <input type="button" value="导出EXCEL" class="ui_input_btn01" onclick="excel_storagedevice();" /> </div> </form> </div> </div> {% endblock %} {% block content %} <div class="ui_content"> <div class="ui_tb"> <table class="table" cellspacing="0" cellpadding="0" width="100%" align="center" border="0"> <tr> <th width="30"><input type="checkbox" id="id" name="id" /> </th> <th>设备名字</th> <th>制造商/型号</th> <th>IP</th> <th>容量信息</th> <th>备注</th> <th>状态</th> <th>机房</th> <th>操作</th> </tr> {% for s in storagedevicelist.object_list %} <tr> <td><input type="checkbox" name="idcheck" value={{ s.id }} class="acb" /></td> <td>{{ s.hostname }}</td> <td>{{ s.model }}</td> <td>{{ s.ip }}</td> <td>{{ s.disk }}</td> <td>{{ s.memo }}</td> <td>{% if s.status == 0 %} 在线 {% elif s.status == 1 %} 已下线 {% elif s.status == 2 %} 未知 {% elif s.status == 3 %} 故障 {% elif s.status == 4 %} 备用 {% endif %} </td> <td>{{ s.machinaroom.name }}</td> <td> <a href="javascript:void(0)" onclick="edit_storagedevice('{{ s.id }}')" class="edit">编辑</a> <a href="javascript:void(0)" onclick="del_storagedevice({{ s.id }},{{ storagedevicelist.number }});">删除</a> </td> </tr> {% endfor %} </table> </div> </div> </div> <script type="text/javascript"> function search_storagedevice(page){ var mname = document.getElementById("mname").value; var sname = document.getElementById("sname").value; var ip= document.getElementById("ip").value; var model= document.getElementById("model").value; var status = document.getElementById("status").value; var myurl="search_storagedevice.html"+"?"+"mname="+mname+"&&sname="+sname+"&&ip="+ip+"&&model="+model+"&&status="+status+"&&page="+page; window.location.assign(encodeURI(myurl)) } function add_storagedevice(){ var width = 400; var height = 500; var left = parseInt((screen.availWidth/2) - (width/2));//屏幕居中 var top = parseInt((screen.availHeight/2) - (height/2)); var windowFeatures = "width=" + width + ",height=" + height + ",status,resizable,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top; newWindow = window.open("add_storagedevice.html", "subWind", windowFeatures); } function edit_storagedevice(id){ var width = 400; var height = 500; var left = parseInt((screen.availWidth/2) - (width/2));//屏幕居中 var top = parseInt((screen.availHeight/2) - (height/2)); var windowFeatures = "width=" + width + ",height=" + height + ",status,resizable,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top; newWindow = window.open("edit_storagedevice.html?id="+id, "subWind", windowFeatures); } function del_storagedevice(id,page){ if(window.confirm('确定要删除该记录吗?')){ var text1= document.getElementById("mname").value; var sname=document.getElementById("sname").value; var ip=document.getElementById("ip").value; var model=document.getElementById("model").value; var status=document.getElementById("status").value; var myurl="del_storagedevice.html"+"?"+"id="+id+"&&mname="+text1+"&&page="+page+"&&ip="+ip+"&&model="+model+"&&status="+status+"&&sname="+sname; window.location.assign(encodeURI(myurl)) return true; }else{ //alert("取消"); return false; } } function batdel_storagedevice(){ if(window.confirm('确定要删除记录吗?')){ obj = document.getElementsByName("idcheck"); var text1= document.getElementById("mname").value; var sname=document.getElementById("sname").value; var ip=document.getElementById("ip").value; var model=document.getElementById("model").value; var status=document.getElementById("status").value; check_val = []; for(k in obj){ if(obj[k].checked) check_val.push(obj[k].value); } var myurl="batdel_storagedevice.html"+"?"+"ids="+check_val+"&&mname="+text1+"&&ip="+ip+"&&model="+model+"&&status="+status+"&&sname="+sname; window.location.assign(encodeURI(myurl)) return true; }else{ return false; } } function excel_storagedevice(){ var text1 = document.getElementById("mname").value; var sname=document.getElementById("sname").value; var ip=document.getElementById("ip").value; var model=document.getElementById("model").value; var status=document.getElementById("status").value; var myurl="excel_storagedevice.html"+"?mname="+text1+"&&ip="+ip+"&&model="+model+"&&status="+status+"&&sname="+sname; window.location.assign(encodeURI(myurl)) } </script> {% endblock %}

优秀的个人博客,低调大师

我的网站搭建: (第十天) Ueditor后台编辑器

之前说过,我的网站编辑器一开始是tinymce,然后才用的ckeditor。可是最近我发现,ckeditor的小图标不是很美观,看久了有点low的样子。我是不是应该换一个编辑器呢,一想到这里,马上打开谷歌搜索有没有更加美观的富文本编辑器。翻了几页发现,才发现百度Ueditor编辑器就很不错,其实之前我就了解过,但是并没有学习去怎么使用,这回好了,换个富文本编辑器顺便把Ueditor给学会了 安装及使用 1.Ueditor其实对python2和python3有一定的区别,在写程序时想通过Django的form表单顺便把评论框也改成Ueditor,但是没有将其实现却发现了错误提示为: fromwidgetsimportUEditorWidget,AdminUEditorWidget ImportError:Nomodulenamed‘widgets’ 经查发现,DjangoUeditor是基于Python 2.7的,对Python3的支持有问题。导致widgets.py文件出错,不能import,解决方法可以修改widgets.py或者采用网上修改好的版本DjangoUeditor3,github就有很多Ueditor的代码,有些不能直接使用,可能太久没更新了吧,然后才找到了:https://github.com/twz915/DjangoUeditor3 2.使用git下载后,输入如下命令将源码安装到Python路径中 python3setup.pyinstall 3.将DjangooUeditor添加到Django的INSTALLED_APPS中 4.在blog下的models.py文件导入 fromDjangoUeditor.modelsimportUEditorField #将之前ckeditor body=RichTextUploadingField() #改为 body=UEditorField(u'内容',width=1100,height=300,toolbars="full",imagePath="images/",filePath="files/",upload_settings={"imageMaxSize":1204000},) 5.进入admin后台管理页面,可以看到这时编辑器已经换了个装 6.去掉百度编辑器 ueditor 元素路径、字数统计等 在百度编辑器 ueditor 根目录下: ueditor.config.js 文件中 搜索并将参数elementPathEnabled设置成false即可 常用功能开关如下: ,elementPathEnabled : false //是否启用元素路径,默认是true显示 ,wordCount:false //是否开启字数统计 ,autoHeightEnabled:false // 编辑器内容,是否自动长高,默认true ,fullscreen : false //是否开启初始化时即全屏,默认关闭 7.图标对比 ckeditor是这样的 ueditor是这样的 代码高亮 1.为了这个代码高亮可是浪费了我不少时间,一开始是发现在DjangoUeditor/staticueditor/thirdd-party/SyntaxHighlighter文件夹中有shCoreDefault.css和shCore.js这两个文件的,网上也有很多文章说了可以在详情页添加下面三个标签 运行完后,发现的确有些效果,可是伴随着还有另外三个问题 一个是代码之间的行距和字体太小,不便于代码的阅读,通过对网页元素进行分析,我找到了shCoreDefault.css文件中的两个属性,通过文件搜索找出来将它们注释就可以解决了 line-height:1.1em!important; font-size:13px!important; 如果说上面的问题还能接收,第二个问题就完全不适应了,那就是行号与代码不匹配,经常在代码的两头空出多行是没有注明行号的,看着很不习惯 还有第三个问题,代码过长的情况下,不能自动换行,就导致代码块容易超出父容器宽度。网上的解决办法都是在shCoreDefault.css文件中通过ctrl+F查找:.syntaxhighlighter{,然后在括弧中加入样式:word-break:break-all,这个有效果,已经测试过了,但是第二个问题实在能力有限,无法解决,被迫放弃使用DjangoUeditor中的css样式 2.放弃DjangoUeditor的自带样式后,又找到了第二条路,那就是使用Hlightjs,我想要的是类似github上的那种白色背景的代码高亮显示,幸运的是Hlightjs插件提供了太多太多的代码样式。我参考的文章地址:https://blog.csdn.net/msllws/article/details/81048390 3.在官网https://highlightjs.org/download/下载好Hlightjs插件后,与之前使用SyntaxHighlighter类似,添加下面三个标签 <!--foundation.css文件就是我选择的代码样式--> <linkrel="stylesheet"type="text/css"href="{%static'blog/css/foundation.css'%}"> <scripttype="text/javascript"src="{%static'blog/js/highlight.pack.js'%}"></script> <script>hljs.initHighlightingOnLoad();</script> 这个时候,还无法正常显示,因为代码高亮遵循的格式是:<pre><code>代码</code></pre>而百度编辑器默认的代码块显示格式为:<pre>代码</pre>,所以还需要再写上一个script,添加在body下面 <scripttype="text/javascript"> varallpre=document.getElementsByTagName("pre"); for(i=0;i<allpre.length;i++) { varonepre=document.getElementsByTagName("pre")[i]; varmycode=document.getElementsByTagName("pre")[i].innerHTML; onepre.innerHTML='<codeid="mycode">'+mycode+'</code>'; } </script> 这个时候已经能看出代码样式发生改变了,但是没有行号,所以还要给代码加上行号,先创建一个code.css文件,里面包含了code代码块行号的样式效果 pre{ position:relative; padding:0; /*margin-bottom:24px;*/ border-radius:3px; border:1pxsolid#C3CCD0; background:#FFF; overflow:hidden; font-size:14px; } code{ display:block; padding:18px24px; overflow-y:auto; font-weight:300; font-family:Menlo,monospace; font-size:14px; } code.has-numbering{ margin-left:30px; } .pre-numbering{ position:absolute; top:0; left:0; width:30px; padding:8px5px5px0; border-right:1pxsolid#C3CCD0; border-radius:3px003px; background-color:#f5f5f5; text-align:right; font-family:Menlo,monospace; font-size:14px; color:#8c8c8c; } 将上面的行号样式通过javascript绑定到每个li元素上 <scripttype="text/javascript"> $(function(){ $('precode').each(function(){ varlines=$(this).text().split('\n').length-1; var$numbering=$('<ul/>').addClass('pre-numbering'); $(this) .addClass('has-numbering') .parent() .append($numbering); for(i=1;i<=lines+100;i++){ $numbering.append($('<li/>').text(i)); } }); }); </script> 完成后,就已经实现Ueditor+Hightjs的代码高亮了 4.代码高亮对比 Ckeditor是这样的 Ueditor是这样的 其他常见问题 1.此时可能还会出现编辑框内图片无法正常缩放,是因为页面上引入了Bootstrap,而Bootstrap默认将box-sizing样式统一设成border-box了,在ueditor.min.css中加入如下代码,就算是填坑成功 .edui-container*{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;} .edui-container*:before,.edui-container*:after{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;} 2.在css中可能出现长串字母或者数字不会自动换行的问题,在对应css中加: word-break:break-all; 3.因为在编辑文章的时候,上传图片的宽度是用px来表示的,这就有可能导致图片宽度超出父容器宽度,所以需要重新对img元素进行宽度重定义 #post-bodyimg{ max-width:100%; } 4.在编辑超链接内容时可以发现,在移动端或者宽度很窄的显示屏上,a标签元素也常常超出容器宽度之外,这是因为ueditor对长字母或者长数字不会自动换行导致的,所以需要设置自动换行 #post-bodya{ word-break:break-all; } 5.用过ueditor的人都知道,还有一个常见问题就是在编辑器下使用的表格可以被预览,但是内容发布之后,在网页显示中是看不见边框的。网上很多人大都提议取修改ueditor.all.js或者ueditor.all.min.js,但是我按照那个方法行不通,不知道是哪里还出了错,所以我就直接用最粗暴的方式,在详情页中的样式加上 #post-bodytable,#post-bodytr,#post-bodytd{ border:1pxsolid#000; max-width:100%; } 最后,实在没想到换个富文本编辑器会弄出这么多问题,学习之路,最难也是最让人愉悦的,也只有学习才是生活

优秀的个人博客,低调大师

百度架构师是怎样搭建MySQL分布式集群?

1、什么是MySQL集群 MySQL集群是一个无共享的(shared-nothing)、分布式节点架构的存储方案,其目的是提供容错性和高性能。 数据更新使用读已提交隔离级别(read-committedisolation)来保证所有节点数据的一致性,使用两阶段提交机制(two-phasedcommit)保证所有节点都有相同的数据(如果任何一个写操作失败,则更新失败)。 无共享的对等节点使得某台服务器上的更新操作在其他服务器上立即可见。传播更新使用一种复杂的通信机制,这一机制专用来提供跨网络的高吞吐量。 通过多个MySQL服务器分配负载,从而最大程序地达到高性能,通过在不同位置存储数据保证高可用性和冗余。 需要更多MySQL集群知识的可以订阅我哦 2、名称概念 MySQL集群有如下三层: 应用程序层:负责与mysql服务器通信的各种应用程序。 Mysql服务器层:处理SQL命令,并与NDB存储引擎通信和Mysql服务器。 NDB集群组件层:NDB集群组件有时也称数据节点,负责处理查询,然后将结果返回给mysql服务器。 其中MySQL数据库集群主要包括如下三部分: 1) SQL节点(SQL node - 下图对应为 mysqld):分布式数据库。包括自身数据和查询中心结点数据 2) 数据节点(Data node - ndbd):集群共享数据(内存中) 3) 管理服务器(Management Server - ndb_mgmd):管理集群 SQL node,Data node 拓扑结构图如下所示: 欢迎工作一到五年的Java工程师朋友们加入Java架构开发:468947140 点击链接加入群聊【Java-BATJ企业级资深架构】:https://jq.qq.com/?_wv=1027&k=5zMN6JB 本群提供免费的学习指导 架构资料 以及免费的解答 不懂得问题都可以在本群提出来 之后还会有职业生涯规划以及面试指导

优秀的个人博客,低调大师

CentOS7.4上搭建Samba,实现windows与Linux文件数据同步

一 环境介绍 1.本地win10 2.远程Linux (centos7.4) 二 安装Samba 1. 安装samba相关的服务 yum install -y samba* 2. 查看Samba是否安装成功 systemctl status smb 注:如果出现如下显示,说明Samba安装成功 三 配置Samba 1. 配置Samba配置文件 1.1 备份samba配置文件 cp /etc/samba/smb.conf /etc/samba/smb.conf.bak 1.2 编辑smb.conf , 对samba进行配置,改为如下 [global] workgroup = WORKGROUP server string = Ted Samba Server %v netbios name = TedSamba security = user map to guest = Bad User passdb backend = tdbsam [Faraway] comment = project development directory path = /data valid users = ted write list = ted printable = no create mask = 0644 directory mask = 0755 2. 配置系统文件打开数目上限(因为后续会通过samba文件打开大量文件,所以需要修改此参数) vim /etc/security/limits.conf //文件末尾需要添加如下内容 * soft nofile 65535 * hard nofile 65535 四 创建用户 groupadd co3 #创建co3组 useradd ted -g co3 -s /sbin/nologin #添加用户ted,并放到co3组 smbpasswd -a ted #将ted用户添加到smb服务中 五 赋予共享文件夹属性 chown ted:co3 /data/ 六 关闭 Selinux 和 防火墙 1.关闭Selinux vim /etc/selinux/config #永久关闭selinux , 将SELINUX=enforcing改为SELINUX=disabled 2.关闭firewall systemctl stop firewalld systemctl disable firewalld 3. 重启系统 reboot 七 启动Samba systemctl stop iptables #关闭防火墙 (虽然之前有关闭防火墙的操作,但是根据实践表明,可能防火墙关闭的并不彻底,所以添加了这一步) systemctl restart smb #重启 systemctl enable smb #修改为开机启动 systemctl status smb #查看状态 八 windows访问Linux下data文件夹 1 访问 2. 效果 3. 将Linux上的文件映射到磁盘中 鼠标右键Faraway文件夹, 选择"映射网络驱动器,选择一个磁盘名",确定之后,我们打开我的电脑,可以看到多了一个磁盘,就是Linux映射过来的文件夹 像这样 九 可能出现的问题 一 无法访问远程samba共享文件夹 1. 重新关闭firewalld,并重启smb 2. 进行windows的smb配置 //管理员权限进入cmd //开启SMBv1 sc.exe config lanmanworkstation depend= bowser/mrxsmb10/mrxsmb20/nsi sc.exe config mrxsmb10 start= auto //关闭SMBv2 and SMBv3 sc.exe config lanmanworkstation depend= bowser/mrxsmb10/nsi sc.exe config mrxsmb20 start= disabled 3. 设置windows访问来宾权限 3.1 win+R 3.2 3.3 双击调整来宾登录 https://jingyan.baidu.com/article/7c6fb428d62a6e80642c90cc.html 4. 如果到现在还是不行,检查本地win10计算机登录账户, 确认切换到本地账户登录 二 写入文件用sublime可以, 用phpstorm就打不开 这时,我们需要对phpstorm进行一定的设置,如下 应用确定之后,我们发现,现在可以用phpstorm打开刚才在phpstorm中显示不出来的远程Linux文件了 参考: http://www.mamicode.com/info-detail-2255973.html https://blog.csdn.net/qice675563721/article/details/74853222

优秀的个人博客,低调大师

手把手:用Python搭建机器学习模型预测黄金价格

自古以来,黄金一直作为货币而存在,就是在今天,黄金也具有非常高的储藏价值,那么有没有可能预测出黄金价格的变化趋势呢? 答案是肯定的,让我们使用机器学习中的回归算法来预测世界上贵重金属之一,黄金的价格吧。 我们将建立一个机器学习线性回归模型,它将从黄金ETF (GLD)的历史价格中获取信息,并返回黄金ETF价格在第二天的预测值。 GLD是最大的以黄金进行直接投资的ETF交易基金。 (详见:http://www.etf.com/GLD) 在python的开发环境下用机器学习预测黄金价格的步骤: 导入Python库并读取黄金ETF 的数据 定义解释变量 将数据切分为模型训练数据集和测试数据集 建立线性回归模型 预测黄金ETF的价格 导入Python库并读取黄金 ETF 的数据 首先:导入实现此策略所需的所有必要的库(LinearRegression,pand

资源下载

更多资源
腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册