def zone_list(request,zid): owner = request.user.username if not CheckZoneOwner(zid,owner): return HttpResponseRedirect('/dns/') u = get_object_or_404(User,username=owner) zones_list = OwnedZones(owner) if request.method == 'POST': form = ZoneForm(request.POST) if form.is_valid(): form.save() message = 'Zona creada!! por suerte...' #zones_list = Zone.objects.all() zones_list = OwnedZones(owner) return HttpResponseRedirect('/') else: form = RecordForm() #zones_list = Zone.objects.all() # bump! esto estaba comentareado ... y no se porque ... zones_list = OwnedZones(owner) ttl_list = TTL.objects.all() #record_list = Record.objects.filter(zone=zid) fullrr_list = Record.objects.filter(zone=zid) rl_list = fullrr_list for rr in fullrr_list: if rr.type.id == 15: url_cname_rr = Record.objects.filter(zone=zid,type=6,name__iexact=rr.name) urlr = get_object_or_404(Record,pk=url_cname_rr[0].id) rl_list = rl_list.exclude(id=urlr.id) record_list = rl_list z = get_object_or_404(Zone,pk=zid) # toja reverse = 0 ptrz = '' if 'in-addr.arpa' in z.name : zname = z.name reverse = 1 fullreverseip = zname.split('.') # le quito el in-addr y el arpa reverseip = fullreverseip[1:-2] reverseip.reverse() ptrz = '.'.join(reverseip) #freverseip = '.'.join(fullreverseip) return render_to_response('dns/index.html', {'zones_list':zones_list,'form':form,'zid':zid,'record_list':record_list,'zone':z,'ttl_list':ttl_list,'username':request.user.username,'user':u,'reverse':reverse,'ptrz':ptrz})
def zone_edit(request,zid): if request.method == 'POST': z = get_object_or_404(Zone,pk=zid) form = ZoneForm(request.POST,instance=z) message = "Dominio editado exitosamente !!" #form = ZoneForm(instance=z) # form = ZoneForm(request.POST) if form.is_valid(): form.save() #return HttpResponseRedirect('/') #return render_to_response('dns/index.html',{'message': message}) #return render_to_response(url_redirect\,{'message': message}) return HttpResponseRedirect(reverse('gesta.dnsadmin.views.zone_list', args=[zid])) else: message = 'los datos son invalidos' return render_to_response('dns/index.html',{'message': message}) else: z = get_object_or_404(Zone,pk=zid) message = "Editando el dominio !!" form = ZoneForm(instance=z) # form = ZoneForm() return render_to_response('dns/zone_edit.html', {'form': form, 'message': message,'zid':zid})
def zone_add(request): owner = request.user.username if request.method == 'POST': u = get_object_or_404(User,username=owner) z = Zone() z.owner = u zones_list = OwnedZones(owner) if Zone.objects.filter(name__iexact=request.POST['name']).count(): message = "Ya existe una zona con ese nombre." return render_to_response('dns/index.html',{'message': message,'zones_list':zones_list,'username':owner}) form = ZoneForm(request.POST, instance=z) if form.is_valid(): zone_add = '0' form.save() message = 'Zona creada!!' zone_file_new(z,owner) return HttpResponseRedirect(reverse('gesta.dnsadmin.views.zone_list', args=[z.id])) else: form = ZoneForm() zone_add = '1' zones_list = OwnedZones(owner) # zones_list = Zone.objects.all() return render_to_response('dns/index.html', {'zone_add':zone_add,'zoneform':form,'zones_list':zones_list,'username':owner})