Beispiel #1
0
def add_patron(request):
    if request.method == 'POST':
        patron_form = PatronForm(request.POST)
        if patron_form.is_valid():
            patron_form.save()
            return HttpResponseRedirect(reverse('core.views.patron_list'))
    else:
        patron_form = PatronForm()
        return render(request, 'core/add_patron.html',
            {'patron_form': patron_form}
        )
Beispiel #2
0
def edit_patron(request, patron_id):
    patron = get_object_or_404(Patron, pk=patron_id)
    if request.method == 'POST':
        patron_form = PatronForm(request.POST, instance=patron)
        if patron_form.is_valid():
            patron_form.save()
            return HttpResponseRedirect(reverse('core.views.patron_list'))
    else:
        patron_form = PatronForm(instance=patron)
        return render(request, 'core/edit_patron.html',
            {'patron': patron, 'patron_form': patron_form}
        )