From f3c49c09dc7b2a7ccee36b897b9056a9622e0c02 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Tue, 17 Mar 2015 12:55:46 +0100 Subject: [PATCH] Django 1.8(b2) support. --- cas_provider/urls.py | 23 ++++++++++++----------- cas_provider/views.py | 11 +++++------ cas_provider_examples/simple/urls.py | 11 +++++------ tox.ini | 3 ++- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/cas_provider/urls.py b/cas_provider/urls.py index fb59599..f679a87 100644 --- a/cas_provider/urls.py +++ b/cas_provider/urls.py @@ -1,15 +1,16 @@ from __future__ import unicode_literals -from django.conf.urls import patterns, url +from django.conf.urls import url +from cas_provider import views -urlpatterns = patterns('cas_provider.views', - url(r'^login/merge/', 'login', {'merge': True, 'template_name': 'cas/merge.html'}), - url(r'^login/?$', 'login', name='cas_login'), - url(r'^socialauth-login/$', 'login', name='cas_socialauth_login'), - url(r'^validate/?$', 'validate', name='cas_validate'), - url(r'^proxy/?$', 'proxy', name='proxy'), - url(r'^serviceValidate/?$', 'service_validate', name='cas_service_validate'), - url(r'^proxyValidate/?$', 'proxy_validate', name='cas_proxy_validate'), - url(r'^logout/?$', 'logout', name='cas_logout'), -) +urlpatterns = [ + url(r'^login/merge/', views.login, {'merge': True, 'template_name': 'cas/merge.html'}), + url(r'^login/?$', views.login, name='cas_login'), + url(r'^socialauth-login/$', views.login, name='cas_socialauth_login'), + url(r'^validate/?$', views.validate, name='cas_validate'), + url(r'^proxy/?$', views.proxy, name='proxy'), + url(r'^serviceValidate/?$', views.service_validate, name='cas_service_validate'), + url(r'^proxyValidate/?$', views.proxy_validate, name='cas_proxy_validate'), + url(r'^logout/?$', views.logout, name='cas_logout'), +] diff --git a/cas_provider/views.py b/cas_provider/views.py index 76bcbb2..0b18b22 100644 --- a/cas_provider/views.py +++ b/cas_provider/views.py @@ -23,7 +23,7 @@ from django.http import HttpResponse, HttpResponseRedirect from django.conf import settings from django.contrib.auth import login as auth_login, logout as auth_logout from django.core.urlresolvers import get_callable -from django.shortcuts import render_to_response +from django.shortcuts import render from django.utils.translation import ugettext as _ from django.template import RequestContext from django.contrib.auth import authenticate @@ -166,10 +166,10 @@ def login(request, template_name='cas/login.html', return HttpResponseRedirect(success_redirect) else: if request.GET.get('warn', False): - return render_to_response(warn_template_name, { + return render(request, warn_template_name, { 'service': service, 'warn': False - }, context_instance=RequestContext(request)) + }) # Create a service ticket and redirect to the service. ticket = ServiceTicket.objects.create(service=service, user=user) @@ -182,7 +182,7 @@ def login(request, template_name='cas/login.html', return HttpResponseRedirect(url) logging.debug('Rendering response on %s, merge is %s', template_name, merge) - return render_to_response(template_name, {'form': form, 'errors': errors}, context_instance=RequestContext(request)) + return render(request, template_name, {'form': form, 'errors': errors}) @never_cache @@ -226,8 +226,7 @@ def logout(request, template_name='cas/logout.html', auth_logout(request) if url and auto_redirect: return HttpResponseRedirect(url) - return render_to_response(template_name, {'url': url}, - context_instance=RequestContext(request)) + return render(request, template_name, {'url': url}) @never_cache diff --git a/cas_provider_examples/simple/urls.py b/cas_provider_examples/simple/urls.py index 71e70f3..f1b5378 100644 --- a/cas_provider_examples/simple/urls.py +++ b/cas_provider_examples/simple/urls.py @@ -1,12 +1,11 @@ from __future__ import unicode_literals -from django.conf.urls import patterns, include, url +from django.conf.urls import include, url from django.contrib import admin from django.views.generic import TemplateView -urlpatterns = patterns('', +urlpatterns = [ url(r'^admin/', include(admin.site.urls)), - url(r'^', include('cas_provider.urls')), - url(r'^accounts/profile', TemplateView.as_view(template_name='login-success-redirect-target.html')), - - ) + url(r'^', include('cas_provider.urls')), + url(r'^accounts/profile', TemplateView.as_view(template_name='login-success-redirect-target.html')), +] diff --git a/tox.ini b/tox.ini index d62a393..2a4c5fb 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,7 @@ [tox] envlist=clear, d1{5,6}-py{26,27,32,33}, - d{17,d}-py{27,32,33,34}, + d{17,18,d}-py{27,32,33,34}, stats [testenv] @@ -10,6 +10,7 @@ deps= d15: Django>=1.5,<1.6 d16: Django>=1.6,<1.7 d17: Django>=1.7,<1.8 + d18: https://www.djangoproject.com/download/1.8b2/tarball/ dd: https://github.com/django/django/zipball/master d15,d16: https://bitbucket.org/andrewgodwin/south/get/e2c9102ee033.zip coverage -- 2.20.1