From d5bbc8ac59145ca8aa06989b1e4fb5ba4f266a45 Mon Sep 17 00:00:00 2001 From: Fabian Faessler Date: Sat, 28 Sep 2013 13:56:54 +0200 Subject: [PATCH] added javascript example for /myip and added a view OverviewView. JS fails for dev server, because of the Access-Control-Allow-Origin --- nsupdate/main/urls.py | 3 ++- nsupdate/main/views.py | 9 +++++++ nsupdate/nsupdate/templates/base.html | 2 ++ nsupdate/nsupdate/templates/overview.html | 29 +++++++++++++++++++++++ 4 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 nsupdate/nsupdate/templates/overview.html diff --git a/nsupdate/main/urls.py b/nsupdate/main/urls.py index d50c085..2222b69 100644 --- a/nsupdate/main/urls.py +++ b/nsupdate/main/urls.py @@ -1,7 +1,8 @@ from django.conf.urls import patterns, include, url -from main.views import HomeView, MyIpView +from main.views import HomeView, MyIpView, OverviewView urlpatterns = patterns('', url(r'^$', HomeView.as_view(), name="home"), + url(r'^overview/', OverviewView.as_view(), name="overview"), url(r'^myip/', MyIpView) ) diff --git a/nsupdate/main/views.py b/nsupdate/main/views.py index eb36792..24b02bd 100644 --- a/nsupdate/main/views.py +++ b/nsupdate/main/views.py @@ -11,5 +11,14 @@ class HomeView(TemplateView): context['nav_home'] = True return context +class OverviewView(TemplateView): + template_name = "overview.html" + + def get_context_data(self, *args, **kwargs): + context = super(OverviewView, self).get_context_data(*args, **kwargs) + context['nav_overview'] = True + return context + + def MyIpView(request): return HttpResponse(json.dumps({'ip':request.META['REMOTE_ADDR']}), content_type="application/json") \ No newline at end of file diff --git a/nsupdate/nsupdate/templates/base.html b/nsupdate/nsupdate/templates/base.html index 2140bb8..4e10175 100644 --- a/nsupdate/nsupdate/templates/base.html +++ b/nsupdate/nsupdate/templates/base.html @@ -11,6 +11,7 @@ + @@ -27,6 +28,7 @@