Redirect logout to login page

This commit is contained in:
Gabriel Augendre 2019-03-02 15:53:27 +01:00
parent b2c6051bd3
commit 293c2a0aa7
4 changed files with 9 additions and 4 deletions

View file

@ -144,4 +144,5 @@ APP = {
}
CRISPY_TEMPLATE_PACK = 'bootstrap4'
LOGOUT_REDIRECT_URL = '/'

View file

@ -23,9 +23,9 @@
<a class="dropdown-item" href="{% url 'admin:index' %}">Admin</a>
<div role="separator" class="dropdown-divider"></div>
{% endif %}
<a class="dropdown-item" href="{% url 'password_change' %}">Modifier le mot de passe</a>
<a class="dropdown-item" href="{% url 'password_change' %}">Change password</a>
<div role="separator" class="dropdown-divider"></div>
<a class="dropdown-item" href="{% url 'logout' %}">Déconnexion</a>
<a class="dropdown-item" href="{% url 'logout' %}">Logout</a>
</div>
{% else %}
<a class="nav-link" href="{% url 'login' %}?next={% url 'map' %}">Login</a>

View file

@ -1,7 +1,10 @@
{% extends 'map/base.html' %}
{% load crispy_forms_tags %}
{% block h1 %}Login{% endblock %}
{% block content %}
<p>Please authenticate before accessing the map.</p>
<form method="post">
{% csrf_token %}
{{ form|crispy }}

View file

@ -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'