From a364b878b233b000a26ab1eedad1e14cf91c58a8 Mon Sep 17 00:00:00 2001 From: Correl Roush Date: Wed, 8 Dec 2010 17:01:09 -0500 Subject: [PATCH] Created a logout link --- browser/views.py | 25 ++++++++++++++----------- dashboard/urls.py | 1 + dashboard/views.py | 7 +++++-- templates/layouts/default.html | 8 +++++++- templates/registration/logged_out.html | 4 ++++ 5 files changed, 31 insertions(+), 14 deletions(-) create mode 100644 templates/registration/logged_out.html diff --git a/browser/views.py b/browser/views.py index 307dbfe..dcb3bd3 100755 --- a/browser/views.py +++ b/browser/views.py @@ -1,6 +1,7 @@ import os from django.http import Http404 from django.shortcuts import render_to_response +from django.template import RequestContext from django.contrib.auth.decorators import permission_required from codereview.dashboard.models import Repository from codereview.browser import vcs @@ -41,7 +42,9 @@ def _log_data(request, repo, ref, path=None): @permission_required('dashboard.browse') def log(request, repository, path=None): repo, ref = _repo(request, repository) - data = {'repository': repository} + data = RequestContext(request, { + 'repository': repository + }) data.update(_log_data(request, repo, ref, path)) data.update(_nav_data(request, repo, ref, path)) return render_to_response('browser/log.html', data) @@ -55,21 +58,21 @@ def commit(request, repository, ref): commit = repo.commit(ref) diffs = repo.diff(ref) - return render_to_response('browser/view.html', - { - 'repository': repository, - 'repo': repo, - 'ref': ref, - 'commit': commit, - 'diffs': diffs, - }) + data = RequestContext(request, { + 'repository': repository, + 'repo': repo, + 'ref': ref, + 'commit': commit, + 'diffs': diffs, + }) + return render_to_response('browser/view.html', data) @permission_required('dashboard.browse') def blob(request, repository, path): repo, ref = _repo(request, repository) - data = { + data = RequestContext(request, { 'repository': repository, 'blob': repo.blob(ref, path), - } + }) data.update(_log_data(request, repo, ref, path)) data.update(_nav_data(request, repo, ref, os.path.dirname(path))) return render_to_response('browser/blob.html', data) diff --git a/dashboard/urls.py b/dashboard/urls.py index ed2bbb1..7429b4c 100644 --- a/dashboard/urls.py +++ b/dashboard/urls.py @@ -2,4 +2,5 @@ from django.conf.urls.defaults import * urlpatterns = patterns('', (r'^login/$', 'django.contrib.auth.views.login'), + (r'^logout/$', 'django.contrib.auth.views.logout'), ) diff --git a/dashboard/views.py b/dashboard/views.py index 36c16d6..eecc973 100755 --- a/dashboard/views.py +++ b/dashboard/views.py @@ -1,9 +1,12 @@ from django.shortcuts import render_to_response +from django.template import RequestContext from codereview.dashboard.models import Repository def index(request): """ List available repositories """ repositories = Repository.objects.all() - return render_to_response('dashboard/index.html', - {'repositories': repositories}) + data = RequestContext(request, { + 'repositories': repositories, + }) + return render_to_response('dashboard/index.html', data) diff --git a/templates/layouts/default.html b/templates/layouts/default.html index 0f7b7b2..67bc06c 100644 --- a/templates/layouts/default.html +++ b/templates/layouts/default.html @@ -11,7 +11,13 @@
-

CodeReview +

CodeReview

+ {% if user and user.is_authenticated %} + Currently logged in as + {{ user }} + + Log Out + {% endif %}