Update to Django 1.9

- update all dependencies
- fix deprecation warnings and errors for Django 1.9 compatibility
This commit is contained in:
Jan Dittberner 2015-12-19 20:11:23 +01:00
parent 1b30b1a38c
commit 085b126416
21 changed files with 85 additions and 110 deletions

View file

@ -4,7 +4,7 @@ URL patterns for the contact_form views.
""" """
from __future__ import absolute_import, unicode_literals from __future__ import absolute_import, unicode_literals
from django.conf.urls import patterns, url from django.conf.urls import url
from .views import ( from .views import (
ContactFormView, ContactFormView,
@ -12,8 +12,7 @@ from .views import (
) )
urlpatterns = patterns( urlpatterns = [
'',
url(r'^$', ContactFormView.as_view(), name='contact_form'), url(r'^$', ContactFormView.as_view(), name='contact_form'),
url(r'^success/$', ContactSuccessView.as_view(), name='contact_success'), url(r'^success/$', ContactSuccessView.as_view(), name='contact_success'),
) ]

View file

@ -1,6 +1,6 @@
from __future__ import absolute_import, unicode_literals from __future__ import absolute_import, unicode_literals
from django.conf.urls import patterns, url from django.conf.urls import url
from .views import ( from .views import (
IndexView, IndexView,
@ -8,9 +8,8 @@ from .views import (
) )
urlpatterns = patterns( urlpatterns = [
'',
url(r'^$', IndexView.as_view(), name='dashboard'), url(r'^$', IndexView.as_view(), name='dashboard'),
url(r'^user/(?P<slug>[\w0-9@.+-_]+)/$', url(r'^user/(?P<slug>[\w0-9@.+-_]+)/$',
UserDashboardView.as_view(), name='customer_dashboard'), UserDashboardView.as_view(), name='customer_dashboard'),
) ]

View file

@ -50,7 +50,6 @@ DNS_TSIG_KEY_ALGORITHMS = Choices(
) )
@python_2_unicode_compatible
class DomainBase(TimeStampedModel): class DomainBase(TimeStampedModel):
""" """
This is the base model for domains. This is the base model for domains.
@ -64,9 +63,6 @@ class DomainBase(TimeStampedModel):
class Meta: class Meta:
abstract = True abstract = True
def __str__(self):
return self.domain
@python_2_unicode_compatible @python_2_unicode_compatible
class MailDomain(DomainBase): class MailDomain(DomainBase):

View file

@ -9,7 +9,7 @@ from mock import MagicMock, Mock, patch
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.forms import ValidationError from django.forms import ValidationError
from django.test import TestCase from django.test import TestCase
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext as _
from domains.forms import relative_domain_validator, CreateHostingDomainForm from domains.forms import relative_domain_validator, CreateHostingDomainForm

View file

@ -17,7 +17,6 @@ from domains.models import (
DNSRecord, DNSRecord,
DNSSupermaster, DNSSupermaster,
DNSTSIGKey, DNSTSIGKey,
DomainBase,
HostingDomain, HostingDomain,
MailDomain, MailDomain,
) )
@ -32,13 +31,6 @@ User = get_user_model()
TEST_USER = 'test' TEST_USER = 'test'
class DomainBaseTest(TestCase):
def test___str__(self):
db = DomainBase(domain='test')
self.assertEqual(str(db), 'test')
class MailDomainTest(TestCase): class MailDomainTest(TestCase):
def test___str__(self): def test___str__(self):
@ -48,8 +40,7 @@ class MailDomainTest(TestCase):
def test_get_mailaddresses(self): def test_get_mailaddresses(self):
md = MailDomain.objects.create(domain='example.org') md = MailDomain.objects.create(domain='example.org')
from managemails.models import MailAddress from managemails.models import MailAddress
addrmock = MailAddress(localpart='info') addrmock = MailAddress.objects.create(localpart='info', domain=md)
md.mailaddress_set.add(addrmock)
self.assertIn(addrmock, md.get_mailaddresses()) self.assertIn(addrmock, md.get_mailaddresses())
self.assertIn(addrmock, md.mailaddresses) self.assertIn(addrmock, md.mailaddresses)

