From 7b8745382f3ed8cfe9404fd0602e3cc88c9b92e0 Mon Sep 17 00:00:00 2001 From: Dorian Lesbre <dorian.lesbre@gmail.com> Date: Fri, 5 Mar 2021 21:37:59 +0100 Subject: [PATCH] Fix some CSS + login required --- accounts/templates/login.html | 8 ++++---- accounts/views.py | 4 +++- home/static/css/style.css | 9 +++------ 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/accounts/templates/login.html b/accounts/templates/login.html index 754a867..6f6134a 100644 --- a/accounts/templates/login.html +++ b/accounts/templates/login.html @@ -12,13 +12,13 @@ {% endif %} {% if next %} - {% if user.is_authenticated %} <ul class="messagelist"> - <li class="error">Accès non autorisé</li> - </ul> + {% if user.is_authenticated %} + <li class="error">Accès non autorisé.</li> {% else %} - <p>Merci de vous connecter.</p> + <li class="info">Vous devez vous connectez pour accéder à cette page.</li> {% endif %} + </ul> {% endif %} <form method="post" action="{% url 'accounts:login' %}?next={{ next|urlencode }}"> {% csrf_token %} diff --git a/accounts/views.py b/accounts/views.py index 9216439..89696cc 100644 --- a/accounts/views.py +++ b/accounts/views.py @@ -1,5 +1,6 @@ from django.contrib import messages from django.contrib.auth import login, logout +from django.contrib.auth.mixins import LoginRequiredMixin from django.contrib.auth.views import LoginView as DjangoLoginView from django.contrib.sites.shortcuts import get_current_site from django.http import Http404 @@ -32,9 +33,10 @@ class LogoutView(RedirectView): return super().get_redirect_url(*args, **kwargs) -class ProfileView(TemplateView): +class ProfileView(LoginRequiredMixin, TemplateView): """Vue des actions de gestion de son profil""" template_name = "profile.html" + redirect_field_name = "next" class CreateAccountView(View): diff --git a/home/static/css/style.css b/home/static/css/style.css index 06958bb..47e0f4b 100644 --- a/home/static/css/style.css +++ b/home/static/css/style.css @@ -209,22 +209,19 @@ ul.messagelist { ul.messagelist li { display: block; font-weight: 400; - font-size: 13px; padding: 10px 10px 10px 65px; margin: 0 0 10px 0; background: #dfd; - background-size: 16px auto; color: #333; } - ul.messagelist li.warning { background: #ffc; - background-size: 14px auto; } - ul.messagelist li.error { background: #ffefef; - background-size: 16px auto; +} +ul.messagelist li.info { + background: #ddf; } footer { -- GitLab