From: Radek Czajka Date: Tue, 17 Mar 2015 13:42:47 +0000 (+0100) Subject: Django 1.8 X-Git-Url: https://git.mdrn.pl/cas.git/commitdiff_plain/a6bc469288a27a94f4c062a33701b7a57746dbb7?ds=inline Django 1.8 --- diff --git a/requirements.txt b/requirements.txt index d973b7c..5f7fa3e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,8 @@ -i https://py.mdrn.pl:8443/simple -Django>=1.7,<1.8 +Django>=1.8,<1.9 lxml>=2.2 django-gravatar2 Pillow --e git+https://github.com/rczajka/django-cas-provider.git@979cc8e80c887caa8a91a86dd2ed2971bfe2bff5#egg=django-cas-provider +-e git+https://github.com/rczajka/django-cas-provider.git@f3c49c09dc7b2a7ccee36b897b9056a9622e0c02#egg=django-cas-provider diff --git a/src/accounts/templates/account/profile.html b/src/accounts/templates/account/profile.html index b7cc601..6c907cc 100644 --- a/src/accounts/templates/account/profile.html +++ b/src/accounts/templates/account/profile.html @@ -6,7 +6,7 @@ Gravatar -

{% trans "Logout" %}

+

{% trans "Logout" %}

diff --git a/src/accounts/urls.py b/src/accounts/urls.py index 41752f8..6a18733 100644 --- a/src/accounts/urls.py +++ b/src/accounts/urls.py @@ -1,8 +1,9 @@ # -*- coding: utf-8 -*- -from django.conf.urls import patterns, url +from django.conf.urls import url +from . import views -urlpatterns = patterns('accounts.views', - url(r'^$', 'account_profile'), - url(r'^change_profile$', 'account_change_basic_profile'), - url(r'^change_password$', 'account_change_password'), -) +urlpatterns = [ + url(r'^$', views.account_profile), + url(r'^change_profile$', views.account_change_basic_profile), + url(r'^change_password$', views.account_change_password), +] diff --git a/src/accounts/views.py b/src/accounts/views.py index 5f153c0..9a95608 100644 --- a/src/accounts/views.py +++ b/src/accounts/views.py @@ -1,6 +1,7 @@ # Create your views here. from django import http from django.contrib.auth.decorators import login_required +from django.contrib.auth import update_session_auth_hash from django.contrib import messages from django.shortcuts import render from django.utils.translation import ugettext as _ @@ -37,6 +38,7 @@ def account_change_password(request): if form.is_valid(): request.user.set_password(form.cleaned_data['new_password']) request.user.save() + update_session_auth_hash(request, request.user) messages.add_message(request, messages.INFO, _("Password has been changed.")) return http.HttpResponseRedirect('/accounts/') diff --git a/src/cas/settings.py b/src/cas/settings.py index 562111c..a4c4137 100644 --- a/src/cas/settings.py +++ b/src/cas/settings.py @@ -4,7 +4,6 @@ from os import path PROJECT_ROOT = path.realpath(path.dirname(__file__)) DEBUG = True -TEMPLATE_DEBUG = DEBUG ADMINS = [ ] @@ -57,9 +56,28 @@ STATICFILES_DIRS = [ ROOT_URLCONF = 'cas.urls' -TEMPLATE_DIRS = ( - PROJECT_ROOT + '/templates', -) +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'APP_DIRS': True, + 'DIRS': [ + PROJECT_ROOT + '/templates', + ], + 'OPTIONS': { + 'context_processors': [ + "django.contrib.auth.context_processors.auth", + "django.template.context_processors.debug", + "django.template.context_processors.i18n", + "django.template.context_processors.media", + "django.template.context_processors.static", + "django.template.context_processors.tz", + "django.contrib.messages.context_processors.messages", + "django.template.context_processors.request", + ], + 'debug': DEBUG, + }, + }, +] LOCALE_PATHS = ( PROJECT_ROOT + '/locale', @@ -85,21 +103,11 @@ MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ) -TEMPLATE_CONTEXT_PROCESSORS = ( - "django.contrib.auth.context_processors.auth", - "django.core.context_processors.debug", - "django.core.context_processors.i18n", - "django.core.context_processors.media", - "django.core.context_processors.static", - "django.core.context_processors.tz", - "django.contrib.messages.context_processors.messages", - "django.core.context_processors.request", -) - # django-cas-provider settings LOGIN_URL = '/cas/login/' LOGOUT_URL = '/cas/logout/' diff --git a/src/cas/urls.py b/src/cas/urls.py index 5b67eb1..9db4e41 100644 --- a/src/cas/urls.py +++ b/src/cas/urls.py @@ -1,13 +1,13 @@ # -*- coding: utf-8 -*- -from django.conf.urls import include, patterns, url +from django.conf.urls import include, url from django.views.generic import RedirectView from django.contrib import admin from django.conf import settings admin.autodiscover() -urlpatterns = patterns('', - url(r'^$', RedirectView.as_view(url='/accounts/')), +urlpatterns = [ + url(r'^$', RedirectView.as_view(url='/accounts/', permanent=False)), # django-cas-provider url(r'^cas/', include('cas_provider.urls')), @@ -17,12 +17,13 @@ urlpatterns = patterns('', url(r'^admin/', include(admin.site.urls)), url(r'^accounts/', include('accounts.urls')), -) +] if settings.DEBUG: - urlpatterns += patterns('', - url(r'^media/(?P.*)$', 'django.views.static.serve', { + from django.views.static import serve + urlpatterns += [ + url(r'^media/(?P.*)$', serve, { 'document_root': settings.MEDIA_ROOT, }), - ) + ]