Esempio n. 1
0
def author_add(request):
    if request.method == 'POST':
        form = AuthorForm(request.POST)
        if form.is_valid():
            form.save()
            return render_to_response('common/success.html')
    else:
        form = AuthorForm()

    variables = RequestContext(request, {'form': form})
    return render_to_response('crud/author/author_add.html', variables)
Esempio n. 2
0
def author_add(request):
    if request.method == "POST":
        form = AuthorForm(request.POST)
        if form.is_valid():
            form.save()
            return render_to_response("common/success.html")
    else:
        form = AuthorForm()

    variables = RequestContext(request, {"form": form})
    return render_to_response("crud/author/author_add.html", variables)
Esempio n. 3
0
def author_add(request):
    if request.method == 'POST':
        form = AuthorForm(request.POST)
        if form.is_valid():
            form.save()
            return render_to_response('common/success.html')
    else:
        form = AuthorForm()

    variables = RequestContext(request, {
        'form': form
    })
    return render_to_response('crud/author/author_add.html', variables)
Esempio n. 4
0
def author_edit(request, id):
    author = Author.objects.get(pk=id)
    if request.method == "POST":
        form = AuthorForm(request.POST, instance=author)
        if form.is_valid():
            form.save()
            return render_to_response('common/success.html')
    else:
        form = AuthorForm(instance=author)

    variables = RequestContext(request, {'form': form})

    return render_to_response("crud/author/author_edit.html", variables)
Esempio n. 5
0
def author_edit(request, id):
    author = Author.objects.get(pk=id)
    if request.method == "POST":
        form = AuthorForm(request.POST, instance=author)
        if form.is_valid():
            form.save()
            return render_to_response("common/success.html")
    else:
        form = AuthorForm(instance=author)

    variables = RequestContext(request, {"form": form})

    return render_to_response("crud/author/author_edit.html", variables)
Esempio n. 6
0
def author_manager(request, author):
    BookInlineFormSet = inlineformset_factory(Author, Book, extra=1,
                                              formfield_callback=add_category)

    form = AuthorForm(request.POST or None, instance=author)
    formset = BookInlineFormSet(request.POST or None, instance=author)

    if form.is_valid() and formset.is_valid():
        form.save()
        formset.save()
        return HttpResponseRedirect('/inlines/')

    return render_to_response("manage_authors.html",
        {"formset": formset,
        "form": form},
        RequestContext(request))
Esempio n. 7
0
def author_manager(request, author):
    BookInlineFormSet = inlineformset_factory(Author,
                                              Book,
                                              extra=1,
                                              formfield_callback=add_category)

    form = AuthorForm(request.POST or None, instance=author)
    formset = BookInlineFormSet(request.POST or None, instance=author)

    if form.is_valid() and formset.is_valid():
        form.save()
        formset.save()
        return HttpResponseRedirect('/inlines/')

    return render_to_response("manage_authors.html", {
        "formset": formset,
        "form": form
    }, RequestContext(request))