From f4575ec75903eca62afac242288c7667058ca1d7 Mon Sep 17 00:00:00 2001 From: Kumi Date: Sun, 23 Jun 2024 09:36:28 +0200 Subject: [PATCH] feat: enhance forms with crispy-forms and Bootstrap5 Improved the user interface of various forms by integrating django-crispy-forms and crispy-bootstrap5. Updated form templates to use crispy forms for better styling and layout consistency. Removed the standalone login template in favor of using email-based login flow. Benefits include: - Enhanced form layout and styling using Bootstrap 5. - Improved user experience with clearer instructions and polished designs. Additionally, updated settings to include crispy forms and Bootstrap 5 template pack. --- freedoi/accounts/templates/accounts/login.html | 10 ---------- .../accounts/templates/accounts/send_login_email.html | 10 +++++++--- .../resolver/templates/resolver/identifier_form.html | 4 ++-- freedoi/resolver/templates/resolver/prefix_form.html | 4 ++-- freedoi/resolver/templates/resolver/suffix_form.html | 10 +++++++--- freedoi/settings.py | 6 ++++++ 6 files changed, 24 insertions(+), 20 deletions(-) delete mode 100644 freedoi/accounts/templates/accounts/login.html diff --git a/freedoi/accounts/templates/accounts/login.html b/freedoi/accounts/templates/accounts/login.html deleted file mode 100644 index 3c34f9d..0000000 --- a/freedoi/accounts/templates/accounts/login.html +++ /dev/null @@ -1,10 +0,0 @@ -{% extends "base_generic.html" %} {% block title %}Login{% endblock %} -{% block content %} -
-

Login

-
- {% csrf_token %} {{ form.as_p }} - -
-
-{% endblock %} diff --git a/freedoi/accounts/templates/accounts/send_login_email.html b/freedoi/accounts/templates/accounts/send_login_email.html index b6c911f..f749826 100644 --- a/freedoi/accounts/templates/accounts/send_login_email.html +++ b/freedoi/accounts/templates/accounts/send_login_email.html @@ -1,9 +1,13 @@ {% extends "base_generic.html" %} {% block title %}Email Login{% endblock %} -{% block content %} +{% block content %}{% load crispy_forms_tags %}
-

Email Login

+

Login

+

Please login to access FreeDOI. If you don't have an + account yet, one will be created for you.

- {% csrf_token %} {{ form.as_p }} + {% csrf_token %} {{ form | crispy }} +

We will send you an email with a link to login. + By submitting this form, you agree to our Privacy Policy.

diff --git a/freedoi/resolver/templates/resolver/identifier_form.html b/freedoi/resolver/templates/resolver/identifier_form.html index 6c3614c..c5d7564 100644 --- a/freedoi/resolver/templates/resolver/identifier_form.html +++ b/freedoi/resolver/templates/resolver/identifier_form.html @@ -1,10 +1,10 @@ {% extends "base_generic.html" %} {% block title %} {% if form.instance.pk %}Edit{% else %}Create{% endif %} Identifier -{% endblock %} {% block content %} +{% endblock %} {% load crispy_forms_tags %} {% block content %}

{% if form.instance.pk %}Edit{% else %}Create{% endif %} Identifier

- {% csrf_token %} {{ form.as_p }} + {% csrf_token %} {{ form | crispy }}
{% if form.instance.pk %}Edit{% else %}Create{% endif %} Prefix
- {% csrf_token %} {{ form.as_p }} + {% csrf_token %} {{ form | crispy }}
Back to list diff --git a/freedoi/resolver/templates/resolver/suffix_form.html b/freedoi/resolver/templates/resolver/suffix_form.html index 2881004..1085748 100644 --- a/freedoi/resolver/templates/resolver/suffix_form.html +++ b/freedoi/resolver/templates/resolver/suffix_form.html @@ -1,10 +1,14 @@ {% extends "base_generic.html" %} {% block title %} -{% if form.instance.pk %}Edit{% else %}Create{% endif %} Suffix{% endblock %} -{% block content %} +{% if form.instance.pk %}Edit{% else %}Request{% endif %} Suffix{% endblock %} +{% load crispy_forms_tags %}{% block content %}

{% if form.instance.pk %}Edit{% else %}Create{% endif %} Suffix

- {% csrf_token %} {{ form.as_p }} + {% csrf_token %} {{ form | crispy }} +

Please make sure to include a full description of + your intended use of the suffix in the "Description" field. Your request + may be rejected if this information is not provided, or if the selected + prefix is not appropriate for your intended use.

Back to list diff --git a/freedoi/settings.py b/freedoi/settings.py index cf259d9..595b4e7 100644 --- a/freedoi/settings.py +++ b/freedoi/settings.py @@ -32,6 +32,8 @@ INSTALLED_APPS = [ "django_otp", "django_otp.plugins.otp_totp", "two_factor", + "crispy_forms", + "crispy_bootstrap5", ] MIDDLEWARE = [ @@ -144,3 +146,7 @@ STATIC_URL = "static/" # https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" + +# Crispy Forms + +CRISPY_TEMPLATE_PACK = "bootstrap5" \ No newline at end of file