Factor out forms + small changes

This commit is contained in:
Ludovic Stephan 2020-06-25 16:25:10 +02:00
parent bf99e93cf1
commit b41bbb4188
7 changed files with 38 additions and 40 deletions

View file

@ -35,13 +35,12 @@ h2 {
color: white; color: white;
} }
/* TODO: https://git.eleves.ens.fr/klub-dev-ens/authens/issues/9 */
.oldcas { .oldcas {
background: #CB6318; background: #CB6318;
color: white; color: white;
} }
form { .auth_form {
padding: 0.5em; padding: 0.5em;
text-align: center; text-align: center;
width: 100%; width: 100%;
@ -58,7 +57,7 @@ form {
text-align: center; text-align: center;
} }
form table { .auth_form table {
margin: 20px auto; margin: 20px auto;
border-spacing: 0.3em; border-spacing: 0.3em;
} }

View file

@ -0,0 +1,4 @@
<tr>
<th>{{ field.label_tag }}</th>
<td>{{ field }}</td>
</tr>

View file

@ -0,0 +1,4 @@
<tr>
<th>{{ field.label_tag }}</th>
<td>{{ field }} {{ field.errors }}</td>
</tr>

View file

@ -0,0 +1,8 @@
{% load i18n %}
<form action="" method="post">
{% csrf_token %}
{% include "authens/form_snippet.html" %}
<input type="submit" value="{% trans submit_text %}">
</form>

View file

@ -0,0 +1,7 @@
<table>
<tbody>
{% for field in form %}
{% include 'authens/form_field_snippet.html' with field=field %}
{% endfor %}
</tbody>
</table>

View file

@ -4,24 +4,12 @@
{% block content %} {% block content %}
<h2>{% if request.site.name %}{{ request.site.name }}{% else %}AuthENS{% endif %} - {% trans "Connexion vieilleux" %}</h2> <h2>{% if request.site.name %}{{ request.site.name }}{% else %}AuthENS{% endif %} - {% trans "Connexion vieilleux" %}</h2>
{% if form.errors %} {% for error in form.non_field_errors %}
<p class="error">{% trans "Login CAS, promotion et/ou mot de passe incorrect" %}</p> <p class="error">{{ error }}</p>
{% endif %} {% endfor %}
<form class="oldcas" method="post" action=""> <div class=" auth_form oldcas">
{% csrf_token %} {% include "authens/form_full_snippet.html" with submit_text="Se connecter" %}
<table> </div>
<tbody>
{% for field in form %}
<tr>
<th>{{ field.label_tag }}</th>
<td>{{ field }}</td>
</tr>
{% endfor %}
</tbody>
</table>
<input type="submit" value="{% trans "Se connecter" %}">
<input type="hidden" name="next" value="{{ next }}">
</form>
{% endblock %} {% endblock %}

View file

@ -4,23 +4,11 @@
{% block content %} {% block content %}
<h2>{% if request.site.name %}{{ request.site.name }}{% else %}AuthENS{% endif %} - {% trans "Connexion par mot de passe" %}</h2> <h2>{% if request.site.name %}{{ request.site.name }}{% else %}AuthENS{% endif %} - {% trans "Connexion par mot de passe" %}</h2>
{% if form.errors %} {% for error in form.non_field_errors %}
<p class="error">{% trans "Nom d'utilisateur et/ou mot de passe incorrect" %}</p> <p class="error">{{ error }}</p>
{% endif %} {% endfor %}
<form class="exte" method="post" action="{% url 'authens:login.pwd' %}"> <div class=" auth_form exte">
{% csrf_token %} {% include "authens/form_full_snippet.html" with submit_text="Se connecter" %}
<table> </div>
<tbody> {% endblock %}
{% for field in form %}
<tr>
<th>{{ field.label_tag }}</th>
<td>{{ field }}</td>
</tr>
{% endfor %}
</tbody>
</table>
<input type="submit" value="{% trans "Se connecter" %}">
<input type="hidden" name="next" value="{{ next }}">
</form>
{% endblock %}