From 210c439a0ee7b1180380803518528a3f14769bd9 Mon Sep 17 00:00:00 2001 From: Sanj Date: Mon, 4 Jul 2011 18:53:18 +0530 Subject: [PATCH] add RequestContext to all main views; add logged in status in footer --- edgware/files/views.py | 4 +++- edgware/main/views.py | 29 +++++++++++++++++++---------- edgware/templates/main_base.html | 7 +++++++ 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/edgware/files/views.py b/edgware/files/views.py index 30d8cdf..d865019 100644 --- a/edgware/files/views.py +++ b/edgware/files/views.py @@ -65,11 +65,13 @@ def getFolderList(): full_dirs.sort(key=lambda x: getmtime(x), reverse=True) return map(lambda x: (basename(x), basename(x)), full_dirs) + @login_required def upload_files(request): - return render_to_response("upload_files.html", { + context = RequestContext(request, { 'categoryForm': CategoryForm() }) + return render_to_response("upload_files.html", context) @login_required def add_category(request): diff --git a/edgware/main/views.py b/edgware/main/views.py index 8283c6e..5c7b330 100644 --- a/edgware/main/views.py +++ b/edgware/main/views.py @@ -3,32 +3,41 @@ from django.shortcuts import render_to_response import Image import sys from django.http import HttpResponse +from django.template import RequestContext def home(request): - return render_to_response("main/home.html") + context = RequestContext(request, {}) + return render_to_response("main/home.html", context) def contact(request): - return render_to_response("main/contact.html") + context = RequestContext(request, {}) + return render_to_response("main/contact.html", context) def archive(request): - return render_to_response("main/archive.html") + context = RequestContext(request, {}) + return render_to_response("main/archive.html", context) def publish(request): - return render_to_response("main/publish.html") + context = RequestContext(request, {}) + return render_to_response("main/publish.html", context) def browse(request): - return render_to_response("main/browse.html") + context = RequestContext(request, {}) + return render_to_response("main/browse.html", context) def faq(request): - return render_to_response("main/faq.html") + context = RequestContext(request, {}) + return render_to_response("main/faq.html", context) def help(request): - return render_to_response("main/help.html") + context = RequestContext(request, {}) + return render_to_response("main/help.html", context) def debug(request): - imageVersion = Image.VERSION - sysPath = ",".join(sys.path) - return HttpResponse(imageVersion + "\n" + sysPath) +# imageVersion = Image.VERSION +# sysPath = ",".join(sys.path) +# return HttpResponse(imageVersion + "\n" + sysPath) + return Foo() def error(request): return FooBar() diff --git a/edgware/templates/main_base.html b/edgware/templates/main_base.html index c44e6dd..94a5b15 100644 --- a/edgware/templates/main_base.html +++ b/edgware/templates/main_base.html @@ -57,6 +57,13 @@ +
+ {% if user.is_authenticated %} + Logged in as {{ user.username }}. + {% else %} + Not logged in. + {% endif %} +