From 293c2a0aa7d2e54d8f05aff1ef52642d62decf06 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Sat, 2 Mar 2019 15:53:27 +0100 Subject: [PATCH] Redirect logout to login page --- friends_map/settings.py | 1 + map/templates/map/navbar.html | 4 ++-- map/templates/registration/login.html | 3 +++ map/views.py | 5 +++-- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/friends_map/settings.py b/friends_map/settings.py index 08cf457..bdf41fb 100644 --- a/friends_map/settings.py +++ b/friends_map/settings.py @@ -144,4 +144,5 @@ APP = { } CRISPY_TEMPLATE_PACK = 'bootstrap4' +LOGOUT_REDIRECT_URL = '/' diff --git a/map/templates/map/navbar.html b/map/templates/map/navbar.html index a608401..b44f22d 100644 --- a/map/templates/map/navbar.html +++ b/map/templates/map/navbar.html @@ -23,9 +23,9 @@ Admin {% endif %} - Modifier le mot de passe + Change password - Déconnexion + Logout {% else %} Login diff --git a/map/templates/registration/login.html b/map/templates/registration/login.html index 9b3afe8..a358613 100644 --- a/map/templates/registration/login.html +++ b/map/templates/registration/login.html @@ -1,7 +1,10 @@ {% extends 'map/base.html' %} {% load crispy_forms_tags %} +{% block h1 %}Login{% endblock %} + {% block content %} +

Please authenticate before accessing the map.

{% csrf_token %} {{ form|crispy }} diff --git a/map/views.py b/map/views.py index 396ce15..407a483 100644 --- a/map/views.py +++ b/map/views.py @@ -1,9 +1,10 @@ -from django.shortcuts import render +from django.contrib.auth.mixins import LoginRequiredMixin from django.views.generic import ListView + from map import models -class MapView(ListView): +class MapView(LoginRequiredMixin, ListView): model = models.FriendLocation context_object_name = 'locations' template_name = 'map/map.html'