Beispiel #1
0
def computers_create(request):
    if request.method == "POST":
        form = ComputerForm(request.POST)
        if form.is_valid():
            computer = form.save()
            return HttpResponseRedirect(reverse("cthulhubot-computer-detail", kwargs={
                "computer" : computer.slug,
            }))
    else:
        form = ComputerForm()
        
    return direct_to_template(request, 'cthulhubot/computers_create.html', {
        'form' : form
    })
Beispiel #2
0
def computer_edit(request, computer):
    computer = get_object_or_404(BuildComputer, slug=computer)
    if request.method == "POST":
        form = ComputerForm(request.POST, instance=computer)
        if form.is_valid():
            computer = form.save()
            return HttpResponseRedirect(reverse("cthulhubot-computer-detail", kwargs={
                "computer" : computer.slug,
            }))
    else:
        form = ComputerForm(instance=computer)

    return direct_to_template(request, 'cthulhubot/computers_edit.html', {
        'form' : form
    })