Ejemplo n.º 1
0
def detail(request, host_id):
    host = Host.objects.get(pk=host_id)
    if request.method == "POST":
        form = HostForm(request.POST, instance=host)
        if form.is_valid():
            #host = form.cleaned_data['host']
            #name = form.cleaned_data['name']
            #alias = form.cleaned_data['alias']
            form.save()
            #return HttpResponseRedirect('/detail/')
            return HttpResponseRedirect('assets_management.html')
            #return HttpResponseRedirect(reverse('Welcome'))
    else:
        form = HostForm(instance=host)

    #return render(request, 'assets_detail.html', {'host':host, 'form':form})
    return render(request, 'assets_detail.html', {'host':host, 'form':form}, context_instance=RequestContext(request))
Ejemplo n.º 2
0
def manager_host(request):
	data_center = models.DataCenter.objects.all()
	cabinet = models.Cabinet.objects.all()
	if request.method == 'POST':
		data=request.POST.copy()
		data['hardware'] = json.JSONEncoder().encode({"cpu":data['cpu'],
													"disk":data['disk_capcity']})
		form = HostForm(data)
		if form.is_valid():
			form.save()
			return HttpResponseRedirect("/main")
	else:
		form = HostForm()

	return render_to_response("add_host.html",{"form": form,
												"data_center": data_center,
												"cabinet": cabinet})
Ejemplo n.º 3
0
def detail(request, host_id):
    host = Host.objects.get(pk=host_id)
    if request.method == "POST":
        form = HostForm(request.POST, instance=host)
        if form.is_valid():
            #host = form.cleaned_data['host']
            #name = form.cleaned_data['name']
            #alias = form.cleaned_data['alias']
            form.save()
            #return HttpResponseRedirect('/detail/')
            return HttpResponseRedirect('assets_management.html')
            #return HttpResponseRedirect(reverse('Welcome'))
    else:
        form = HostForm(instance=host)

    #return render(request, 'assets_detail.html', {'host':host, 'form':form})
    return render(request,
                  'assets_detail.html', {
                      'host': host,
                      'form': form
                  },
                  context_instance=RequestContext(request))