Added logout
This commit is contained in:
parent
77a9aa9424
commit
02288ef5fd
@ -16,6 +16,7 @@ def protected_serve(request, path, document_root=None, show_indexes=False):
|
|||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^$', main.views.index, name='home'),
|
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'^admin/', admin.site.urls, name='admin'),
|
||||||
url(r'^attorney/(?P<userId>\d+)', charter_members.views.index, name='attorney'),
|
url(r'^attorney/(?P<userId>\d+)', charter_members.views.index, name='attorney'),
|
||||||
url(r'^media/secure/(?P<path>.*)$', protected_serve, {'document_root': os.path.join(settings.MEDIA_ROOT, 'secure')}, name='secure media'),
|
url(r'^media/secure/(?P<path>.*)$', protected_serve, {'document_root': os.path.join(settings.MEDIA_ROOT, 'secure')}, name='secure media'),
|
||||||
|
@ -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
|
from charter_members.models import Attorney
|
||||||
|
|
||||||
@ -6,3 +7,8 @@ from charter_members.models import Attorney
|
|||||||
def index(request):
|
def index(request):
|
||||||
attorneys = Attorney.objects.filter(front_page=True)
|
attorneys = Attorney.objects.filter(front_page=True)
|
||||||
return render(request, 'index.html', {'attorneys': attorneys})
|
return render(request, 'index.html', {'attorneys': attorneys})
|
||||||
|
|
||||||
|
|
||||||
|
def logout(request):
|
||||||
|
auth.logout(request)
|
||||||
|
return redirect('/')
|
||||||
|
@ -55,9 +55,14 @@
|
|||||||
<a class="nav-link" href="/admin/">ADMIN PANEL</a>
|
<a class="nav-link" href="/admin/">ADMIN PANEL</a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if request.user.is_authenticated%}
|
||||||
|
<li class="nav-item text-dark-primary">
|
||||||
|
<a class="nav-link" href="{% url 'logout' %}">LOGOUT</a>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
{% if not request.user.is_authenticated %}
|
{% if not request.user.is_authenticated %}
|
||||||
<li class="nav-item text-dark-primary">
|
<li class="nav-item text-dark-primary">
|
||||||
<a class="nav-link" href="{% url 'admin' %}">LOGIN</a>
|
<a class="nav-link" href="/admin/">LOGIN</a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
|
Loading…
Reference in New Issue
Block a user