From 305592b85c83a63c7bf14ce5ea63fbda29f1a81e Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Mon, 27 Dec 2010 17:01:06 +0100 Subject: Add a context processor --- ishtar/furnitures/context_processors.py | 27 +++++++++++++++++++++++++++ ishtar/furnitures/views.py | 9 ++++----- ishtar/settings.py.example | 9 +++++++++ ishtar/templates/base.html | 14 ++++++++++++-- 4 files changed, 52 insertions(+), 7 deletions(-) create mode 100644 ishtar/furnitures/context_processors.py (limited to 'ishtar') diff --git a/ishtar/furnitures/context_processors.py b/ishtar/furnitures/context_processors.py new file mode 100644 index 000000000..ae1bbc36d --- /dev/null +++ b/ishtar/furnitures/context_processors.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (C) 2010 Étienne Loks + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# See the file COPYING for details. + +from ishtar import settings + +def get_base_context(request): + dct = {} + if settings.APP_NAME: + dct["APP_NAME"] = settings.APP_NAME + return dct + diff --git a/ishtar/furnitures/views.py b/ishtar/furnitures/views.py index 28e078cd3..9ec293ee8 100644 --- a/ishtar/furnitures/views.py +++ b/ishtar/furnitures/views.py @@ -24,14 +24,13 @@ Furnitures views from django.template import RequestContext from django.shortcuts import render_to_response -def get_base_info(request): - dct = {} - return RequestContext(request, dct) +from ishtar import settings def index(request): """ Main page """ - dct = get_base_info(request) - return render_to_response('index.html', dct) + dct = {} + return render_to_response('index.html', dct, + context_instance=RequestContext(request)) diff --git a/ishtar/settings.py.example b/ishtar/settings.py.example index 0b1177830..2fe347345 100644 --- a/ishtar/settings.py.example +++ b/ishtar/settings.py.example @@ -2,6 +2,7 @@ # Ishtar custom SRID = 27572 +APP_NAME = "" ROOT_PATH = "/var/local/webapp/ishtar/ishtar/" URL_PATH = "" @@ -83,6 +84,14 @@ MIDDLEWARE_CLASSES = ( 'django.contrib.messages.middleware.MessageMiddleware', ) +TEMPLATE_CONTEXT_PROCESSORS = ( + 'furnitures.context_processors.get_base_context', + "django.core.context_processors.auth", + "django.core.context_processors.debug", + "django.core.context_processors.i18n", + "django.core.context_processors.media", +) + ROOT_URLCONF = 'ishtar.urls' TEMPLATE_DIRS = ( diff --git a/ishtar/templates/base.html b/ishtar/templates/base.html index 4f8282bbe..e26a5ddab 100644 --- a/ishtar/templates/base.html +++ b/ishtar/templates/base.html @@ -5,7 +5,9 @@ - {% block title %}Ishtar{% endblock %} + + {% block title %}Ishtar{% if APP_NAME %} - {{APP_NAME}}{%endif%}{% endblock %} + @@ -20,7 +22,15 @@ {% endif %} {% endblock %} - + +
+ {% block context %}{% endblock %} +
+
{% block content %}{% endblock %}
-- cgit v1.2.3