feat: Re-add option to add animal
This commit is contained in:
@@ -34,7 +34,6 @@ class AdoptionNoticeForm(forms.ModelForm):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class AdoptionNoticeFormAutoAnimal(AdoptionNoticeForm):
|
class AdoptionNoticeFormAutoAnimal(AdoptionNoticeForm):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(AdoptionNoticeFormAutoAnimal, self).__init__(*args, **kwargs)
|
super(AdoptionNoticeFormAutoAnimal, self).__init__(*args, **kwargs)
|
||||||
@@ -46,7 +45,6 @@ class AdoptionNoticeFormAutoAnimal(AdoptionNoticeForm):
|
|||||||
self.fields["date_of_birth"].widget = DateInput(format=('%Y-%m-%d'))
|
self.fields["date_of_birth"].widget = DateInput(format=('%Y-%m-%d'))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class AnimalForm(forms.ModelForm):
|
class AnimalForm(forms.ModelForm):
|
||||||
template_name = "fellchensammlung/forms/form_snippets.html"
|
template_name = "fellchensammlung/forms/form_snippets.html"
|
||||||
|
|
||||||
@@ -93,6 +91,7 @@ class ImageForm(forms.ModelForm):
|
|||||||
|
|
||||||
class ReportAdoptionNoticeForm(forms.ModelForm):
|
class ReportAdoptionNoticeForm(forms.ModelForm):
|
||||||
template_name = "fellchensammlung/forms/form_snippets.html"
|
template_name = "fellchensammlung/forms/form_snippets.html"
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = ReportAdoptionNotice
|
model = ReportAdoptionNotice
|
||||||
fields = ('reported_broken_rules', 'user_comment')
|
fields = ('reported_broken_rules', 'user_comment')
|
||||||
@@ -100,6 +99,7 @@ class ReportAdoptionNoticeForm(forms.ModelForm):
|
|||||||
|
|
||||||
class ReportCommentForm(forms.ModelForm):
|
class ReportCommentForm(forms.ModelForm):
|
||||||
template_name = "fellchensammlung/forms/form_snippets.html"
|
template_name = "fellchensammlung/forms/form_snippets.html"
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = ReportComment
|
model = ReportComment
|
||||||
fields = ('reported_broken_rules', 'user_comment')
|
fields = ('reported_broken_rules', 'user_comment')
|
||||||
|
@@ -1,13 +1,17 @@
|
|||||||
{% extends "fellchensammlung/base_generic.html" %}
|
{% extends "fellchensammlung/base_bulma.html" %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% load crispy_forms_tags %}
|
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>{% translate "Vermitteln" %}</h1>
|
<h1>{% translate "Tiere hinzufügen" %}</h1>
|
||||||
{% blocktranslate %}
|
{% blocktranslate %}
|
||||||
Hier kannst du jetzt einzelne Tiere zu deiner Vermittlung hinzufügen. Lad auch gerne Fotos hoch. Gruppenfotos
|
Hier kannst du jetzt einzelne Tiere zu deiner Vermittlung hinzufügen.
|
||||||
kannst
|
|
||||||
du im nächsten Schritt hochladen.
|
|
||||||
{% endblocktranslate %}
|
{% endblocktranslate %}
|
||||||
{% crispy form %}
|
|
||||||
|
<form method="POST">
|
||||||
|
{% csrf_token %}
|
||||||
|
{{ form }}
|
||||||
|
<input class="button is-primary is-light" type="submit" value="{% translate "Speichern" %}">
|
||||||
|
<input class="button is-primary" type="submit" name="save-and-add-another-animal" value="{% translate "Speichern und weiteres Tier hinzufügen" %}">
|
||||||
|
</form>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
@@ -289,7 +289,7 @@ def adoption_notice_add_animal(request, adoption_notice_id):
|
|||||||
adoption_notice = AdoptionNotice.objects.get(pk=adoption_notice_id)
|
adoption_notice = AdoptionNotice.objects.get(pk=adoption_notice_id)
|
||||||
fail_if_user_not_owner_or_trust_level(request.user, adoption_notice)
|
fail_if_user_not_owner_or_trust_level(request.user, adoption_notice)
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
form = AnimalFormWithDateWidget(request.POST, request.FILES)
|
form = AnimalForm(request.POST, request.FILES)
|
||||||
|
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
instance = form.save(commit=False)
|
instance = form.save(commit=False)
|
||||||
@@ -298,12 +298,12 @@ def adoption_notice_add_animal(request, adoption_notice_id):
|
|||||||
instance.save()
|
instance.save()
|
||||||
form.save_m2m()
|
form.save_m2m()
|
||||||
if "save-and-add-another-animal" in request.POST:
|
if "save-and-add-another-animal" in request.POST:
|
||||||
form = AnimalFormWithDateWidget(in_adoption_notice_creation_flow=True)
|
form = AnimalForm()
|
||||||
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})
|
||||||
else:
|
else:
|
||||||
return redirect(reverse("adoption-notice-detail", args=[adoption_notice_id]))
|
return redirect(reverse("adoption-notice-detail", args=[adoption_notice_id]))
|
||||||
else:
|
else:
|
||||||
form = AnimalFormWithDateWidget(in_adoption_notice_creation_flow=True)
|
form = AnimalForm()
|
||||||
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})
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user