moved create_context to context_processor

This commit is contained in:
Arne Schauf 2013-09-28 23:31:33 +02:00
parent 202de726c1
commit 2b365a0496
4 changed files with 14 additions and 10 deletions

View File

@ -31,8 +31,8 @@
</div>
<div class="row">
<h3>Information</h3>
<b>your IPv4:</b> <span class="ipv4adr">{{session.ipv4}}</span> </br>
<b>your IPv6:</b> <span class="ipv6adr">{{session.ipv6}}</span>
<b>your IPv4:</b> <span class="ipv4adr">{{ request.session.ipv4 }}</span> </br>
<b>your IPv6:</b> <span class="ipv6adr">{{ request.session.ipv6 }}</span>
</div>
<div style="display: none">
<img src="//{{ WWW_IPV4_HOST }}/updateip" />

View File

@ -12,13 +12,6 @@ from django.core.urlresolvers import reverse
from main.forms import HostForm
from main.models import Host
def create_context(request):
context = {}
context['WWW_IPV4_HOST'] = settings.WWW_IPV4_HOST
context['WWW_IPV6_HOST'] = settings.WWW_IPV6_HOST
context['session'] = request.session
return context
class HomeView(TemplateView):
template_name = "base.html"
@ -57,7 +50,7 @@ class OverviewView(CreateView):
@login_required
def HostView(request,pk=None):
context = create_context(request)
context = {}
context['nav_overview'] = True
context['HostForm'] = HostForm(request.user,instance=get_object_or_404(Host, pk=pk, created_by=request.user))
if request.method == "POST":

View File

@ -0,0 +1,9 @@
# -*- coding: utf-8 -*-
from django.conf import settings
def add_settings(request):
context = {}
context['WWW_IPV4_HOST'] = settings.WWW_IPV4_HOST
context['WWW_IPV6_HOST'] = settings.WWW_IPV6_HOST
return context

View File

@ -121,6 +121,7 @@ MIDDLEWARE_CLASSES = (
TEMPLATE_CONTEXT_PROCESSORS = DEFAULT_SETTINGS.TEMPLATE_CONTEXT_PROCESSORS + (
'django.core.context_processors.request',
'nsupdate.context_processors.add_settings',
)
ROOT_URLCONF = 'nsupdate.urls'
@ -203,3 +204,4 @@ try:
from .local_settings import *
except ImportError:
pass