From 04c7d35e0e6958bf0752cd69f3ad2e291df4e5e6 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sun, 30 Sep 2018 22:16:28 +0200 Subject: [PATCH 1/6] add py37 / Django 2.1 to travis, restructure matrix --- .travis.yml | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/.travis.yml b/.travis.yml index be30c4e..98ab236 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,16 +4,6 @@ language: python os: linux -dist: trusty - -python: - - "2.7" - - "pypy" - - "3.4" - - "3.5" - - "3.6" - - "3.6-dev" - env: global: - SECRET_KEY=justfortravis @@ -22,24 +12,24 @@ env: - TEST_K="not ddns_client" - TEST_OPTS="" - COVERAGE="" - matrix: - - DJANGO=1.11 matrix: - exclude: - - python: "2.7" - env: DJANGO=1.11 - - python: "3.6" - env: DJANGO=1.11 - - python: "3.6-dev" - env: DJANGO=1.11 include: - python: "2.7" + dist: trusty env: DJANGO=1.11 COVERAGE="coverage run -m" TEST_K="not ddns_client" TEST_OPTS="--pep8" - - python: "3.6" + - python: "3.4" + dist: trusty env: DJANGO=1.11 - - python: "3.6-dev" - env: DJANGO=2.0 + - python: "3.5" + dist: trusty + env: DJANGO=1.11 + - python: "3.6" + dist: trusty + env: DJANGO=1.11 + - python: "3.7" + dist: xenial + env: DJANGO=2.1 install: - ./scripts/travis/install.sh From fb0967c0eccc01c095172e3f270bec1d4db1fa51 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sun, 30 Sep 2018 23:04:28 +0200 Subject: [PATCH 2/6] setup.py: don't require a specific Django version, so 1.1 and 2.x works also add py37 to pypi metadata. --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 414dbd0..6e61d26 100644 --- a/setup.py +++ b/setup.py @@ -48,7 +48,7 @@ setup( install_requires=[ 'dnspython', 'netaddr', - 'django~=1.11.0', + 'django', 'django-bootstrap-form', 'django-registration-redux', 'django-extensions', @@ -68,6 +68,7 @@ setup( 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', 'Topic :: Internet :: Name Service (DNS)', ], ) From d8bb17730195ef1ac384a88f5759d67f2fab9e98 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Fri, 19 Oct 2018 22:03:21 +0200 Subject: [PATCH 3/6] django 2.0 requires on_delete arg for ForeignKey/OneToOneField the default in django 1.11 is models.CASCADE. note: updated migrations, the models already had the required change. --- nsupdate/accounts/migrations/0001_initial.py | 2 +- nsupdate/main/migrations/0001_initial.py | 18 +++++++++--------- .../main/migrations/0002_auto_20141115_2227.py | 18 +++++++++--------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/nsupdate/accounts/migrations/0001_initial.py b/nsupdate/accounts/migrations/0001_initial.py index f781589..e58f75b 100644 --- a/nsupdate/accounts/migrations/0001_initial.py +++ b/nsupdate/accounts/migrations/0001_initial.py @@ -15,7 +15,7 @@ class Migration(migrations.Migration): migrations.CreateModel( name='UserProfile', fields=[ - ('user', models.OneToOneField(related_name='profile', primary_key=True, serialize=False, to=settings.AUTH_USER_MODEL, verbose_name='user')), + ('user', models.OneToOneField(related_name='profile', primary_key=True, serialize=False, to=settings.AUTH_USER_MODEL, verbose_name='user', on_delete=models.CASCADE)), ('language', models.CharField(default=b'', choices=[(b'en', b'English'), (b'de', b'German'), (b'fr', b'French'), (b'it', b'Italian'), (b'pl', b'Polish'), (b'zh-cn', b'Chinese (China)')], max_length=10, blank=True, null=True, verbose_name='language')), ], options={ diff --git a/nsupdate/main/migrations/0001_initial.py b/nsupdate/main/migrations/0001_initial.py index 349529c..1f08a0a 100644 --- a/nsupdate/main/migrations/0001_initial.py +++ b/nsupdate/main/migrations/0001_initial.py @@ -21,7 +21,7 @@ class Migration(migrations.Migration): ('name_re', models.CharField(help_text='Blacklisted domain. Evaluated as regex (search).', unique=True, max_length=255)), ('last_update', models.DateTimeField(auto_now=True)), ('created', models.DateTimeField(auto_now_add=True)), - ('created_by', models.ForeignKey(related_name=u'blacklisted_domains', to=settings.AUTH_USER_MODEL)), + ('created_by', models.ForeignKey(related_name=u'blacklisted_domains', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)), ], options={ }, @@ -40,7 +40,7 @@ class Migration(migrations.Migration): ('comment', models.CharField(default=b'', max_length=255, null=True, help_text='Some arbitrary comment about your domain. If your domain is public, the comment will be also publicly shown.', blank=True)), ('last_update', models.DateTimeField(auto_now=True)), ('created', models.DateTimeField(auto_now_add=True)), - ('created_by', models.ForeignKey(related_name=u'domains', to=settings.AUTH_USER_MODEL)), + ('created_by', models.ForeignKey(related_name=u'domains', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)), ], options={ }, @@ -68,8 +68,8 @@ class Migration(migrations.Migration): ('tls_update_ipv6', models.BooleanField(default=False)), ('last_update', models.DateTimeField(auto_now=True)), ('created', models.DateTimeField(auto_now_add=True)), - ('created_by', models.ForeignKey(related_name=u'hosts', to=settings.AUTH_USER_MODEL)), - ('domain', models.ForeignKey(to='main.Domain')), + ('created_by', models.ForeignKey(related_name=u'hosts', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)), + ('domain', models.ForeignKey(to='main.Domain', on_delete=models.CASCADE)), ], options={ }, @@ -84,7 +84,7 @@ class Migration(migrations.Migration): ('interface_id_ipv4', models.CharField(default=b'', help_text='The IPv4 interface ID of this host. Use IPv4 notation.', max_length=16)), ('interface_id_ipv6', models.CharField(default=b'', help_text='The IPv6 interface ID of this host. Use IPv6 notation.', max_length=22)), ('available', models.BooleanField(default=True, help_text="Check if host is available/in use - if not checked, we won't accept updates for this host")), - ('main_host', models.ForeignKey(related_name=u'relatedhosts', to='main.Host')), + ('main_host', models.ForeignKey(related_name=u'relatedhosts', to='main.Host', on_delete=models.CASCADE)), ], options={ }, @@ -103,7 +103,7 @@ class Migration(migrations.Migration): ('accept_ipv6', models.BooleanField(default=False)), ('last_update', models.DateTimeField(auto_now=True)), ('created', models.DateTimeField(auto_now_add=True)), - ('created_by', models.ForeignKey(related_name=u'serviceupdater', to=settings.AUTH_USER_MODEL)), + ('created_by', models.ForeignKey(related_name=u'serviceupdater', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)), ], options={ }, @@ -121,9 +121,9 @@ class Migration(migrations.Migration): ('give_ipv6', models.BooleanField(default=False)), ('last_update', models.DateTimeField(auto_now=True)), ('created', models.DateTimeField(auto_now_add=True)), - ('created_by', models.ForeignKey(related_name=u'serviceupdaterhostconfigs', to=settings.AUTH_USER_MODEL)), - ('host', models.ForeignKey(related_name=u'serviceupdaterhostconfigs', to='main.Host')), - ('service', models.ForeignKey(to='main.ServiceUpdater')), + ('created_by', models.ForeignKey(related_name=u'serviceupdaterhostconfigs', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)), + ('host', models.ForeignKey(related_name=u'serviceupdaterhostconfigs', to='main.Host', on_delete=models.CASCADE)), + ('service', models.ForeignKey(to='main.ServiceUpdater', on_delete=models.CASCADE)), ], options={ }, diff --git a/nsupdate/main/migrations/0002_auto_20141115_2227.py b/nsupdate/main/migrations/0002_auto_20141115_2227.py index 3a36899..913291c 100644 --- a/nsupdate/main/migrations/0002_auto_20141115_2227.py +++ b/nsupdate/main/migrations/0002_auto_20141115_2227.py @@ -47,7 +47,7 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='blacklistedhost', name='created_by', - field=models.ForeignKey(related_name='blacklisted_domains', verbose_name='created by', to=settings.AUTH_USER_MODEL), + field=models.ForeignKey(related_name='blacklisted_domains', verbose_name='created by', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE), preserve_default=True, ), migrations.AlterField( @@ -83,7 +83,7 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='domain', name='created_by', - field=models.ForeignKey(related_name='domains', verbose_name='created by', to=settings.AUTH_USER_MODEL), + field=models.ForeignKey(related_name='domains', verbose_name='created by', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE), preserve_default=True, ), migrations.AlterField( @@ -167,13 +167,13 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='host', name='created_by', - field=models.ForeignKey(related_name='hosts', verbose_name='created by', to=settings.AUTH_USER_MODEL), + field=models.ForeignKey(related_name='hosts', verbose_name='created by', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE), preserve_default=True, ), migrations.AlterField( model_name='host', name='domain', - field=models.ForeignKey(verbose_name='domain', to='main.Domain'), + field=models.ForeignKey(verbose_name='domain', to='main.Domain', on_delete=models.CASCADE), preserve_default=True, ), migrations.AlterField( @@ -269,7 +269,7 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='relatedhost', name='main_host', - field=models.ForeignKey(related_name='relatedhosts', verbose_name='main host', to='main.Host'), + field=models.ForeignKey(related_name='relatedhosts', verbose_name='main host', to='main.Host', on_delete=models.CASCADE), preserve_default=True, ), migrations.AlterField( @@ -305,7 +305,7 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='serviceupdater', name='created_by', - field=models.ForeignKey(related_name='serviceupdater', verbose_name='created by', to=settings.AUTH_USER_MODEL), + field=models.ForeignKey(related_name='serviceupdater', verbose_name='created by', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE), preserve_default=True, ), migrations.AlterField( @@ -353,7 +353,7 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='serviceupdaterhostconfig', name='created_by', - field=models.ForeignKey(related_name='serviceupdaterhostconfigs', verbose_name='created by', to=settings.AUTH_USER_MODEL), + field=models.ForeignKey(related_name='serviceupdaterhostconfigs', verbose_name='created by', to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE), preserve_default=True, ), migrations.AlterField( @@ -371,7 +371,7 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='serviceupdaterhostconfig', name='host', - field=models.ForeignKey(related_name='serviceupdaterhostconfigs', verbose_name='host', to='main.Host'), + field=models.ForeignKey(related_name='serviceupdaterhostconfigs', verbose_name='host', to='main.Host', on_delete=models.CASCADE), preserve_default=True, ), migrations.AlterField( @@ -401,7 +401,7 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='serviceupdaterhostconfig', name='service', - field=models.ForeignKey(verbose_name='service', to='main.ServiceUpdater'), + field=models.ForeignKey(verbose_name='service', to='main.ServiceUpdater', on_delete=models.CASCADE), preserve_default=True, ), ] From 896531276fd09b24a7fe62880428a042fd92f88c Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Fri, 19 Oct 2018 22:29:18 +0200 Subject: [PATCH 4/6] django 2.0 does not allow giving a 3-tuple to include() --- nsupdate/urls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nsupdate/urls.py b/nsupdate/urls.py index bd559e3..dc1afda 100644 --- a/nsupdate/urls.py +++ b/nsupdate/urls.py @@ -29,7 +29,7 @@ urlpatterns = [ url(r'^accounts/', include('nsupdate.login.urls')), # registration and user settings url(r'^account/', include('nsupdate.accounts.urls')), - url(r'^admin/', include(admin.site.urls)), + url(r'^admin/', include((admin.site.get_urls(), 'admin'), namespace='admin')), url(r'^i18n/', include('django.conf.urls.i18n')), url(r'^', include('nsupdate.main.urls')), ] From 9a6772b74a1c64a4599431122eb574b35202a5b5 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Fri, 19 Oct 2018 22:58:41 +0200 Subject: [PATCH 5/6] django 2.0 does not have these view functions any more, use classes --- nsupdate/login/urls.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/nsupdate/login/urls.py b/nsupdate/login/urls.py index 9ecd129..5695bf3 100644 --- a/nsupdate/login/urls.py +++ b/nsupdate/login/urls.py @@ -1,22 +1,22 @@ # -*- coding: utf-8 -*- from django.conf.urls import url -from django.contrib.auth.views import login, logout, password_reset, password_reset_done, \ - password_reset_confirm, password_reset_complete +from django.contrib.auth.views import LoginView, LogoutView, \ + PasswordResetView, PasswordResetDoneView, PasswordResetConfirmView, PasswordResetCompleteView urlpatterns = ( # login and logout url - url(r'^login/$', login, {'template_name': 'login.html'}, name='login'), + url(r'^login/$', LoginView.as_view(), {'template_name': 'login.html'}, name='login'), # or use logout with template 'logout.html' - url(r'^logout/$', logout, name='logout'), + url(r'^logout/$', LogoutView.as_view(), name='logout'), # password reset urls - url(r'^password_reset/$', password_reset, {'template_name': 'password_reset.html'}, + url(r'^password_reset/$', PasswordResetView.as_view(), {'template_name': 'password_reset.html'}, name='password_reset'), - url(r'^password_reset_done/$', password_reset_done, + url(r'^password_reset_done/$', PasswordResetDoneView.as_view(), {'template_name': 'password_reset_done.html'}, name='password_reset_done'), url(r'^password_reset_confirm/(?P[0-9A-Za-z_\-]+)/(?P.+)/$', - password_reset_confirm, {'template_name': 'password_reset_confirm.html'}, + PasswordResetConfirmView.as_view(), {'template_name': 'password_reset_confirm.html'}, name='password_reset_confirm'), - url(r'^password_reset_complete/$', password_reset_complete, + url(r'^password_reset_complete/$', PasswordResetCompleteView.as_view(), {'template_name': 'password_reset_complete.html'}, name='password_reset_complete'), ) From 6ecee32398403632e8bad0223e13ff6bbcdba8d7 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Fri, 19 Oct 2018 23:37:29 +0200 Subject: [PATCH 6/6] use new MIDDLEWARE setting (since Django 1.10) MIDDLEWARE_CLASSES was removed in Django 2.0. --- nsupdate/settings/base.py | 2 +- nsupdate/settings/dev.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nsupdate/settings/base.py b/nsupdate/settings/base.py index b4576b2..1da50c9 100644 --- a/nsupdate/settings/base.py +++ b/nsupdate/settings/base.py @@ -156,7 +156,7 @@ TEMPLATES = [ }, ] -MIDDLEWARE_CLASSES = ( +MIDDLEWARE = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware', diff --git a/nsupdate/settings/dev.py b/nsupdate/settings/dev.py index 7d8c11f..19d236b 100644 --- a/nsupdate/settings/dev.py +++ b/nsupdate/settings/dev.py @@ -19,9 +19,9 @@ WWW_IPV6_HOST = 'ip6-localhost:8000' # ALLOWED_HOSTS is not needed here, as DEBUG is True -MIDDLEWARE_CLASSES = ( +MIDDLEWARE = ( 'debug_toolbar.middleware.DebugToolbarMiddleware', -) + MIDDLEWARE_CLASSES +) + MIDDLEWARE INTERNAL_IPS = ['127.0.0.1', '::1', ] # needed for DebugToolbar! DEBUG_TOOLBAR_PATCH_SETTINGS = False