fix: Correct add animal flow

This commit is contained in:
moanos [he/him] 2024-05-31 10:56:41 +02:00
parent bfcd8cd2e5
commit a364287a38

View File

@ -104,6 +104,7 @@ def add_adoption(request):
form = AdoptionNoticeForm(in_adoption_notice_creation_flow=True) form = AdoptionNoticeForm(in_adoption_notice_creation_flow=True)
return render(request, 'fellchensammlung/forms/form_add_adoption.html', {'form': form}) return render(request, 'fellchensammlung/forms/form_add_adoption.html', {'form': form})
@login_required @login_required
def adoption_notice_add_animal(request, adoption_notice_id): def adoption_notice_add_animal(request, adoption_notice_id):
if request.method == 'POST': 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.adoption_notice_id = adoption_notice_id
instance.save() instance.save()
form.save_m2m() form.save_m2m()
if True: if "save-and-add-another-animal" in request.POST:
return redirect(reverse("adoption-notice-detail", args=[adoption_notice_id])) form = AnimalForm(in_adoption_notice_creation_flow=True)
return render(request, 'fellchensammlung/forms/form_add_animal_to_adoption.html', {'form': form})
else: else:
return render(request, 'fellchensammlung/forms/form_add_animal_to_adoption.html') return redirect(reverse("adoption-notice-detail", args=[adoption_notice_id]))
else: else:
form = AnimalForm(in_adoption_notice_creation_flow=True) form = AnimalForm(in_adoption_notice_creation_flow=True)
return render(request, 'fellchensammlung/forms/form_add_animal_to_adoption.html', {'form': form}) return render(request, 'fellchensammlung/forms/form_add_animal_to_adoption.html', {'form': form})
@login_required @login_required
def animal_edit(request, animal_id): def animal_edit(request, animal_id):
""" """