feat: Make proper animal edit form
This commit is contained in:
@@ -84,19 +84,7 @@ class AdoptionNoticeFormWithDateWidget(AdoptionNoticeForm):
|
|||||||
|
|
||||||
|
|
||||||
class AnimalForm(forms.ModelForm):
|
class AnimalForm(forms.ModelForm):
|
||||||
def __init__(self, *args, **kwargs):
|
template_name = "fellchensammlung/forms/form_snippets.html"
|
||||||
if 'in_adoption_notice_creation_flow' in kwargs:
|
|
||||||
adding = kwargs.pop('in_adoption_notice_creation_flow')
|
|
||||||
else:
|
|
||||||
adding = False
|
|
||||||
super().__init__(*args, **kwargs)
|
|
||||||
self.helper = FormHelper()
|
|
||||||
self.helper.form_class = 'form-animal card'
|
|
||||||
if adding:
|
|
||||||
self.helper.add_input(Submit('save-and-add-another-animal', _('Speichern und weiteres Tier hinzufügen')))
|
|
||||||
self.helper.add_input(Submit('save-and-finish', _('Speichern und beenden')))
|
|
||||||
else:
|
|
||||||
self.helper.add_input(Submit('submit', _('Speichern'), css_class="btn"))
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Animal
|
model = Animal
|
||||||
|
@@ -1,8 +1,15 @@
|
|||||||
{% extends "fellchensammlung/base_generic.html" %}
|
{% extends "fellchensammlung/base_bulma.html" %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% load crispy_forms_tags %}
|
{% load widget_tweaks %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>{% translate "Vermittlungsanzeige" %}</h1>
|
<h1>{{ form.name.data }}</h1>
|
||||||
{% crispy form %}
|
<form method="post" enctype="multipart/form-data">
|
||||||
|
{% csrf_token %}
|
||||||
|
|
||||||
|
{{ form }}
|
||||||
|
<input class="button is-primary" type="submit" value="{% translate "Speichern" %}">
|
||||||
|
|
||||||
|
<a class="button is-danger">{% translate "Löschen" %}</a>
|
||||||
|
</form>
|
||||||
{% endblock %}
|
{% endblock %}
|
@@ -515,7 +515,8 @@ def animal_edit(request, animal_id):
|
|||||||
"""Log"""
|
"""Log"""
|
||||||
Log.objects.create(user=request.user, action="add_photo_to_animal",
|
Log.objects.create(user=request.user, action="add_photo_to_animal",
|
||||||
text=f"{request.user} hat Tier {animal.pk} zum Tier geändert")
|
text=f"{request.user} hat Tier {animal.pk} zum Tier geändert")
|
||||||
return redirect(reverse("adoption-notice-detail", args=[animal.adoption_notice.pk], ))
|
print(reverse("adoption-notice-detail", args=[animal.adoption_notice.pk], ))
|
||||||
|
return redirect(reverse("adoption-notice-detail-bulma", args=[animal.adoption_notice.pk], ))
|
||||||
else:
|
else:
|
||||||
form = AnimalForm(instance=animal)
|
form = AnimalForm(instance=animal)
|
||||||
return render(request, 'fellchensammlung/forms/form-adoption-notice.html', context={"form": form})
|
return render(request, 'fellchensammlung/forms/form-adoption-notice.html', context={"form": form})
|
||||||
|
Reference in New Issue
Block a user