From 9b1cc965c7e6260c0f16d1040029d28b2945d202 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Wed, 10 May 2017 18:41:17 +0100 Subject: [PATCH] Update to Django 1.10 --- PyRIGS/decorators.py | 12 ++++++------ PyRIGS/settings.py | 3 +++ PyRIGS/urls.py | 2 +- RIGS/urls.py | 2 +- requirements.txt | 3 ++- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/PyRIGS/decorators.py b/PyRIGS/decorators.py index 055901ca..1ae73e7d 100644 --- a/PyRIGS/decorators.py +++ b/PyRIGS/decorators.py @@ -26,15 +26,15 @@ def user_passes_test_with_403(test_func, login_url=None, oembed_view=None): return view_func(request, *args, **kwargs) elif not request.user.is_authenticated(): if oembed_view is not None: - extra_context = {} - extra_context['oembed_url'] = "{0}://{1}{2}".format(request.scheme, request.META['HTTP_HOST'], reverse(oembed_view, kwargs=kwargs)) - extra_context['login_url'] = "{0}?{1}={2}".format(login_url, REDIRECT_FIELD_NAME, request.get_full_path()) - resp = render_to_response('login_redirect.html', extra_context, context_instance=RequestContext(request)) + context = RequestContext(request) + context['oembed_url'] = "{0}://{1}{2}".format(request.scheme, request.META['HTTP_HOST'], reverse(oembed_view, kwargs=kwargs)) + context['login_url'] = "{0}?{1}={2}".format(login_url, REDIRECT_FIELD_NAME, request.get_full_path()) + resp = render_to_response('login_redirect.html', context=context) return resp else: return HttpResponseRedirect('%s?%s=%s' % (login_url, REDIRECT_FIELD_NAME, request.get_full_path())) else: - resp = render_to_response('403.html', context_instance=RequestContext(request)) + resp = render_to_response('403.html', context=RequestContext(request)) resp.status_code = 403 return resp _checklogin.__doc__ = view_func.__doc__ @@ -62,7 +62,7 @@ def api_key_required(function): userid = kwargs.get('api_pk') key = kwargs.get('api_key') - error_resp = render_to_response('403.html', context_instance=RequestContext(request)) + error_resp = render_to_response('403.html', context=RequestContext(request)) error_resp.status_code = 403 if key is None: diff --git a/PyRIGS/settings.py b/PyRIGS/settings.py index 70d41064..d29c0e6b 100644 --- a/PyRIGS/settings.py +++ b/PyRIGS/settings.py @@ -31,6 +31,9 @@ ALLOWED_HOSTS = ['pyrigs.nottinghamtec.co.uk', 'rigs.nottinghamtec.co.uk', 'pyri if STAGING: ALLOWED_HOSTS.append('.herokuapp.com') +if DEBUG: + ALLOWED_HOSTS.append('localhost') + SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') if not DEBUG: SECURE_SSL_REDIRECT = True # Redirect all http requests to https diff --git a/PyRIGS/urls.py b/PyRIGS/urls.py index f8993d48..cbfcbfa0 100644 --- a/PyRIGS/urls.py +++ b/PyRIGS/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls import patterns, include, url +from django.conf.urls import include, url from django.contrib import admin from django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.conf import settings diff --git a/RIGS/urls.py b/RIGS/urls.py index 30eb7051..5af3fd9a 100644 --- a/RIGS/urls.py +++ b/RIGS/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls import patterns, include, url +from django.conf.urls import url from django.contrib.auth.views import password_reset from django.contrib.auth.decorators import login_required diff --git a/requirements.txt b/requirements.txt index f74f08e3..d9fbe723 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,9 @@ beautifulsoup4==4.4.1 +contextlib2==0.5.5 diff-match-patch==20121119 dj-database-url==0.4.0 dj-static==0.0.6 -Django==1.9.4 +Django==1.10.7 django-debug-toolbar==1.4 django-ical==1.3 django-recaptcha==1.0.5