Merge branch 'kerl/templates' into 'master'

Première tentative de templates

See merge request klub-dev-ens/authens!9
This commit is contained in:
Ludovic Stephan 2020-06-13 18:20:28 +02:00
commit 6e51e555f6
5 changed files with 175 additions and 52 deletions

View file

@ -0,0 +1,106 @@
html, body {
width: 100%;
background: #eee;
font-family: sans-serif;
margin: 0;
padding: 0;
}
#container {
display: flex;
flex-flow: row wrap;
padding: 10% 1em;
min-width: 300px;
max-width: 900px;
margin: auto;
}
h2 {
margin: 0;
padding: 15px;
width: 100%;
background: #505160;
color: white;
font-weight: initial;
font-size: 2em;
}
.cas {
background: #4D85BD;
color: white;
}
.exte {
background: #749F2A;
color: white;
}
/* TODO: https://git.eleves.ens.fr/klub-dev-ens/authens/issues/9 */
.oldcas {
background: #CB6318;
color: white;
}
form {
padding: 0.5em;
text-align: center;
width: 100%;
font-size: 1.5em;
}
.error {
background: red;
color: white;
width: 100%;
padding: 0.5em;
margin: 0;
font-size: 1.2em;
text-align: center;
}
form table {
margin: auto;
border-spacing: 0.3em;
}
th {
text-align: right;
}
input {
font-size: 1em;
}
input[type="text"], input[type="password"] {
border: 0;
padding: 5px;
}
input[type="submit"] {
font-size: 1.2em;
background: #505160;
color: white;
border-radius: 0.25rem;
border: solid #505160;
padding: 0.2em 0.5em;
cursor: pointer;
}
input[type="submit"]:hover {
border-color: white;
}
a {
flex: 1;
height: 200px;
min-width: 300px;
text-align: center;
font-size: 2.5em;
color: white;
line-height: 200px;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}

View file

@ -0,0 +1,21 @@
{% load static %}
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="{% static "authens/css/authens.css" %}" type="text/css">
<title>
{% if request.site.name %}{{ request.site.name }}{% else %}AuthENS{% endif %} - login
</title>
</head>
<body>
<div id="container">
{% block content %}{% endblock %}
</div>
</body>
</html>

View file

@ -1,17 +1,23 @@
{% extends "authens/base.html" %}
{% load i18n %} {% load i18n %}
<!DOCTYPE html> {% block content %}
<html> <h2>{% if request.site.name %}{{ request.site.name }}{% else %}AuthENS{% endif %} - {% trans "Mode de connexion" %}</h2>
<head> <a href="{% url "authens:login.cas" %}?next={{ next| urlencode }}">
<meta http-equiv="content-type" content="text/html; charset=utf-8"> <div class="big-button cas">
<title>ENS Auth</title> {% trans "Clipper" %}
</head> </div>
<body> </a>
<p><a href="{% url "authens:login.cas" %}?next={{ next| urlencode }}"> <a href="{% url "authens:login.pwd" %}?next={{ next| urlencode }}">
{% trans "Login par CAS" %} <div class="big-button exte">
</a></p> {% trans "Mot de passe" %}
<p><a href="{% url "authens:login.pwd" %}?next={{ next| urlencode }}"> </div>
{% trans "Login par mot de passe" %} </a>
</a></p> {% comment %} TODO: https://git.eleves.ens.fr/klub-dev-ens/authens/issues/9
</body> <a href="#TODO">
</html> <div class="big-button oldcas">
{% trans "Vieilleux" %}
</div>
</a>
{% endcomment %}
{% endblock %}

View file

@ -1,38 +1,26 @@
<!DOCTYPE html> {% extends "authens/base.html" %}
<html> {% load i18n %}
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"> {% block content %}
<title>ENS Auth</title> <h2>{% if request.site.name %}{{ request.site.name }}{% else %}AuthENS{% endif %} - {% trans "Connexion par mot de passe" %}</h2>
</head>
<body>
{% if form.errors %} {% if form.errors %}
<p>Your username and password didn't match. Please try again.</p> <p class="error">{% trans "Nom d'utilisateur et/ou mot de passe incorrect" %}</p>
{% endif %} {% endif %}
{% if next %} <form class="exte" method="post" action="{% url 'authens:login.pwd' %}">
{% if user.is_authenticated %}
<p>Your account doesn't have access to this page. To proceed,
please login with an account that has access.</p>
{% else %}
<p>Please login to see this page.</p>
{% endif %}
{% endif %}
<form method="post" action="{% url 'authens:login.pwd' %}">
{% csrf_token %} {% csrf_token %}
<table> <table>
<tbody>
{% for field in form %}
<tr> <tr>
<td>{{ form.username.label_tag }}</td> <th>{{ field.label_tag }}</th>
<td>{{ form.username }}</td> <td>{{ field }}</td>
</tr>
<tr>
<td>{{ form.password.label_tag }}</td>
<td>{{ form.password }}</td>
</tr> </tr>
{% endfor %}
</tbody>
</table> </table>
<input type="submit" value="{% trans "Se connecter" %}">
<input type="submit" value="login">
<input type="hidden" name="next" value="{{ next }}"> <input type="hidden" name="next" value="{{ next }}">
</form> </form>
</body> {% endblock %}
</html>

View file

@ -120,13 +120,15 @@ STATIC_URL = "/static/"
from django.urls import reverse_lazy # noqa from django.urls import reverse_lazy # noqa
# This is mandatory
INSTALLED_APPS += ["example", "authens"] INSTALLED_APPS += ["example", "authens"]
AUTHENTICATION_BACKENDS = [ AUTHENTICATION_BACKENDS = [
"django.contrib.auth.backends.ModelBackend", "django.contrib.auth.backends.ModelBackend",
"authens.backends.ENSCASBackend", "authens.backends.ENSCASBackend",
] ]
LOGIN_URL = reverse_lazy("authens:login") LOGIN_URL = reverse_lazy("authens:login")
# This is cosmetic
LOGIN_REDIRECT_URL = reverse_lazy("home") LOGIN_REDIRECT_URL = reverse_lazy("home")
LOGOUT_REDIRECT_URL = reverse_lazy("home") LOGOUT_REDIRECT_URL = reverse_lazy("home")
LANGUAGE_CODE = "fr-fr"