Beispiel #1
0
def add_host(request):
    form = HostForm()
    if request.method == 'POST':
        form = HostForm(request.POST)
        form.owner = request.user
        if form.is_valid():
            form.save()
            return redirect(reverse('hosts.views.index'))
    ctx = {'form': form}
    return render_to_response('hosts/add_host.html',
                              ctx,
                              context_instance=RequestContext(request))
Beispiel #2
0
def add_host(request):
    form = HostForm()
    if request.method == 'POST':
        form = HostForm(request.POST)
        form.owner = request.user
        if form.is_valid():
            form.save()
            return redirect(reverse('hosts.views.index'))
    ctx = {
        'form': form
    }
    return render_to_response('hosts/add_host.html', ctx,
        context_instance=RequestContext(request))
Beispiel #3
0
def edit_host(request, host_id):
    h = Host.objects.get(id=host_id)
    form = HostForm(instance=h)
    if request.method == 'POST':
        form = HostForm(request.POST, instance=h)
        form.owner = request.user
        if form.is_valid():
            form.save()
            messages.add_message(request, messages.INFO,
                                 _('Updated') + ' {0}'.format(h.name))
            return redirect(reverse('hosts.views.index'))
    ctx = {'form': form}
    return render_to_response('hosts/edit_host.html',
                              ctx,
                              context_instance=RequestContext(request))
Beispiel #4
0
def edit_host(request, host_id):
    h = Host.objects.get(id=host_id)
    form = HostForm(instance=h)
    if request.method == 'POST':
        form = HostForm(request.POST, instance=h)
        form.owner = request.user
        if form.is_valid():
            form.save()
            messages.add_message(request, messages.INFO, _('Updated') + ' {0}'.format(
                h.name))
            return redirect(reverse('hosts.views.index'))
    ctx = {
        'form': form
    }
    return render_to_response('hosts/edit_host.html', ctx,
        context_instance=RequestContext(request))