mirror of
https://framagit.org/la-chariotte/la-chariotte.git
synced 2025-05-03 12:21:52 +02:00
feat: use django crispy-forms
This commit is contained in:
parent
d35a411f78
commit
6b7e080861
7 changed files with 86 additions and 65 deletions
|
@ -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 import forms
|
||||||
from django.contrib.auth.forms import UserChangeForm, UserCreationForm
|
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 CustomUserChangeForm(UserChangeForm): # pas encore utilisé - pour la V1
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
|
@ -1,21 +1,29 @@
|
||||||
{% extends 'base.html' %}
|
{% extends 'base.html' %}
|
||||||
|
{% load crispy_forms_tags %}
|
||||||
{% block title %}Connexion{% endblock %}
|
{% block title %}Connexion{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<p class="desktop-hidden mobile-content-title">
|
<p class="desktop-hidden mobile-content-title">
|
||||||
{% block content_title %}Connexion{% endblock %}
|
{% block content_title %}Connexion{% endblock %}
|
||||||
</p>
|
</p>
|
||||||
<div class="box">
|
<div class="box">
|
||||||
|
<div class="columns is-flex is-flex-direction-column">
|
||||||
<form method="post">
|
<form method="post">
|
||||||
{% csrf_token %}
|
<div class="column">
|
||||||
{{ form.as_p }}
|
{{ form | crispy }}
|
||||||
<a href="{% url 'accounts:password_reset' %}">Mot de passe oublié ?</a>
|
<a href="{% url 'accounts:password_reset' %}"
|
||||||
<div class="buttons">
|
class="is-size-7 has-text-primary">Mot de passe oublié ?</a>
|
||||||
|
</div>
|
||||||
|
<div class="column">
|
||||||
<button class="button is-primary" type="submit">Se connecter</button>
|
<button class="button is-primary" type="submit">Se connecter</button>
|
||||||
<a href="{% url 'accounts:signup' %}">Créer un compte</a>
|
</div>
|
||||||
|
<div class="has-text-centered">
|
||||||
|
<p class="is-size-7">
|
||||||
|
Pas de compte ? <a href="{% url 'accounts:signup' %}" class="has-text-primary">Créez en un !</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
{% csrf_token %}
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -1,25 +1,25 @@
|
||||||
{% extends 'base.html' %}
|
{% extends 'base.html' %}
|
||||||
|
{% load crispy_forms_tags %}
|
||||||
{% block title %}Nouveau mot de passe{% endblock %}
|
{% block title %}Nouveau mot de passe{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<p class="desktop-hidden mobile-content-title">
|
<p class="desktop-hidden mobile-content-title">
|
||||||
{% block content_title %}Nouveau mot de passe{% endblock %}
|
{% block content_title %}Nouveau mot de passe{% endblock %}
|
||||||
</p>
|
</p>
|
||||||
<div class="box">
|
<div class="box">
|
||||||
{% if validlink %}
|
{% if validlink %}
|
||||||
|
|
||||||
<form method="POST">
|
<form method="POST">
|
||||||
<p>Veuillez entrer un nouveau mot de passe tout neuf.</p>
|
<p>Veuillez entrer un nouveau mot de passe tout neuf.</p>
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ form.as_p }}
|
{% crispy form %}
|
||||||
<input class="button is-primary" type="submit" value="Changer le mot de passe">
|
<input class="button is-primary"
|
||||||
|
type="submit"
|
||||||
|
value="Changer le mot de passe">
|
||||||
</form>
|
</form>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
<p>
|
||||||
<p>Le lien de réinitialisation du mot de passe est invalide, probablement parce qu'il a déjà été utilisé.
|
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.</p>
|
Veuillez demander une nouvelle réinitialisation.
|
||||||
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -1,7 +1,6 @@
|
||||||
{% extends 'base.html' %}
|
{% extends 'base.html' %}
|
||||||
|
{% load crispy_forms_tags %}
|
||||||
{% block title %}Mot de passe oublié ?{% endblock %}
|
{% block title %}Mot de passe oublié ?{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<p class="desktop-hidden mobile-content-title">
|
<p class="desktop-hidden mobile-content-title">
|
||||||
{% block content_title %}Mot de passe oublié ?{% endblock %}
|
{% block content_title %}Mot de passe oublié ?{% endblock %}
|
||||||
|
@ -9,9 +8,10 @@
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<form method="POST">
|
<form method="POST">
|
||||||
<p>Entrez votre mail pour recevoir les instructions pour le réinitialiser.</p>
|
<p>Entrez votre mail pour recevoir les instructions pour le réinitialiser.</p>
|
||||||
{% csrf_token %}
|
{% crispy form %}
|
||||||
{{ form.as_p }}
|
<div class="buttons">
|
||||||
<input class="button is-primary" type="submit" value="Envoyer">
|
<input class="button is-primary" type="submit" value="Envoyer">
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -1,17 +1,9 @@
|
||||||
{% extends 'base.html' %}
|
{% extends 'base.html' %}
|
||||||
|
{% load crispy_forms_tags %}
|
||||||
{% block title %}Créer un compte{% endblock %}
|
{% block title %}Créer un compte{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<p class="desktop-hidden mobile-content-title">
|
<p class="desktop-hidden mobile-content-title">
|
||||||
{% block content_title %}Créer un compte{% endblock %}
|
{% block content_title %}Créer un compte{% endblock %}
|
||||||
</p>
|
</p>
|
||||||
<div class="box">
|
<div class="box">{% crispy form %}</div>
|
||||||
<form method="post">
|
|
||||||
{% csrf_token %}
|
|
||||||
{{ form.as_p }}
|
|
||||||
<button class="button is-primary" type="submit">Valider</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -34,6 +34,8 @@ INSTALLED_APPS = [
|
||||||
"django.contrib.sessions",
|
"django.contrib.sessions",
|
||||||
"django.contrib.messages",
|
"django.contrib.messages",
|
||||||
"django.contrib.staticfiles",
|
"django.contrib.staticfiles",
|
||||||
|
"crispy_forms",
|
||||||
|
"crispy_bulma",
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
|
@ -69,6 +71,9 @@ TEMPLATES = [
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
CRISPY_ALLOWED_TEMPLATE_PACKS = ("bulma",)
|
||||||
|
CRISPY_TEMPLATE_PACK = "bulma"
|
||||||
|
|
||||||
WSGI_APPLICATION = "la_chariotte.wsgi.application"
|
WSGI_APPLICATION = "la_chariotte.wsgi.application"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,8 @@ dependencies = [
|
||||||
"django-weasyprint==1.1.0.post1", # see below
|
"django-weasyprint==1.1.0.post1", # see below
|
||||||
"weasyprint==52.5", # pin weasyprint to not depend on latest libpango
|
"weasyprint==52.5", # pin weasyprint to not depend on latest libpango
|
||||||
"html2text>=2020.1.16",
|
"html2text>=2020.1.16",
|
||||||
|
"django-crispy-forms>=2.0,<3",
|
||||||
|
"crispy-bulma>=0.11.0,<1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[tool.setuptools]
|
[tool.setuptools]
|
||||||
|
|
Loading…
Reference in a new issue