feat: Manually craft the add adoption form to work with bulma
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
93ffbe09af
commit
88987a973e
@ -297,11 +297,13 @@ class AdoptionNotice(models.Model):
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
last_checked = models.DateTimeField(verbose_name=_('Zuletzt überprüft am'), default=timezone.now)
|
||||
searching_since = models.DateField(verbose_name=_('Sucht nach einem Zuhause seit'))
|
||||
name = models.CharField(max_length=200)
|
||||
name = models.CharField(max_length=200, verbose_name=_('Titel der Vermittlung'))
|
||||
description = models.TextField(null=True, blank=True, verbose_name=_('Beschreibung'))
|
||||
organization = models.ForeignKey(RescueOrganization, blank=True, null=True, on_delete=models.SET_NULL,
|
||||
verbose_name=_('Organisation'))
|
||||
further_information = models.URLField(null=True, blank=True, verbose_name=_('Link zu mehr Informationen'))
|
||||
further_information = models.URLField(null=True, blank=True,
|
||||
verbose_name=_('Link zu mehr Informationen'),
|
||||
help_text=_("Verlinke hier die Quelle der Vermittlung (z.B. die Website des Tierheims"))
|
||||
group_only = models.BooleanField(default=False, verbose_name=_('Ausschließlich Gruppenadoption'))
|
||||
photos = models.ManyToManyField(Image, blank=True)
|
||||
location_string = models.CharField(max_length=200, verbose_name=_("Ortsangabe"))
|
||||
|
@ -1,6 +1,7 @@
|
||||
{% extends "fellchensammlung/base_bulma.html" %}
|
||||
{% load i18n %}
|
||||
{% load crispy_forms_tags %}
|
||||
{% load widget_tweaks %}
|
||||
|
||||
{% block title %}<title>{% translate "Vermittlung hinzufügen" %}</title>{% endblock %}
|
||||
|
||||
@ -12,17 +13,83 @@
|
||||
{% url 'terms-of-service' as rules_url %}
|
||||
{% trans "Regeln" as rules_text %}
|
||||
{% blocktranslate with rules_link='<a href="'|add:rules_url|add:'">'|add:rules_text|add:'</a>'|safe %}
|
||||
Bitte mach dich zunächst mit unseren {{ rules_link }} vertraut. Dann trage hier die ersten Informationen ein.
|
||||
Wenn du Details und Fotos zu den Tieren hinzufügen willst oder ihr Geschlecht und Geburtsdatum anpassen
|
||||
willst,
|
||||
kannst du das im nächsten Schritt tun.
|
||||
Bitte mach dich zunächst mit unseren {{ rules_link }} vertraut. Dann trage hier die ersten Informationen
|
||||
ein.
|
||||
Fotos kannst du im nächsten Schritt hinzufügen.
|
||||
{% endblocktranslate %}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
{% csrf_token %}
|
||||
{{ form }}
|
||||
<button class="button is-primary" type="submit">{% translate "Speichern" %}</button>
|
||||
|
||||
<div class="field">
|
||||
<label class="label" for="an-name">{{ form.name.label }}
|
||||
{% if form.name.field.required %}<span class="special_class">*</span>{% endif %}</label>
|
||||
{{ form.name|add_class:"input"|attr:"id:an-name" }}
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label class="label" for="an-description">{% translate 'Beschreibung' %}</label>
|
||||
{{ form.description|add_class:"input textarea"|attr:"rows:3"|attr:"id:an-description" }}
|
||||
</div>
|
||||
|
||||
|
||||
<div class="field">
|
||||
<label class="label" for="an-location">{{ form.location_string.label }}</label>
|
||||
{{ form.location_string|add_class:"input"|attr:"id:an-location" }}
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label class="checkbox" for="an-group-only">{{ form.group_only.label }}</label>
|
||||
{{ form.group_only|add_class:"checkbox"|attr:"id:an-group-only" }}
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label class="label" for="an-searching-since">{{ form.searching_since.label }}</label>
|
||||
{{ form.searching_since|add_class:"input"|attr:"id:an-searching-since"|attr:"type:date" }}
|
||||
</div>
|
||||
|
||||
<div class="notification">
|
||||
<button class="delete"></button>
|
||||
<p>
|
||||
|
||||
{% blocktranslate %}
|
||||
Gibt hier schonmal erste Details zu den Tieren an.
|
||||
Wenn du Details und Fotos zu den Tieren hinzufügen willst oder ihr Geschlecht und Geburtsdatum
|
||||
anpassen
|
||||
willst,
|
||||
kannst du das im nächsten Schritt tun.
|
||||
{% endblocktranslate %}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label class="label" for="an-species">{% translate 'Tierart' %}</label>
|
||||
<div class="select">
|
||||
{{ form.species|attr:"id:an-species" }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="field">
|
||||
<label class="label" for="an-num-animals">{{ form.num_animals.label }}</label>
|
||||
{{ form.num_animals|add_class:"input"|attr:"id:an-num-animals" }}
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label class="label" for="an-sex">{% translate 'Geschlecht' %}</label>
|
||||
<div class="select">
|
||||
{{ form.sex|attr:"id:an-sex" }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label class="label" for="an-date-of-birth">{{ form.date_of_birth.label }}</label>
|
||||
{{ form.date_of_birth|add_class:"input"|attr:"id:an-date-of-birth"|attr:"type:date" }}
|
||||
</div>
|
||||
|
||||
|
||||
<input class="button is-primary" type="submit" value="{% translate "Speichern" %}">
|
||||
</form>
|
||||
{% endblock %}
|
@ -314,9 +314,11 @@ def add_adoption_notice(request):
|
||||
@login_required
|
||||
def add_adoption_notice_bulma(request):
|
||||
if request.method == 'POST':
|
||||
form = BulmaAdoptionNoticeForm(request.POST)
|
||||
print("dada")
|
||||
form = AdoptionNoticeFormWithDateWidgetAutoAnimal(request.POST)
|
||||
|
||||
if form.is_valid():
|
||||
print("dodo")
|
||||
an_instance = form.save(commit=False)
|
||||
an_instance.owner = request.user
|
||||
|
||||
@ -346,9 +348,11 @@ def add_adoption_notice_bulma(request):
|
||||
# Automatically subscribe user that created AN to AN
|
||||
Subscriptions.objects.create(owner=request.user, adoption_notice=an_instance)
|
||||
|
||||
return redirect(reverse("adoption-notice-detail", args=[an_instance.pk]))
|
||||
return redirect(reverse("adoption-notice-detail-bulma", args=[an_instance.pk]))
|
||||
else:
|
||||
print(form.errors)
|
||||
else:
|
||||
form = BulmaAdoptionNoticeForm()
|
||||
form = AdoptionNoticeFormWithDateWidgetAutoAnimal()
|
||||
return render(request, 'fellchensammlung/forms/bulma-form-add-adoption.html', {'form': form})
|
||||
|
||||
|
||||
|
@ -176,6 +176,7 @@ INSTALLED_APPS = [
|
||||
'rest_framework.authtoken',
|
||||
'drf_spectacular',
|
||||
'drf_spectacular_sidecar', # required for Django collectstatic discovery
|
||||
'widget_tweaks'
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
|
Loading…
x
Reference in New Issue
Block a user