diff --git a/la_chariotte/accounts/forms.py b/la_chariotte/accounts/forms.py index 8a6d0ca..b6466c9 100644 --- a/la_chariotte/accounts/forms.py +++ b/la_chariotte/accounts/forms.py @@ -1,3 +1,6 @@ +from crispy_bulma.layout import Submit +from crispy_forms.helper import FormHelper +from crispy_forms.layout import Layout from django import forms from django.contrib.auth.forms import UserChangeForm, UserCreationForm @@ -16,6 +19,17 @@ class CustomUserCreationForm(UserCreationForm): ), } + helper = FormHelper() + helper.form_class = "form-horizontal" + helper.layout = Layout( + "username", + "first_name", + "last_name", + "password1", + "password2", + Submit("submit", "Valider", css_class="is-primary"), + ) + class CustomUserChangeForm(UserChangeForm): # pas encore utilisé - pour la V1 class Meta: diff --git a/la_chariotte/accounts/templates/registration/login.html b/la_chariotte/accounts/templates/registration/login.html index 63c6a03..bff4e05 100644 --- a/la_chariotte/accounts/templates/registration/login.html +++ b/la_chariotte/accounts/templates/registration/login.html @@ -1,21 +1,29 @@ {% extends 'base.html' %} - +{% load crispy_forms_tags %} {% block title %}Connexion{% endblock %} - {% block content %} -

- {% block content_title %}Connexion{% endblock %} -

-
-
- {% csrf_token %} - {{ form.as_p }} - Mot de passe oublié ? -
- - Créer un compte +

+ {% block content_title %}Connexion{% endblock %} +

+
+
+ +
+ {{ form | crispy }} + Mot de passe oublié ? +
+
+ +
+
+

+ Pas de compte ? Créez en un ! +

+
+ {% csrf_token %} +
- -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/la_chariotte/accounts/templates/registration/password_reset_confirm.html b/la_chariotte/accounts/templates/registration/password_reset_confirm.html index 79863a1..6f67cf3 100644 --- a/la_chariotte/accounts/templates/registration/password_reset_confirm.html +++ b/la_chariotte/accounts/templates/registration/password_reset_confirm.html @@ -1,25 +1,25 @@ {% extends 'base.html' %} - +{% load crispy_forms_tags %} {% block title %}Nouveau mot de passe{% endblock %} - {% block content %} -

- {% block content_title %}Nouveau mot de passe{% endblock %} -

-
- {% if validlink %} - -
-

Veuillez entrer un nouveau mot de passe tout neuf.

- {% csrf_token %} - {{ form.as_p }} - -
- {% else %} - -

Le lien de réinitialisation du mot de passe est invalide, probablement parce qu'il a déjà été utilisé. - Veuillez demander une nouvelle réinitialisation.

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

+ {% block content_title %}Nouveau mot de passe{% endblock %} +

+
+ {% if validlink %} +
+

Veuillez entrer un nouveau mot de passe tout neuf.

+ {% csrf_token %} + {% crispy form %} + +
+ {% else %} +

+ Le lien de réinitialisation du mot de passe est invalide, probablement parce qu'il a déjà été utilisé. + Veuillez demander une nouvelle réinitialisation. +

+ {% endif %} +
+{% endblock %} diff --git a/la_chariotte/accounts/templates/registration/password_reset_form.html b/la_chariotte/accounts/templates/registration/password_reset_form.html index f14ecf6..2e66624 100644 --- a/la_chariotte/accounts/templates/registration/password_reset_form.html +++ b/la_chariotte/accounts/templates/registration/password_reset_form.html @@ -1,17 +1,17 @@ {% extends 'base.html' %} - +{% load crispy_forms_tags %} {% block title %}Mot de passe oublié ?{% endblock %} - {% block content %} -

- {% block content_title %}Mot de passe oublié ?{% endblock %} -

-
-
-

Entrez votre mail pour recevoir les instructions pour le réinitialiser.

- {% csrf_token %} - {{ form.as_p }} - -
-
-{% endblock %} \ No newline at end of file +

+ {% block content_title %}Mot de passe oublié ?{% endblock %} +

+
+
+

Entrez votre mail pour recevoir les instructions pour le réinitialiser.

+ {% crispy form %} +
+ +
+
+
+{% endblock %} diff --git a/la_chariotte/accounts/templates/registration/signup.html b/la_chariotte/accounts/templates/registration/signup.html index f67232d..3bc2efc 100644 --- a/la_chariotte/accounts/templates/registration/signup.html +++ b/la_chariotte/accounts/templates/registration/signup.html @@ -1,17 +1,9 @@ {% extends 'base.html' %} - +{% load crispy_forms_tags %} {% block title %}Créer un compte{% endblock %} - {% block content %} -

- {% block content_title %}Créer un compte{% endblock %} -

-
-
- {% csrf_token %} - {{ form.as_p }} - -
-
- -{% endblock %} \ No newline at end of file +

+ {% block content_title %}Créer un compte{% endblock %} +

+
{% crispy form %}
+{% endblock %} diff --git a/la_chariotte/settings.py b/la_chariotte/settings.py index 284f5b9..844810c 100644 --- a/la_chariotte/settings.py +++ b/la_chariotte/settings.py @@ -34,6 +34,8 @@ INSTALLED_APPS = [ "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", + "crispy_forms", + "crispy_bulma", ] MIDDLEWARE = [ @@ -69,6 +71,9 @@ TEMPLATES = [ }, ] +CRISPY_ALLOWED_TEMPLATE_PACKS = ("bulma",) +CRISPY_TEMPLATE_PACK = "bulma" + WSGI_APPLICATION = "la_chariotte.wsgi.application" diff --git a/pyproject.toml b/pyproject.toml index 577cfad..e4d7dc9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,6 +17,8 @@ dependencies = [ "django-weasyprint==1.1.0.post1", # see below "weasyprint==52.5", # pin weasyprint to not depend on latest libpango "html2text>=2020.1.16", + "django-crispy-forms>=2.0,<3", + "crispy-bulma>=0.11.0,<1", ] [tool.setuptools]