Templates: first draft

This commit is contained in:
Martin Pépin 2020-05-18 01:27:12 +02:00
parent 4e9e2f62e8
commit 7d56fe15a9
No known key found for this signature in database
GPG key ID: E7520278B1774448
5 changed files with 132 additions and 52 deletions

View file

@ -0,0 +1,69 @@
html, body {
width: 100%;
background: #ccc;
font-family: monospace;
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;
}
form {
padding: 0.5em;
text-align: center;
width: 100%;
font-size: 2em;
}
form table {
margin: auto;
}
/* TODO: https://git.eleves.ens.fr/klub-dev-ens/authens/issues/9 */
.oldcas {
background: #CB6318;
color: white;
}
a {
flex: 1;
height: 200px;
min-width: 300px;
text-align: center;
font-size: 3em;
color: white;
line-height: 200px;
text-decoration: none;
}
a:hover {
text-decoration: underline;
font-weight: bold;
}

View file

@ -0,0 +1,22 @@
{% 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 }} - login
{% else %}ENS Auth{% endif %}
</title>
</head>
<body>
<div id="container">
{% block content %}{% endblock %}
</div>
</body>
</html>

View file

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

View file

@ -1,38 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>ENS Auth</title>
</head>
<body>
{% if form.errors %}
<p>Your username and password didn't match. Please try again.</p>
{% endif %}
{% extends "authens/base.html" %}
{% load i18n %}
{% if next %}
{% 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 %}
{% block content %}
<h2>{% trans "Connexion par mot de passe" %}</h2>
<form method="post" action="{% url 'authens:login.pwd' %}">
{% csrf_token %}
<table>
<tr>
<td>{{ form.username.label_tag }}</td>
<td>{{ form.username }}</td>
</tr>
<tr>
<td>{{ form.password.label_tag }}</td>
<td>{{ form.password }}</td>
</tr>
</table>
{% if form.errors %}
<p>{% trans "Nom d'utilisateur et/ou mot de passe incorrect" %}</p>
{% endif %}
<input type="submit" value="login">
<input type="hidden" name="next" value="{{ next }}">
</form>
</body>
</html>
<form class="exte" method="post" action="{% url 'authens:login.pwd' %}">
{% csrf_token %}
<table>
{{ form.as_table }}
</table>
<input type="submit" value="login">
<input type="hidden" name="next" value="{{ next }}">
</form>
{% endblock %}

View file

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