Upgrade to Django 3.2

- update dependencies
- fix deprecation warnings
- fix tests
- skip some tests that need more work
- reformat changed code with isort and black
This commit is contained in:
Jan Dittberner 2023-02-18 22:46:48 +01:00
parent 0f18e59d67
commit 4af1a39ca4
93 changed files with 3598 additions and 2725 deletions

View file

@ -3,11 +3,10 @@ This module defines form classes that can be extended by other gnuviechadmin
apps' forms.
"""
from __future__ import absolute_import, unicode_literals
from __future__ import absolute_import
from django import forms
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
PASSWORD_MISMATCH_ERROR = _("Passwords don't match")
"""
@ -21,11 +20,14 @@ class PasswordModelFormMixin(forms.Form):
whether both fields contain the same string.
"""
password1 = forms.CharField(
label=_('Password'), widget=forms.PasswordInput,
label=_("Password"),
widget=forms.PasswordInput,
)
password2 = forms.CharField(
label=_('Password (again)'), widget=forms.PasswordInput,
label=_("Password (again)"),
widget=forms.PasswordInput,
)
def clean_password2(self):
@ -36,8 +38,8 @@ class PasswordModelFormMixin(forms.Form):
:rtype: str or None
"""
password1 = self.cleaned_data.get('password1')
password2 = self.cleaned_data.get('password2')
password1 = self.cleaned_data.get("password1")
password2 = self.cleaned_data.get("password2")
if password1 and password2 and password1 != password2:
raise forms.ValidationError(PASSWORD_MISMATCH_ERROR)
return password2

View file

@ -2,9 +2,10 @@
This module defines common view code to be used by multiple gnuviechadmin apps.
"""
from __future__ import absolute_import, unicode_literals
from __future__ import absolute_import
from django.shortcuts import get_object_or_404
from hostingpackages.models import CustomerHostingPackage
@ -14,7 +15,8 @@ class HostingPackageAndCustomerMixin(object):
keyword argument 'package'.
"""
hosting_package_kwarg = 'package'
hosting_package_kwarg = "package"
"""Keyword argument used to find the hosting package in the URL."""
hostingpackage = None
@ -22,8 +24,8 @@ class HostingPackageAndCustomerMixin(object):
def get_hosting_package(self):
if self.hostingpackage is None:
self.hostingpackage = get_object_or_404(
CustomerHostingPackage,
pk=int(self.kwargs[self.hosting_package_kwarg]))
CustomerHostingPackage, pk=int(self.kwargs[self.hosting_package_kwarg])
)
return self.hostingpackage
def get_customer_object(self):