# HG changeset patch # User Brian Neal # Date 1450062283 21600 # Node ID 312f198e895840e2c43cb15b09b0b4ed610f9ad8 # Parent 574cdd0241af3a90405fd0839691754d05fde4f7 Changes for Django 1.8. diff -r 574cdd0241af -r 312f198e8958 articles/urls.py --- a/articles/urls.py Tue Oct 20 20:38:34 2015 -0500 +++ b/articles/urls.py Sun Dec 13 21:04:43 2015 -0600 @@ -2,13 +2,13 @@ Urls for the articles application. """ -from django.conf.urls import patterns, url +from django.conf.urls import url from django.views.generic import DetailView, ListView from articles.models import Article -urlpatterns = patterns('', +urlpatterns = [ url(r'^$', ListView.as_view( model=Article, @@ -17,4 +17,4 @@ url(r'^(?P\d+)/$', DetailView.as_view(model=Article, context_object_name='article'), name='articles-item') -) +] diff -r 574cdd0241af -r 312f198e8958 band/urls.py --- a/band/urls.py Tue Oct 20 20:38:34 2015 -0500 +++ b/band/urls.py Sun Dec 13 21:04:43 2015 -0600 @@ -2,12 +2,15 @@ Urls for the band application. """ -from django.conf.urls import patterns, url +from django.conf.urls import url -urlpatterns = patterns('band.views', - url(r'^bio/$', 'bio', name='band-bio'), - url(r'^buy/$', 'buy', name='band-buy'), - url(r'^contact/$', 'contact', name='band-contact'), - url(r'^photos/$', 'photos_index', name='band-photo_index'), - url(r'^photos/(\d+)/$', 'photo_detail', name='band-photo_detail'), -) +import band.views + + +urlpatterns = [ + url(r'^bio/$', band.views.bio, name='band-bio'), + url(r'^buy/$', band.views.buy, name='band-buy'), + url(r'^contact/$', band.views.contact, name='band-contact'), + url(r'^photos/$', band.views.photos_index, name='band-photo_index'), + url(r'^photos/(\d+)/$', band.views.photo_detail, name='band-photo_detail'), +] diff -r 574cdd0241af -r 312f198e8958 band/views.py --- a/band/views.py Tue Oct 20 20:38:34 2015 -0500 +++ b/band/views.py Sun Dec 13 21:04:43 2015 -0600 @@ -45,8 +45,8 @@ albums = Album.objects.all().order_by('-id') merchandise = Merchandise.objects.all().order_by('-id') return render(request, 'band/buy.html', { - 'albums': albums, - 'merchandise': merchandise, + 'albums': albums, + 'merchandise': merchandise, }) diff -r 574cdd0241af -r 312f198e8958 email_list/admin.py --- a/email_list/admin.py Tue Oct 20 20:38:34 2015 -0500 +++ b/email_list/admin.py Sun Dec 13 21:04:43 2015 -0600 @@ -3,7 +3,7 @@ """ from django.contrib import admin -from django.conf.urls import patterns, url +from django.conf.urls import url from django.shortcuts import render, redirect from email_list.models import Subscriber @@ -17,11 +17,11 @@ def get_urls(self): urls = super(SubscriberAdmin, self).get_urls() - my_urls = patterns('', + my_urls = [ url(r'^send_mail/$', self.admin_site.admin_view(self.send_mail), name='email_list-admin_mail'), - ) + ] return my_urls + urls def send_mail(self, request): diff -r 574cdd0241af -r 312f198e8958 email_list/tests/test_views.py --- a/email_list/tests/test_views.py Tue Oct 20 20:38:34 2015 -0500 +++ b/email_list/tests/test_views.py Sun Dec 13 21:04:43 2015 -0600 @@ -2,8 +2,6 @@ View tests for the email_list application. """ -import urllib - from django.test import TestCase from django.core.urlresolvers import reverse from django.core import mail @@ -211,7 +209,7 @@ self.assertEqual(mail.outbox[0].to[0], subscriber.email) msg = str(mail.outbox[0].message()) - self.assertTrue(msg.count(urllib.quote(subscriber.key)) > 0) + self.assertTrue(msg.count(subscriber.key) > 0) # clear outbox mail.outbox = [] diff -r 574cdd0241af -r 312f198e8958 email_list/urls.py --- a/email_list/urls.py Tue Oct 20 20:38:34 2015 -0500 +++ b/email_list/urls.py Sun Dec 13 21:04:43 2015 -0600 @@ -2,16 +2,18 @@ Urls for the email_list application. """ -from django.conf.urls import patterns, url +from django.conf.urls import url from django.views.generic import TemplateView +import email_list.views -urlpatterns = patterns('email_list.views', + +urlpatterns = [ url(r'^$', - 'mailing_list', + email_list.views.mailing_list, name='email_list-main'), url(r'^confirm/(?P[-a-zA-Z0-9_=]{28})/$', - 'confirm', + email_list.views.confirm, name='email_list-confirm'), url(r'^request/subscribe/$', TemplateView.as_view(template_name='email_list/subscribe_request.html'), @@ -25,4 +27,4 @@ url(r'^unsubscribed/$', TemplateView.as_view(template_name='email_list/unsubscribed.html'), name='email_list-unsubscribed'), -) +] diff -r 574cdd0241af -r 312f198e8958 gigs/urls.py --- a/gigs/urls.py Tue Oct 20 20:38:34 2015 -0500 +++ b/gigs/urls.py Sun Dec 13 21:04:43 2015 -0600 @@ -2,14 +2,15 @@ Urls for the gigs application. """ -from django.conf.urls import patterns, url +from django.conf.urls import url from django.views.generic import ListView from gigs.models import Gig +import gigs.views -urlpatterns = patterns('', - url(r'^$', 'gigs.views.gigs', name='gigs-index'), +urlpatterns = [ + url(r'^$', gigs.views.gigs, name='gigs-index'), url(r'^flyers/$', ListView.as_view( queryset=Gig.objects.exclude(flyer__isnull=True).select_related('flyer'), @@ -17,4 +18,4 @@ paginate_by=10, context_object_name='gig_list'), name='gigs-flyers') -) +] diff -r 574cdd0241af -r 312f198e8958 madeira/settings/base.py --- a/madeira/settings/base.py Tue Oct 20 20:38:34 2015 -0500 +++ b/madeira/settings/base.py Sun Dec 13 21:04:43 2015 -0600 @@ -6,7 +6,6 @@ PROJECT_PATH = os.path.abspath(os.path.join(os.path.split(__file__)[0], '..')) DEBUG = True -TEMPLATE_DEBUG = DEBUG ADMINS = [ ('Brian Neal', 'admin@surfguitar101.com'), @@ -53,12 +52,6 @@ SECRETS = json.load(open(os.path.join(PROJECT_PATH, 'settings', 'secrets.json'))) SECRET_KEY = SECRETS['SECRET_KEY'] -TEMPLATE_LOADERS = [ - 'django.template.loaders.filesystem.Loader', - 'django.template.loaders.app_directories.Loader', -# 'django.template.loaders.eggs.Loader', -] - MIDDLEWARE_CLASSES = [ 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', @@ -66,27 +59,32 @@ 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.admindocs.middleware.XViewMiddleware', 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware', ] ROOT_URLCONF = 'madeira.urls' -# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". -# Always use forward slashes, even on Windows. -# Don't forget to use absolute paths, not relative paths. -TEMPLATE_DIRS = [ - os.path.join(PROJECT_PATH, 'templates'), - os.path.abspath(os.path.join(PROJECT_PATH, '..', 'photologue', 'templates')), -] - -TEMPLATE_CONTEXT_PROCESSORS = [ - "django.contrib.auth.context_processors.auth", - "django.core.context_processors.debug", - "django.core.context_processors.request", - "django.core.context_processors.media", - "django.core.context_processors.static", - "django.contrib.messages.context_processors.messages", +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [ + os.path.join(PROJECT_PATH, 'templates'), + os.path.abspath(os.path.join(PROJECT_PATH, '..', 'photologue', 'templates')), + ], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + "django.contrib.auth.context_processors.auth", + "django.template.context_processors.debug", + "django.template.context_processors.request", + "django.template.context_processors.media", + "django.template.context_processors.static", + "django.contrib.messages.context_processors.messages", + ], + }, + }, ] INSTALLED_APPS = [ diff -r 574cdd0241af -r 312f198e8958 madeira/templates/band/photos.html --- a/madeira/templates/band/photos.html Tue Oct 20 20:38:34 2015 -0500 +++ b/madeira/templates/band/photos.html Sun Dec 13 21:04:43 2015 -0600 @@ -10,7 +10,7 @@ {% if galleries %} {% else %} diff -r 574cdd0241af -r 312f198e8958 madeira/urls.py --- a/madeira/urls.py Tue Oct 20 20:38:34 2015 -0500 +++ b/madeira/urls.py Sun Dec 13 21:04:43 2015 -0600 @@ -1,5 +1,6 @@ -from django.conf.urls import patterns, include, url +from django.conf.urls import include, url from django.contrib import admin +import django.contrib.auth.views from django.contrib.admin.views.decorators import staff_member_required from django.conf.urls.static import static from django.conf import settings @@ -8,26 +9,26 @@ from photologue.models import Photo -urlpatterns = patterns('', +urlpatterns = [ url(r'^$', TemplateView.as_view(template_name='index.html'), name='home'), - (r'^', include('band.urls')), - (r'^gigs/', include('gigs.urls')), - (r'^mail/', include('email_list.urls')), - (r'^news/', include('news.urls')), - (r'^press/', include('articles.urls')), - (r'^songs/', include('mp3.urls')), - (r'^videos/', include('videos.urls')), - (r'^admin/doc/', include('django.contrib.admindocs.urls')), + url(r'^', include('band.urls')), + url(r'^gigs/', include('gigs.urls')), + url(r'^mail/', include('email_list.urls')), + url(r'^news/', include('news.urls')), + url(r'^press/', include('articles.urls')), + url(r'^songs/', include('mp3.urls')), + url(r'^videos/', include('videos.urls')), + url(r'^admin/doc/', include('django.contrib.admindocs.urls')), url(r'^admin/password_reset/$', - 'django.contrib.auth.views.password_reset', + django.contrib.auth.views.password_reset, name='admin_password_reset'), - (r'^admin/password_reset/done/$', - 'django.contrib.auth.views.password_reset_done'), - (r'^reset/(?P[0-9A-Za-z]+)-(?P.+)/$', - 'django.contrib.auth.views.password_reset_confirm'), - (r'^reset/done/$', 'django.contrib.auth.views.password_reset_complete'), + url(r'^admin/password_reset/done/$', + django.contrib.auth.views.password_reset_done), + url(r'^reset/(?P[0-9A-Za-z]+)-(?P.+)/$', + django.contrib.auth.views.password_reset_confirm), + url(r'^reset/done/$', django.contrib.auth.views.password_reset_complete), # Keeping photologue on life support: url(r'^photo/(?P[\-\d\w]+)/$', @@ -35,8 +36,8 @@ slug_field='title_slug')), name='pl-photo'), - (r'^admin/', include(admin.site.urls)), -) + url(r'^admin/', include(admin.site.urls)), +] # For serving media files in development only: urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) diff -r 574cdd0241af -r 312f198e8958 mp3/urls.py --- a/mp3/urls.py Tue Oct 20 20:38:34 2015 -0500 +++ b/mp3/urls.py Sun Dec 13 21:04:43 2015 -0600 @@ -2,17 +2,17 @@ Urls for the mp3 application. """ -from django.conf.urls import patterns, url +from django.conf.urls import url from django.views.generic import ListView from mp3.models import Collection -urlpatterns = patterns('', +urlpatterns = [ url(r'^$', ListView.as_view( model=Collection, paginate_by=10, context_object_name='collection_list'), name='mp3-index'), -) +] diff -r 574cdd0241af -r 312f198e8958 news/urls.py --- a/news/urls.py Tue Oct 20 20:38:34 2015 -0500 +++ b/news/urls.py Sun Dec 13 21:04:43 2015 -0600 @@ -2,13 +2,13 @@ Urls for the news application. """ -from django.conf.urls import patterns, url +from django.conf.urls import url from django.views.generic import DetailView, ListView from news.models import News -urlpatterns = patterns('', +urlpatterns = [ url(r'^$', ListView.as_view( model=News, @@ -18,4 +18,4 @@ url(r'^story/(?P\d+)/$', DetailView.as_view(model=News, context_object_name='story'), name='news-item') -) +] diff -r 574cdd0241af -r 312f198e8958 videos/urls.py --- a/videos/urls.py Tue Oct 20 20:38:34 2015 -0500 +++ b/videos/urls.py Sun Dec 13 21:04:43 2015 -0600 @@ -2,13 +2,13 @@ Urls for the videos application. """ -from django.conf.urls import patterns, url +from django.conf.urls import url from django.views.generic import DetailView, ListView from videos.models import Collection -urlpatterns = patterns('', +urlpatterns = [ url(r'^$', ListView.as_view( model=Collection, @@ -17,4 +17,4 @@ url(r'^(?P\d+)/$', DetailView.as_view(model=Collection, context_object_name='collection'), name='videos-item') -) +]