Exemple #1
0
def add_machine(request):
    """
    TODO: need some magic to make VM 'real' not just 'visible on site'!
    """
    if request.method == "POST":
        form = VMForm(request.POST)
        if form.is_valid():
            new_vm = form.save()
            new_vm.save()
            return HttpResponseRedirect('/vms')
        else:
            return render_to_response('vms/add.html', {
                'form': form,
            }, context_instance=RequestContext(request))
    else:
        form = VMForm()
        return render_to_response('vms/add.html', {
            'form': form,
        }, context_instance=RequestContext(request))
Exemple #2
0
def edit_machine(request, pid):
    """
    TODO: need some magic to make VM editing 'real', not just 'visible on site!'
    """
    vm = VirtualMachine
    try:
        vm = VirtualMachine.objects.get(id=pid)
    except VirtualMachine.DoesNotExist:
        raise Http404()
    if request.method == "POST":
        form = VMForm(request.POST, instance=vm)
        if form.is_valid():
            vm = form.save()
            vm.save()
            return HttpResponseRedirect('/vms')
        else:
            return render_to_response('vms/edit.html', {
                'form': form,
            },
                                      context_instance=RequestContext(request))
    else:
        form = VMForm(instance=vm)
        return render_to_response('vms/edit.html', {
            'form': form,
        },
                                  context_instance=RequestContext(request))
Exemple #3
0
def edit_machine(request, pid):
    """
    TODO: need some magic to make VM editing 'real', not just 'visible on site!'
    """
    vm = VirtualMachine
    try:
        vm = VirtualMachine.objects.get(id=pid)
    except VirtualMachine.DoesNotExist:
        raise Http404()
    if request.method == "POST":
        form = VMForm(request.POST, instance=vm)
        if form.is_valid():
            vm = form.save()
            vm.save()
            return HttpResponseRedirect('/vms')
        else:
            return render_to_response('vms/edit.html', {
                'form': form,
            }, context_instance=RequestContext(request))
    else:
        form = VMForm(instance=vm)
        return render_to_response('vms/edit.html', {
            'form': form,
        }, context_instance=RequestContext(request))
Exemple #4
0
def add_machine(request):
    """
    TODO: need some magic to make VM 'real' not just 'visible on site'!
    """
    if request.method == "POST":
        form = VMForm(request.POST)
        if form.is_valid():
            new_vm = form.save()
            new_vm.save()
            return HttpResponseRedirect('/vms')
        else:
            return render_to_response('vms/add.html', {
                'form': form,
            },
                                      context_instance=RequestContext(request))
    else:
        form = VMForm()
        return render_to_response('vms/add.html', {
            'form': form,
        },
                                  context_instance=RequestContext(request))