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;
}
/* TODO: https://git.eleves.ens.fr/klub-dev-ens/authens/issues/9 */
.oldcas {
background: #CB6318;
color: white;
}
form {
.auth_form {
padding: 0.5em;
text-align: center;
width: 100%;
@ -58,7 +57,7 @@ form {
text-align: center;
}
form table {
.auth_form table {
margin: 20px auto;
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 %}
<h2>{% if request.site.name %}{{ request.site.name }}{% else %}AuthENS{% endif %} - {% trans "Connexion vieilleux" %}</h2>
{% if form.errors %}
<p class="error">{% trans "Login CAS, promotion et/ou mot de passe incorrect" %}</p>
{% endif %}
{% for error in form.non_field_errors %}
<p class="error">{{ error }}</p>
{% endfor %}
<form class="oldcas" method="post" action="">
{% csrf_token %}
<table>
<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>
<div class=" auth_form oldcas">
{% include "authens/form_full_snippet.html" with submit_text="Se connecter" %}
</div>
{% endblock %}

View file

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