Skip to content

Commit b396833

Browse files
authored
Merge pull request SAML-Toolkits#55 from palbee/master
Update demo-django to Django 1.11
2 parents 061f635 + e88ad9e commit b396833

File tree

4 files changed

+37
-32
lines changed

4 files changed

+37
-32
lines changed

demo-django/demo/settings.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
1212
import os
13-
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
1413

14+
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
1515

1616
# Quick-start development settings - unsuitable for production
1717
# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/
@@ -22,11 +22,8 @@
2222
# SECURITY WARNING: don't run with debug turned on in production!
2323
DEBUG = True
2424

25-
TEMPLATE_DEBUG = True
26-
2725
ALLOWED_HOSTS = []
2826

29-
3027
# Application definition
3128

3229
INSTALLED_APPS = (
@@ -38,7 +35,7 @@
3835
'django.contrib.staticfiles',
3936
)
4037

41-
MIDDLEWARE_CLASSES = (
38+
MIDDLEWARE = (
4239
'django.contrib.sessions.middleware.SessionMiddleware',
4340
'django.middleware.common.CommonMiddleware',
4441
# 'django.middleware.csrf.CsrfViewMiddleware',
@@ -51,7 +48,6 @@
5148

5249
WSGI_APPLICATION = 'demo.wsgi.application'
5350

54-
5551
# Database
5652
# https://docs.djangoproject.com/en/1.6/ref/settings/#databases
5753

@@ -75,16 +71,26 @@
7571

7672
USE_TZ = True
7773

78-
79-
# Static files (CSS, JavaScript, Images)
80-
# https://docs.djangoproject.com/en/1.6/howto/static-files/
81-
8274
STATIC_URL = '/static/'
8375

8476
SAML_FOLDER = os.path.join(BASE_DIR, 'saml')
8577

8678
SESSION_ENGINE = 'django.contrib.sessions.backends.file'
8779

88-
TEMPLATE_DIRS = (
89-
os.path.join(BASE_DIR, 'templates'),
90-
)
80+
TEMPLATES = [
81+
{
82+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
83+
'DIRS': [os.path.join(BASE_DIR, 'templates')]
84+
,
85+
'APP_DIRS': True,
86+
'OPTIONS': {
87+
'debug': True,
88+
'context_processors': [
89+
'django.template.context_processors.debug',
90+
'django.template.context_processors.request',
91+
'django.contrib.auth.context_processors.auth',
92+
'django.contrib.messages.context_processors.messages',
93+
],
94+
},
95+
},
96+
]

demo-django/demo/urls.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
from django.conf.urls import patterns, url
2-
1+
from django.conf.urls import url
32
from django.contrib import admin
3+
from .views import attrs, index, metadata
44
admin.autodiscover()
55

6-
urlpatterns = patterns(
7-
'',
8-
url(r'^$', 'demo.views.index', name='index'),
9-
url(r'^attrs/$', 'demo.views.attrs', name='attrs'),
10-
url(r'^metadata/$', 'demo.views.metadata', name='metadata'),
11-
)
6+
urlpatterns = [
7+
url(r'^$', index, name='index'),
8+
url(r'^attrs/$', attrs, name='attrs'),
9+
url(r'^metadata/$', metadata, name='metadata'),
10+
]

demo-django/demo/views.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from django.conf import settings
2-
from django.core.urlresolvers import reverse
2+
from django.urls import reverse
33
from django.http import (HttpResponse, HttpResponseRedirect,
44
HttpResponseServerError)
55
from django.shortcuts import render_to_response
@@ -78,13 +78,13 @@ def index(request):
7878
if len(request.session['samlUserdata']) > 0:
7979
attributes = request.session['samlUserdata'].items()
8080

81+
context = RequestContext(request, {'errors': errors,
82+
'not_auth_warn': not_auth_warn,
83+
'success_slo': success_slo,
84+
'attributes': attributes,
85+
'paint_logout': paint_logout}).flatten()
8186
return render_to_response('index.html',
82-
{'errors': errors,
83-
'not_auth_warn': not_auth_warn,
84-
'success_slo': success_slo,
85-
'attributes': attributes,
86-
'paint_logout': paint_logout},
87-
context_instance=RequestContext(request))
87+
context=context)
8888

8989

9090
def attrs(request):
@@ -97,9 +97,8 @@ def attrs(request):
9797
attributes = request.session['samlUserdata'].items()
9898

9999
return render_to_response('attrs.html',
100-
{'paint_logout': paint_logout,
101-
'attributes': attributes},
102-
context_instance=RequestContext(request))
100+
context=RequestContext(request, {'paint_logout': paint_logout,
101+
'attributes': attributes}).flatten())
103102

104103

105104
def metadata(request):

demo-django/requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
Django==1.6.5
1+
Django==1.11
2+
python3-saml

0 commit comments

Comments
 (0)