From d7cf051a164ff960ae7bf97c75d1889eb6c761b2 Mon Sep 17 00:00:00 2001 From: moanos Date: Sat, 3 Aug 2024 09:40:53 +0200 Subject: [PATCH] feat: make regirstration form nicer --- src/fellchensammlung/forms.py | 8 ++++++++ .../static/fellchensammlung/css/styles.css | 2 +- .../django_registration/registration_form.html | 16 ++++++---------- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/fellchensammlung/forms.py b/src/fellchensammlung/forms.py index e2da1f2..5c5c836 100644 --- a/src/fellchensammlung/forms.py +++ b/src/fellchensammlung/forms.py @@ -145,6 +145,14 @@ class CustomRegistrationForm(RegistrationForm): class Meta(RegistrationForm.Meta): model = User + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.helper = FormHelper() + self.helper.form_id = 'form-registration' + self.helper.form_class = 'card' + + self.helper.add_input(Submit('submit', _('Registrieren'), css_class="btn")) + def _get_distances(): return {i: i for i in [10, 20, 50, 100, 200, 500]} diff --git a/src/fellchensammlung/static/fellchensammlung/css/styles.css b/src/fellchensammlung/static/fellchensammlung/css/styles.css index 88f6722..f5ee3e4 100644 --- a/src/fellchensammlung/static/fellchensammlung/css/styles.css +++ b/src/fellchensammlung/static/fellchensammlung/css/styles.css @@ -453,7 +453,7 @@ select, .button { padding: 5px; } -#form-adoption-notice { +#form-adoption-notice, #form-registration { .form-group { margin: 30px; } diff --git a/src/templates/django_registration/registration_form.html b/src/templates/django_registration/registration_form.html index 84f6362..0052ac7 100644 --- a/src/templates/django_registration/registration_form.html +++ b/src/templates/django_registration/registration_form.html @@ -1,15 +1,11 @@ {% extends "fellchensammlung/base_generic.html" %} {% load i18n %} +{% load crispy_forms_tags %} {% block content %} -{% if not user.is_authenticated %} -
- {% csrf_token %} - {{ form.as_p }} - - -
-{% else %} -

{% translate "Du bist bereits eingeloggt." %}

-{% endif %} + {% if not user.is_authenticated %} + {% crispy form %} + {% else %} +

{% translate "Du bist bereits eingeloggt." %}

+ {% endif %} {% endblock %} \ No newline at end of file