From 1aed14f487ecd85fb55f6a824ba5b5c91abe82b1 Mon Sep 17 00:00:00 2001 From: Florian Eitel Date: Sat, 14 Jan 2023 13:23:41 +0100 Subject: [PATCH] Update to Django 4.0 --- Pipfile | 2 +- Pipfile.lock | 21 +++----- requirements.d/all.txt | 2 +- setup.py | 2 +- src/nsupdate/accounts/models.py | 4 +- src/nsupdate/accounts/registration_form.py | 2 +- src/nsupdate/accounts/urls.py | 18 +++---- src/nsupdate/accounts/views.py | 2 +- src/nsupdate/login/urls.py | 14 ++--- src/nsupdate/main/forms.py | 2 +- src/nsupdate/main/models.py | 2 +- src/nsupdate/main/urls.py | 60 ++++++++++----------- src/nsupdate/management/commands/domains.py | 2 +- src/nsupdate/management/commands/faults.py | 2 +- src/nsupdate/management/commands/hosts.py | 2 +- src/nsupdate/management/commands/users.py | 2 +- src/nsupdate/urls.py | 18 +++---- src/nsupdate/utils/_tests/test_mail.py | 2 +- 18 files changed, 76 insertions(+), 83 deletions(-) diff --git a/Pipfile b/Pipfile index 10adaa4..9bae646 100644 --- a/Pipfile +++ b/Pipfile @@ -6,7 +6,7 @@ name = "pypi" [packages] dnspython = "*" netaddr = "*" -django = "~=3.2.0" +django = "~=4.0.0" django-bootstrap-form = "*" django-referrer-policy = "*" django-registration-redux = "*" diff --git a/Pipfile.lock b/Pipfile.lock index 9d51d6d..f41314b 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "2d84c864a69bb0acaa84f8ef23dab9dd7c5311888976f1a0f022e3c8c39d6836" + "sha256": "5fbe7a1db419af7b2b43b27cfcd7e9e69e295019a597bdaf1d95c875513c75f8" }, "pipfile-spec": 6, "requires": { @@ -233,11 +233,11 @@ }, "django": { "hashes": [ - "sha256:18ba8efa36b69cfcd4b670d0fa187c6fe7506596f0ababe580e16909bcdec121", - "sha256:3adc285124244724a394fa9b9839cc8cd116faf7d159554c43ecdaa8cdf0b94d" + "sha256:07e6433f263c3839939cfabeb6d7557841e0419e47759a7b7d37f6d44d40adcb", + "sha256:27cb08fa6458c1eff8b97c4c2d03774646fb26feeaa4587dca10c49e6d4fc6a3" ], "index": "pypi", - "version": "==3.2.16" + "version": "==4.0.8" }, "django-bootstrap-form": { "hashes": [ @@ -331,13 +331,6 @@ ], "version": "==3.2.0" }, - "pytz": { - "hashes": [ - "sha256:01a0681c4b9684a28304615eba55d1ab31ae00bf68ec157ec3708a8182dbbcd0", - "sha256:78f4f37d8198e0627c5f1143240bb0206b8691d8d7ac6d78fee88b78733f8c4a" - ], - "version": "==2022.7.1" - }, "requests": { "hashes": [ "sha256:64299f4909223da747622c030b781c0d7811e359c37124b4bd368fb8c6518baa", @@ -571,11 +564,11 @@ }, "django": { "hashes": [ - "sha256:18ba8efa36b69cfcd4b670d0fa187c6fe7506596f0ababe580e16909bcdec121", - "sha256:3adc285124244724a394fa9b9839cc8cd116faf7d159554c43ecdaa8cdf0b94d" + "sha256:07e6433f263c3839939cfabeb6d7557841e0419e47759a7b7d37f6d44d40adcb", + "sha256:27cb08fa6458c1eff8b97c4c2d03774646fb26feeaa4587dca10c49e6d4fc6a3" ], "index": "pypi", - "version": "==3.2.16" + "version": "==4.0.8" }, "django-debug-toolbar": { "hashes": [ diff --git a/requirements.d/all.txt b/requirements.d/all.txt index 69120ac..2e0c57f 100644 --- a/requirements.d/all.txt +++ b/requirements.d/all.txt @@ -1,7 +1,7 @@ # packages always needed dnspython netaddr -django~=3.2.0 +django~=4.0.0 django-bootstrap-form django-referrer-policy django-registration-redux diff --git a/setup.py b/setup.py index d7ebbd4..040e604 100644 --- a/setup.py +++ b/setup.py @@ -31,7 +31,7 @@ setup( install_requires=[ 'dnspython', 'netaddr', - 'django>=3.2.0', + 'django>=4.0.0', 'django-bootstrap-form', 'django-referrer-policy', 'django-registration-redux', diff --git a/src/nsupdate/accounts/models.py b/src/nsupdate/accounts/models.py index 4c29a36..bf2120a 100644 --- a/src/nsupdate/accounts/models.py +++ b/src/nsupdate/accounts/models.py @@ -7,9 +7,9 @@ from django.conf import settings from django.db.models.signals import post_save from django.dispatch import receiver from django.contrib.auth.signals import user_logged_in -from django.utils.translation import ugettext_lazy as _ -from django.utils.translation import LANGUAGE_SESSION_KEY +from django.utils.translation import gettext_lazy as _ +LANGUAGE_SESSION_KEY = "_language" class UserProfile(models.Model): """ diff --git a/src/nsupdate/accounts/registration_form.py b/src/nsupdate/accounts/registration_form.py index d65a4cc..e32e458 100644 --- a/src/nsupdate/accounts/registration_form.py +++ b/src/nsupdate/accounts/registration_form.py @@ -7,7 +7,7 @@ logger = logging.getLogger(__name__) from django import forms from django.conf import settings -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from registration.forms import RegistrationForm diff --git a/src/nsupdate/accounts/urls.py b/src/nsupdate/accounts/urls.py index 22f2676..10573b6 100644 --- a/src/nsupdate/accounts/urls.py +++ b/src/nsupdate/accounts/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls import url +from django.urls import re_path from django.views.generic.base import TemplateView from registration.backends.default.views import ActivationView @@ -8,12 +8,12 @@ from .views import UserProfileView, DeleteUserView, UserChangePasswordView urlpatterns = ( - url(r'^profile/', UserProfileView.as_view(), name="account_profile"), - url(r'^settings/', UserChangePasswordView.as_view(), name='account_settings'), - url(r'^delete/', DeleteUserView.as_view(), name="account_delete"), + re_path(r'^profile/', UserProfileView.as_view(), name="account_profile"), + re_path(r'^settings/', UserChangePasswordView.as_view(), name='account_settings'), + re_path(r'^delete/', DeleteUserView.as_view(), name="account_delete"), # registration start - url(r'^activate/complete/$', + re_path(r'^activate/complete/$', TemplateView.as_view(template_name='registration/activation_complete.html'), name='registration_activation_complete'), # Activation keys get matched by \w+ instead of the more specific @@ -21,16 +21,16 @@ urlpatterns = ( # that way it can return a sensible "invalid key" message instead of a # confusing 404. - url(r'^activate/(?P\w+)/$', + re_path(r'^activate/(?P\w+)/$', ActivationView.as_view(), name='registration_activate'), - url(r'^register/$', + re_path(r'^register/$', RegistrationView.as_view(), name='registration_register'), - url(r'^register/complete/$', + re_path(r'^register/complete/$', TemplateView.as_view(template_name='registration/registration_complete.html'), name='registration_complete'), - url(r'^register/closed/$', + re_path(r'^register/closed/$', TemplateView.as_view(template_name='registration/registration_closed.html'), name='registration_disallowed'), # registration end diff --git a/src/nsupdate/accounts/views.py b/src/nsupdate/accounts/views.py index a02da32..dfeaf09 100644 --- a/src/nsupdate/accounts/views.py +++ b/src/nsupdate/accounts/views.py @@ -10,7 +10,7 @@ from django.views.decorators.debug import sensitive_post_parameters from django.urls import reverse, reverse_lazy from django.shortcuts import redirect from django.contrib import messages -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django.contrib.auth import update_session_auth_hash from .forms import UserForm, UserProfileForm diff --git a/src/nsupdate/login/urls.py b/src/nsupdate/login/urls.py index 03f0d76..d63d4bf 100644 --- a/src/nsupdate/login/urls.py +++ b/src/nsupdate/login/urls.py @@ -1,25 +1,25 @@ # -*- coding: utf-8 -*- -from django.conf.urls import url +from django.urls import re_path from django.contrib.auth.views import LoginView, LogoutView, \ PasswordResetView, PasswordResetDoneView, PasswordResetConfirmView, PasswordResetCompleteView urlpatterns = ( # login and logout url - url(r'^login/$', LoginView.as_view(template_name='login.html'), name='login'), + re_path(r'^login/$', LoginView.as_view(template_name='login.html'), name='login'), # or use logout with template 'logout.html' - url(r'^logout/$', LogoutView.as_view(), name='logout'), + re_path(r'^logout/$', LogoutView.as_view(), name='logout'), # password reset urls - url(r'^password_reset/$', + re_path(r'^password_reset/$', PasswordResetView.as_view(template_name='password_reset.html'), name='password_reset'), - url(r'^password_reset_done/$', + re_path(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.+)/$', + re_path(r'^password_reset_confirm/(?P[0-9A-Za-z_\-]+)/(?P.+)/$', PasswordResetConfirmView.as_view(template_name='password_reset_confirm.html'), name='password_reset_confirm'), - url(r'^password_reset_complete/$', + re_path(r'^password_reset_complete/$', PasswordResetCompleteView.as_view(template_name='password_reset_complete.html'), name='password_reset_complete'), ) diff --git a/src/nsupdate/main/forms.py b/src/nsupdate/main/forms.py index 7944198..0028d99 100644 --- a/src/nsupdate/main/forms.py +++ b/src/nsupdate/main/forms.py @@ -6,7 +6,7 @@ form definitions (which fields are available, order, autofocus, ...) import binascii from django import forms -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from .models import Host, RelatedHost, Domain, ServiceUpdaterHostConfig from .dnstools import check_domain, NameServerNotAvailable diff --git a/src/nsupdate/main/models.py b/src/nsupdate/main/models.py index 4092981..1492e59 100644 --- a/src/nsupdate/main/models.py +++ b/src/nsupdate/main/models.py @@ -17,7 +17,7 @@ from django.conf import settings from django.db.models.signals import pre_delete, post_save from django.contrib.auth.hashers import make_password from django.utils.timezone import now -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from . import dnstools diff --git a/src/nsupdate/main/urls.py b/src/nsupdate/main/urls.py index 974f919..456489d 100644 --- a/src/nsupdate/main/urls.py +++ b/src/nsupdate/main/urls.py @@ -2,7 +2,7 @@ main app url dispatching """ -from django.conf.urls import url +from django.urls import re_path from .views import ( HomeView, OverviewView, HostView, AddHostView, DeleteHostView, AboutView, GenerateSecretView, GenerateNSSecretView, @@ -16,39 +16,39 @@ from ..api.views import ( urlpatterns = ( # interactive web ui - url(r'^$', HomeView.as_view(), name="home"), - url(r'^about/$', AboutView.as_view(), name="about"), - url(r'^custom/(?P