From b0e439b42c8bddcf6f4a2c5bf153a5410e68817e Mon Sep 17 00:00:00 2001 From: Zak Timson Date: Fri, 18 Aug 2017 23:37:16 -0400 Subject: [PATCH] Added logout --- OACPL/urls.py | 1 + main/views.py | 8 +++++++- templates/base.html | 5 ++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/OACPL/urls.py b/OACPL/urls.py index 9b79a3d..af9d7de 100644 --- a/OACPL/urls.py +++ b/OACPL/urls.py @@ -16,6 +16,7 @@ def protected_serve(request, path, document_root=None, show_indexes=False): urlpatterns = [ url(r'^$', main.views.index, name='home'), + url(r'^admin/logout', main.views.logout, name='logout'), url(r'^admin/', admin.site.urls, name='admin'), url(r'^attorney/(?P\d+)', charter_members.views.index, name='attorney'), url(r'^media/secure/(?P.*)$', protected_serve, {'document_root': os.path.join(settings.MEDIA_ROOT, 'secure')}, name='secure media'), diff --git a/main/views.py b/main/views.py index aacadee..94bfb38 100644 --- a/main/views.py +++ b/main/views.py @@ -1,4 +1,5 @@ -from django.shortcuts import render +from django.shortcuts import render, redirect +from django.contrib import auth from charter_members.models import Attorney @@ -6,3 +7,8 @@ from charter_members.models import Attorney def index(request): attorneys = Attorney.objects.filter(front_page=True) return render(request, 'index.html', {'attorneys': attorneys}) + + +def logout(request): + auth.logout(request) + return redirect('/') diff --git a/templates/base.html b/templates/base.html index 7bbc416..1e8c389 100644 --- a/templates/base.html +++ b/templates/base.html @@ -54,10 +54,13 @@ + {% endif %} {% if not request.user.is_authenticated %} {% endif %}