Django 1.8
authorRadek Czajka <radekczajka@nowoczesnapolska.org.pl>
Tue, 17 Mar 2015 13:42:47 +0000 (14:42 +0100)
committerRadek Czajka <radekczajka@nowoczesnapolska.org.pl>
Fri, 3 Apr 2015 12:00:55 +0000 (14:00 +0200)
requirements.txt
src/accounts/templates/account/profile.html
src/accounts/urls.py
src/accounts/views.py
src/cas/settings.py
src/cas/urls.py

index d973b7c..5f7fa3e 100644 (file)
@@ -1,8 +1,8 @@
 -i https://py.mdrn.pl:8443/simple
 
 -i https://py.mdrn.pl:8443/simple
 
-Django>=1.7,<1.8
+Django>=1.8,<1.9
 lxml>=2.2
 django-gravatar2
 Pillow
 
 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
index b7cc601..6c907cc 100644 (file)
@@ -6,7 +6,7 @@
                <img src="{% gravatar_url request.user.email 120 %}"
             alt="Gravatar"
             title="{% trans 'Change at Gravatar.com' %}">
                <img src="{% gravatar_url request.user.email 120 %}"
             alt="Gravatar"
             title="{% trans 'Change at Gravatar.com' %}">
-               <p><a href="{% url 'cas_provider.views.logout' %}">{% trans "Logout" %}</a></p>
+               <p><a href="{% url 'cas_logout' %}">{% trans "Logout" %}</a></p>
        </aside>
 
        <div id="details">
        </aside>
 
        <div id="details">
index 41752f8..6a18733 100644 (file)
@@ -1,8 +1,9 @@
 # -*- coding: utf-8 -*-
 # -*- 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),
+]
index 5f153c0..9a95608 100644 (file)
@@ -1,6 +1,7 @@
 # Create your views here.
 from django import http
 from django.contrib.auth.decorators import login_required
 # 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 _
 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()
     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/')
 
         messages.add_message(request, messages.INFO, _("Password has been changed."))
         return http.HttpResponseRedirect('/accounts/')
index 562111c..a4c4137 100644 (file)
@@ -4,7 +4,6 @@ from os import path
 PROJECT_ROOT = path.realpath(path.dirname(__file__))
 
 DEBUG = True
 PROJECT_ROOT = path.realpath(path.dirname(__file__))
 
 DEBUG = True
-TEMPLATE_DEBUG = DEBUG
 
 ADMINS = [
 ]
 
 ADMINS = [
 ]
@@ -57,9 +56,28 @@ STATICFILES_DIRS = [
 
 ROOT_URLCONF = 'cas.urls'
 
 
 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',
 
 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.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',
 )
 
     '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/'
 # django-cas-provider settings
 LOGIN_URL = '/cas/login/'
 LOGOUT_URL = '/cas/logout/'
index 5b67eb1..9db4e41 100644 (file)
@@ -1,13 +1,13 @@
 # -*- coding: utf-8 -*-
 # -*- 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()
 
 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')),
 
     # 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')),
     url(r'^admin/', include(admin.site.urls)),
 
     url(r'^accounts/', include('accounts.urls')),
-)
+]
 
 
 if settings.DEBUG:
 
 
 if settings.DEBUG:
-    urlpatterns += patterns('',
-        url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {
+    from django.views.static import serve
+    urlpatterns += [
+        url(r'^media/(?P<path>.*)$', serve, {
             'document_root': settings.MEDIA_ROOT,
         }),
             'document_root': settings.MEDIA_ROOT,
         }),
-   )
+   ]