mirror of
https://framagit.org/la-chariotte/la-chariotte.git
synced 2025-05-02 11:52:27 +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.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:
|
||||
|
|
|
@ -1,21 +1,29 @@
|
|||
{% extends 'base.html' %}
|
||||
|
||||
{% load crispy_forms_tags %}
|
||||
{% block title %}Connexion{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<p class="desktop-hidden mobile-content-title">
|
||||
{% block content_title %}Connexion{% endblock %}
|
||||
</p>
|
||||
<div class="box">
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
<a href="{% url 'accounts:password_reset' %}">Mot de passe oublié ?</a>
|
||||
<div class="buttons">
|
||||
<button class="button is-primary" type="submit">Se connecter</button>
|
||||
<a href="{% url 'accounts:signup' %}">Créer un compte</a>
|
||||
<p class="desktop-hidden mobile-content-title">
|
||||
{% block content_title %}Connexion{% endblock %}
|
||||
</p>
|
||||
<div class="box">
|
||||
<div class="columns is-flex is-flex-direction-column">
|
||||
<form method="post">
|
||||
<div class="column">
|
||||
{{ form | crispy }}
|
||||
<a href="{% url 'accounts:password_reset' %}"
|
||||
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>
|
||||
</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>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
{% extends 'base.html' %}
|
||||
|
||||
{% load crispy_forms_tags %}
|
||||
{% block title %}Nouveau mot de passe{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<p class="desktop-hidden mobile-content-title">
|
||||
{% block content_title %}Nouveau mot de passe{% endblock %}
|
||||
</p>
|
||||
<div class="box">
|
||||
{% if validlink %}
|
||||
|
||||
<form method="POST">
|
||||
<p>Veuillez entrer un nouveau mot de passe tout neuf.</p>
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
<input class="button is-primary" type="submit" value="Changer le mot de passe">
|
||||
</form>
|
||||
{% else %}
|
||||
|
||||
<p>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>
|
||||
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
<p class="desktop-hidden mobile-content-title">
|
||||
{% block content_title %}Nouveau mot de passe{% endblock %}
|
||||
</p>
|
||||
<div class="box">
|
||||
{% if validlink %}
|
||||
<form method="POST">
|
||||
<p>Veuillez entrer un nouveau mot de passe tout neuf.</p>
|
||||
{% csrf_token %}
|
||||
{% crispy form %}
|
||||
<input class="button is-primary"
|
||||
type="submit"
|
||||
value="Changer le mot de passe">
|
||||
</form>
|
||||
{% else %}
|
||||
<p>
|
||||
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>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
{% extends 'base.html' %}
|
||||
|
||||
{% load crispy_forms_tags %}
|
||||
{% block title %}Mot de passe oublié ?{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<p class="desktop-hidden mobile-content-title">
|
||||
{% block content_title %}Mot de passe oublié ?{% endblock %}
|
||||
</p>
|
||||
<div class="box">
|
||||
<form method="POST">
|
||||
<p>Entrez votre mail pour recevoir les instructions pour le réinitialiser.</p>
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
<input class="button is-primary" type="submit" value="Envoyer">
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
||||
<p class="desktop-hidden mobile-content-title">
|
||||
{% block content_title %}Mot de passe oublié ?{% endblock %}
|
||||
</p>
|
||||
<div class="box">
|
||||
<form method="POST">
|
||||
<p>Entrez votre mail pour recevoir les instructions pour le réinitialiser.</p>
|
||||
{% crispy form %}
|
||||
<div class="buttons">
|
||||
<input class="button is-primary" type="submit" value="Envoyer">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,17 +1,9 @@
|
|||
{% extends 'base.html' %}
|
||||
|
||||
{% load crispy_forms_tags %}
|
||||
{% block title %}Créer un compte{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<p class="desktop-hidden mobile-content-title">
|
||||
{% block content_title %}Créer un compte{% endblock %}
|
||||
</p>
|
||||
<div class="box">
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
<button class="button is-primary" type="submit">Valider</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
<p class="desktop-hidden mobile-content-title">
|
||||
{% block content_title %}Créer un compte{% endblock %}
|
||||
</p>
|
||||
<div class="box">{% crispy form %}</div>
|
||||
{% endblock %}
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
||||
|
|
|
@ -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]
|
||||
|
|
Loading…
Reference in a new issue