From a364287a38fb99f01ce5ae0bcfcd51c4a54f51cd Mon Sep 17 00:00:00 2001 From: moanos Date: Fri, 31 May 2024 10:56:41 +0200 Subject: [PATCH] fix: Correct add animal flow --- src/fellchensammlung/views.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/fellchensammlung/views.py b/src/fellchensammlung/views.py index 61f4dcb..ede8b89 100644 --- a/src/fellchensammlung/views.py +++ b/src/fellchensammlung/views.py @@ -104,6 +104,7 @@ def add_adoption(request): form = AdoptionNoticeForm(in_adoption_notice_creation_flow=True) return render(request, 'fellchensammlung/forms/form_add_adoption.html', {'form': form}) + @login_required def adoption_notice_add_animal(request, adoption_notice_id): if request.method == 'POST': @@ -114,14 +115,16 @@ def adoption_notice_add_animal(request, adoption_notice_id): instance.adoption_notice_id = adoption_notice_id instance.save() form.save_m2m() - if True: - return redirect(reverse("adoption-notice-detail", args=[adoption_notice_id])) + if "save-and-add-another-animal" in request.POST: + form = AnimalForm(in_adoption_notice_creation_flow=True) + return render(request, 'fellchensammlung/forms/form_add_animal_to_adoption.html', {'form': form}) else: - return render(request, 'fellchensammlung/forms/form_add_animal_to_adoption.html') + return redirect(reverse("adoption-notice-detail", args=[adoption_notice_id])) else: form = AnimalForm(in_adoption_notice_creation_flow=True) return render(request, 'fellchensammlung/forms/form_add_animal_to_adoption.html', {'form': form}) + @login_required def animal_edit(request, animal_id): """