feat: Make sure location gets refreshed when editing AN

This commit is contained in:
moanos [he/him] 2024-08-08 13:27:08 +02:00
parent ac139af706
commit c8ef310a71

View File

@ -119,6 +119,10 @@ def adoption_notice_edit(request, adoption_notice_id):
if form.is_valid(): if form.is_valid():
adoption_notice_instance = form.save() adoption_notice_instance = form.save()
"""Search the location given in the location string and add it to the adoption notice"""
location = Location.get_location_from_string(adoption_notice_instance.location_string)
adoption_notice_instance.location = location
adoption_notice_instance.save()
return redirect(reverse("adoption-notice-detail", args=[adoption_notice_instance.pk], )) return redirect(reverse("adoption-notice-detail", args=[adoption_notice_instance.pk], ))
else: else:
form = AdoptionNoticeForm(instance=adoption_notice) form = AdoptionNoticeForm(instance=adoption_notice)