From 65a921248fffd6c46052ec6027205841357d8a64 Mon Sep 17 00:00:00 2001
From: moanos
Date: Sat, 20 Apr 2024 08:06:20 +0200
Subject: [PATCH] feat: Use crispy form tag
---
src/fellchensammlung/forms.py | 13 ++++++++++++-
.../static/fellchensammlung/css/styles.css | 8 ++++++--
.../fellchensammlung/forms/form_add_adoption.html | 6 +-----
3 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/src/fellchensammlung/forms.py b/src/fellchensammlung/forms.py
index b6e7113..2a242d5 100644
--- a/src/fellchensammlung/forms.py
+++ b/src/fellchensammlung/forms.py
@@ -1,13 +1,24 @@
from django import forms
from .models import AdoptionNotice, Animal, Image, Report, ModerationAction, User
from django_registration.forms import RegistrationForm
-
+from crispy_forms.helper import FormHelper
+from crispy_forms.layout import Submit
+from django.utils.translation import gettext_lazy as _
class DateInput(forms.DateInput):
input_type = 'date'
class AdoptionNoticeForm(forms.ModelForm):
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self.helper = FormHelper()
+ self.helper.form_id = 'id-exampleForm'
+ self.helper.form_class = 'card'
+ self.helper.form_method = 'post'
+
+ self.helper.add_input(Submit('submit', _('Submit')))
+
class Meta:
model = AdoptionNotice
fields = ['name', "group_only", "further_information", "description", "searching_since"]
diff --git a/src/fellchensammlung/static/fellchensammlung/css/styles.css b/src/fellchensammlung/static/fellchensammlung/css/styles.css
index 2beea4b..fff39cb 100644
--- a/src/fellchensammlung/static/fellchensammlung/css/styles.css
+++ b/src/fellchensammlung/static/fellchensammlung/css/styles.css
@@ -135,8 +135,12 @@ h1 {
.btn {
- border: 2px solid #4090b6;
- background-color: #4ba3cd;
+ background-color: var(--primary-light-one);
+ color: var(--secondary-light-one);
+ padding: 16px;
+ border-radius: 8px;
+ border: none;
+ font-weight: bold;
}
.form-button, .link-button a:link, .link-button a:visited {
diff --git a/src/fellchensammlung/templates/fellchensammlung/forms/form_add_adoption.html b/src/fellchensammlung/templates/fellchensammlung/forms/form_add_adoption.html
index 50900e8..b6193ea 100644
--- a/src/fellchensammlung/templates/fellchensammlung/forms/form_add_adoption.html
+++ b/src/fellchensammlung/templates/fellchensammlung/forms/form_add_adoption.html
@@ -11,9 +11,5 @@
Fotos hochzuladen.
{% endblocktranslate %}
-
+ {% crispy form %}
{% endblock %}
\ No newline at end of file