View file

@ -4,13 +4,12 @@ This module defines the URL patterns for domain related views.
""" """
from __future__ import absolute_import, unicode_literals from __future__ import absolute_import, unicode_literals
from django.conf.urls import patterns, url from django.conf.urls import url
from .views import CreateHostingDomain from .views import CreateHostingDomain
urlpatterns = patterns( urlpatterns = [
'',
url(r'^(?P<package>\d+)/create$', CreateHostingDomain.as_view(), url(r'^(?P<package>\d+)/create$', CreateHostingDomain.as_view(),
name='create_hosting_domain'), name='create_hosting_domain'),
) ]

View file

@ -46,9 +46,6 @@ path.append(DJANGO_ROOT)
# ######### DEBUG CONFIGURATION # ######### DEBUG CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#debug # See: https://docs.djangoproject.com/en/dev/ref/settings/#debug
DEBUG = False DEBUG = False
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-debug
TEMPLATE_DEBUG = DEBUG
# ######### END DEBUG CONFIGURATION # ######### END DEBUG CONFIGURATION
@ -158,34 +155,31 @@ FIXTURE_DIRS = (
# ######### TEMPLATE CONFIGURATION # ######### TEMPLATE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-context-processors # noqa # See: https://docs.djangoproject.com/en/1.9/ref/settings/#std:setting-TEMPLATES # noqa
TEMPLATE_CONTEXT_PROCESSORS = ( TEMPLATES = [
'django.contrib.auth.context_processors.auth', {
'django.core.context_processors.debug', 'BACKEND': 'django.template.backends.django.DjangoTemplates',
'django.core.context_processors.i18n', 'DIRS': [
'django.core.context_processors.media', normpath(join(SITE_ROOT, 'templates')),
'django.core.context_processors.static', ],
'django.core.context_processors.tz', 'APP_DIRS': True,
'django.contrib.messages.context_processors.messages', 'OPTIONS': {
'django.core.context_processors.request', 'context_processors': [
# allauth specific context processors 'django.contrib.auth.context_processors.auth',
'allauth.account.context_processors.account', 'django.template.context_processors.debug',
'allauth.socialaccount.context_processors.socialaccount', 'django.template.context_processors.i18n',
# custom context processors 'django.template.context_processors.media',
'gnuviechadmin.context_processors.navigation', 'django.template.context_processors.static',
'gnuviechadmin.context_processors.version_info', 'django.template.context_processors.tz',
) 'django.contrib.messages.context_processors.messages',
'django.template.context_processors.request',
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-loaders # custom context processors
TEMPLATE_LOADERS = ( 'gnuviechadmin.context_processors.navigation',
'django.template.loaders.filesystem.Loader', 'gnuviechadmin.context_processors.version_info',
'django.template.loaders.app_directories.Loader', ],
) },
},
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs ]
TEMPLATE_DIRS = (
normpath(join(SITE_ROOT, 'templates')),
)
# ######### END TEMPLATE CONFIGURATION # ######### END TEMPLATE CONFIGURATION

View file

@ -13,7 +13,7 @@ from .base import * # NOQA
DEBUG = True DEBUG = True
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-debug # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-debug
TEMPLATE_DEBUG = DEBUG TEMPLATES[0]['OPTIONS']['debug'] = DEBUG
# ######### END DEBUG CONFIGURATION # ######### END DEBUG CONFIGURATION

View file

@ -1,13 +1,13 @@
from __future__ import absolute_import from __future__ import absolute_import
from django.conf.urls import patterns, include, url from django.conf.urls import include, url
from django.conf import settings from django.conf import settings
from django.contrib import admin from django.contrib import admin
from django.contrib.flatpages import views
admin.autodiscover() admin.autodiscover()
urlpatterns = patterns( urlpatterns = [
'',
url(r'', include('dashboard.urls')), url(r'', include('dashboard.urls')),
url(r'^accounts/', include('allauth.urls')), url(r'^accounts/', include('allauth.urls')),
url(r'^database/', include('userdbs.urls')), url(r'^database/', include('userdbs.urls')),
@ -16,19 +16,18 @@ urlpatterns = patterns(
url(r'^website/', include('websites.urls')), url(r'^website/', include('websites.urls')),
url(r'^mail/', include('managemails.urls')), url(r'^mail/', include('managemails.urls')),
url(r'^osuser/', include('osusers.urls')), url(r'^osuser/', include('osusers.urls')),
url(r'^admin/', include(admin.site.urls)), url(r'^admin/', admin.site.urls),
url(r'^contact/', include('contact_form.urls')), url(r'^contact/', include('contact_form.urls')),
) url(r'^impressum/$', views.flatpage, {
urlpatterns += patterns( 'url': '/impressum/'
'django.contrib.flatpages.views', }, name='imprint'),
url(r'^impressum/$', 'flatpage', {'url': '/impressum/'}, name='imprint'), ]
)
# Uncomment the next line to serve media files in dev. # Uncomment the next line to serve media files in dev.
# urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) # urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
if settings.DEBUG: # pragma: no cover if settings.DEBUG: # pragma: no cover
import debug_toolbar import debug_toolbar
urlpatterns += patterns('', urlpatterns += [
url(r'^__debug__/', include(debug_toolbar.urls)), url(r'^__debug__/', debug_toolbar.urls),
) ]

View file

@ -4,7 +4,7 @@ This module defines the URL patterns for hosting package related views.
""" """
from __future__ import absolute_import, unicode_literals from __future__ import absolute_import, unicode_literals
from django.conf.urls import patterns, url from django.conf.urls import url
from .views import ( from .views import (
AddHostingOption, AddHostingOption,
@ -17,8 +17,7 @@ from .views import (
) )
urlpatterns = patterns( urlpatterns = [
'',
url(r'^create$', CreateHostingPackage.as_view(), url(r'^create$', CreateHostingPackage.as_view(),
name='create_hosting_package'), name='create_hosting_package'),
url(r'^allpackages/', url(r'^allpackages/',
@ -35,4 +34,4 @@ urlpatterns = patterns(
HostingOptionChoices.as_view(), name='hosting_option_choices'), HostingOptionChoices.as_view(), name='hosting_option_choices'),
url(r'^(?P<package>\d+)/add-option/(?P<type>\w+)/(?P<optionid>\d+)$', url(r'^(?P<package>\d+)/add-option/(?P<type>\w+)/(?P<optionid>\d+)$',
AddHostingOption.as_view(), name='add_hosting_option'), AddHostingOption.as_view(), name='add_hosting_option'),
) ]

View file

@ -32,7 +32,7 @@ class ReadOnlyPasswordHashField(forms.Field):
def bound_data(self, data, initial): def bound_data(self, data, initial):
return initial return initial
def _has_changed(self, initial, data): def has_changed(self, initial, data):
return False return False

View file

@ -52,7 +52,7 @@ class ReadOnlyPasswordHashFieldTest(TestCase):
def test__has_changed(self): def test__has_changed(self):
field = ReadOnlyPasswordHashField() field = ReadOnlyPasswordHashField()
self.assertFalse(field._has_changed('new', 'old')) self.assertFalse(field.has_changed('new', 'old'))
class CustomerTestCase(TestCase): class CustomerTestCase(TestCase):

View file

@ -5,7 +5,7 @@ views.
""" """
from __future__ import absolute_import, unicode_literals from __future__ import absolute_import, unicode_literals
from django.conf.urls import patterns, url from django.conf.urls import url
from .views import ( from .views import (
AddMailAddress, AddMailAddress,
@ -15,8 +15,7 @@ from .views import (
EditMailAddress, EditMailAddress,
) )
urlpatterns = patterns( urlpatterns = [
'',
url(r'^(?P<package>\d+)/mailbox/create$', url(r'^(?P<package>\d+)/mailbox/create$',
CreateMailbox.as_view(), name='create_mailbox'), CreateMailbox.as_view(), name='create_mailbox'),
url(r'^(?P<package>\d+)/mailbox/(?P<slug>[\w0-9]+)/setpassword$', url(r'^(?P<package>\d+)/mailbox/(?P<slug>[\w0-9]+)/setpassword$',
@ -29,4 +28,4 @@ urlpatterns = patterns(
url(r'^(?P<package>\d+)/mailaddress/(?P<domain>[\w0-9-.]+)/(?P<pk>\d+)' url(r'^(?P<package>\d+)/mailaddress/(?P<domain>[\w0-9-.]+)/(?P<pk>\d+)'
r'/delete$', r'/delete$',
DeleteMailAddress.as_view(), name='delete_mailaddress'), DeleteMailAddress.as_view(), name='delete_mailaddress'),
) ]

View file

@ -4,7 +4,7 @@ This module defines the URL patterns for operating system user related views.
""" """
from __future__ import absolute_import, unicode_literals from __future__ import absolute_import, unicode_literals
from django.conf.urls import patterns, url from django.conf.urls import url
from .views import ( from .views import (
AddSshPublicKey, AddSshPublicKey,
@ -15,8 +15,7 @@ from .views import (
) )
urlpatterns = patterns( urlpatterns = [
'',
url(r'^(?P<slug>[\w0-9@.+-_]+)/setpassword$', SetOsUserPassword.as_view(), url(r'^(?P<slug>[\w0-9@.+-_]+)/setpassword$', SetOsUserPassword.as_view(),
name='set_osuser_password'), name='set_osuser_password'),
url(r'^(?P<package>\d+)/ssh-keys/$', ListSshPublicKeys.as_view(), url(r'^(?P<package>\d+)/ssh-keys/$', ListSshPublicKeys.as_view(),
@ -27,4 +26,4 @@ urlpatterns = patterns(
EditSshPublicKeyComment.as_view(), name='edit_ssh_key_comment'), EditSshPublicKeyComment.as_view(), name='edit_ssh_key_comment'),
url(r'^(?P<package>\d+)/ssh-keys/(?P<pk>\d+)/delete$', url(r'^(?P<package>\d+)/ssh-keys/(?P<pk>\d+)/delete$',
DeleteSshPublicKey.as_view(), name='delete_ssh_key'), DeleteSshPublicKey.as_view(), name='delete_ssh_key'),
) ]

View file

@ -1,11 +1,12 @@
{% extends "account/base.html" %} {% extends "account/base.html" %}
{% load account crispy_forms_tags i18n %} {% load account socialaccount crispy_forms_tags i18n %}
{% block title %}{{ block.super }} - {% trans "Sign In" %}{% endblock title %} {% block title %}{{ block.super }} - {% trans "Sign In" %}{% endblock title %}
{% block page_title %}{% trans "Sign In" %}{% endblock page_title %} {% block page_title %}{% trans "Sign In" %}{% endblock page_title %}
{% block content %} {% block content %}
{% if socialaccount.providers %} {% get_providers as socialaccount_providers %}
{% if socialaccount_providers %}
<p>{% blocktrans with site.name as site_name %}Please sign in with one <p>{% blocktrans with site.name as site_name %}Please sign in with one
of your existing third party accounts. Or, <a href="{{ signup_url }}">sign up</a> of your existing third party accounts. Or, <a href="{{ signup_url }}">sign up</a>
for a {{site_name}} account and sign in below:{% endblocktrans %}</p> for a {{site_name}} account and sign in below:{% endblocktrans %}</p>

View file

@ -1,6 +1,7 @@
{% load socialaccount %} {% load socialaccount %}
{% for provider in socialaccount.providers %} {% get_providers as socialaccount_providers %}
{% for provider in socialaccount_providers %}
{% if provider.id == "openid" %} {% if provider.id == "openid" %}
{% for brand in provider.get_brands %} {% for brand in provider.get_brands %}
<li> <li>

View file

@ -4,7 +4,7 @@ This module defines the URL patterns for user database views.
""" """
from __future__ import absolute_import, unicode_literals from __future__ import absolute_import, unicode_literals
from django.conf.urls import patterns, url from django.conf.urls import url
from .views import ( from .views import (
AddUserDatabase, AddUserDatabase,
@ -12,12 +12,11 @@ from .views import (
DeleteUserDatabase, DeleteUserDatabase,
) )
urlpatterns = patterns( urlpatterns = [
'',
url(r'^(?P<package>\d+)/create$', url(r'^(?P<package>\d+)/create$',
AddUserDatabase.as_view(), name='add_userdatabase'), AddUserDatabase.as_view(), name='add_userdatabase'),
url(r'^(?P<package>\d+)/(?P<slug>[\w0-9]+)/setpassword', url(r'^(?P<package>\d+)/(?P<slug>[\w0-9]+)/setpassword',
ChangeDatabaseUserPassword.as_view(), name='change_dbuser_password'), ChangeDatabaseUserPassword.as_view(), name='change_dbuser_password'),
url(r'^(?P<package>\d+)/(?P<slug>[\w0-9]+)/delete', url(r'^(?P<package>\d+)/(?P<slug>[\w0-9]+)/delete',
DeleteUserDatabase.as_view(), name='delete_userdatabase'), DeleteUserDatabase.as_view(), name='delete_userdatabase'),
) ]

View file

@ -4,7 +4,7 @@ This module defines the URL patterns for website related views.
""" """
from __future__ import absolute_import, unicode_literals from __future__ import absolute_import, unicode_literals
from django.conf.urls import patterns, url from django.conf.urls import url
from .views import ( from .views import (
AddWebsite, AddWebsite,
@ -12,10 +12,9 @@ from .views import (
) )
urlpatterns = patterns( urlpatterns = [
'',
url(r'^(?P<package>\d+)/(?P<domain>[\w0-9.-]+)/create$', url(r'^(?P<package>\d+)/(?P<domain>[\w0-9.-]+)/create$',
AddWebsite.as_view(), name='add_website'), AddWebsite.as_view(), name='add_website'),
url(r'^(?P<package>\d+)/(?P<domain>[\w0-9.-]+)/(?P<pk>\d+)/delete$', url(r'^(?P<package>\d+)/(?P<domain>[\w0-9.-]+)/(?P<pk>\d+)/delete$',
DeleteWebsite.as_view(), name='delete_website'), DeleteWebsite.as_view(), name='delete_website'),
) ]

View file

@ -1,19 +1,20 @@
Django==1.8.6 Django==1.9
curtsies==0.1.21
bpython==0.14.2 bpython==0.14.2
django-braces==1.8.1 django-braces==1.8.1
django-model-utils==2.3.1 django-model-utils==2.4
django-crispy-forms==1.5.2 django-crispy-forms==1.5.2
logutils==0.3.3 logutils==0.3.3
psycopg2==2.6.1 psycopg2==2.6.1
passlib==1.6.5 passlib==1.6.5
celery==3.1.18 celery==3.1.19
billiard==3.3.0.20 billiard==3.3.0.22
kombu==3.0.27 kombu==3.0.32
pytz==2015.6 pytz==2015.7
pyaml==15.8.2 pyaml==15.8.2
django-allauth==0.21.0 django-allauth==0.24.1
oauthlib==1.0.3 oauthlib==1.0.3
python-openid==2.2.5 python-openid==2.2.5
requests==2.5.1 requests==2.9.0
requests-oauthlib==0.5.0 requests-oauthlib==0.6.0
simplejson==3.8.0 simplejson==3.8.1

View file

@ -1,7 +1,7 @@
# Local development dependencies go here # Local development dependencies go here
-r test.txt -r test.txt
django-debug-toolbar==1.4 django-debug-toolbar==1.4
sqlparse==0.1.16 sqlparse==0.1.18
Sphinx==1.3.1 Sphinx==1.3.3
snowballstemmer==1.2.0 snowballstemmer==1.2.0
releases==0.7.0 releases==1.0.0

View file

@ -1,4 +1,4 @@
# Test dependencies go here. # Test dependencies go here.
-r base.txt -r base.txt
coverage==4.0 coverage==4.0.3
mock==1.3.0 mock==1.3.0