Compare commits

..

4 commits

Author SHA1 Message Date
affb49a971 Update to Django 4.2
- fix deprecation warnings
- update dependencies
2023-07-08 19:21:02 +02:00
8aadae1c83 Fix Django4 deprecation warnings 2023-07-08 18:34:12 +02:00
30ffdf1751 Update dependencies 2023-07-08 17:01:49 +02:00
aed8e97dbc Fix Poetry deprecation warning 2023-07-08 16:59:04 +02:00
11 changed files with 526 additions and 619 deletions

View file

@ -7,6 +7,7 @@ from __future__ import absolute_import, unicode_literals
from crispy_forms.helper import FormHelper from crispy_forms.helper import FormHelper
from crispy_forms.layout import Submit from crispy_forms.layout import Submit
from django import forms from django import forms
from django.apps import apps
from django.conf import settings from django.conf import settings
from django.contrib.sites.models import Site from django.contrib.sites.models import Site
from django.contrib.sites.requests import RequestSite from django.contrib.sites.requests import RequestSite
@ -41,7 +42,7 @@ class ContactForm(forms.Form):
def get_context(self): def get_context(self):
if not self.is_valid(): if not self.is_valid():
raise ValueError("Cannot generate context from invalid contact form") raise ValueError("Cannot generate context from invalid contact form")
if Site._meta.installed: if apps.is_installed("django.contrib.sites"):
site = Site.objects.get_current() site = Site.objects.get_current()
else: else:
site = RequestSite(self.request) site = RequestSite(self.request)

View file

@ -76,9 +76,6 @@ SITES_SITE_NAME = get_env_variable("GVA_SITE_NAME")
# See: https://docs.djangoproject.com/en/dev/ref/settings/#use-i18n # See: https://docs.djangoproject.com/en/dev/ref/settings/#use-i18n
USE_I18N = True USE_I18N = True
# See: https://docs.djangoproject.com/en/dev/ref/settings/#use-l10n
USE_L10N = True
# See: https://docs.djangoproject.com/en/dev/ref/settings/#use-tz # See: https://docs.djangoproject.com/en/dev/ref/settings/#use-tz
USE_TZ = True USE_TZ = True
# ######### END GENERAL CONFIGURATION # ######### END GENERAL CONFIGURATION

View file

@ -1,7 +1,7 @@
from django.contrib import admin from django.contrib import admin
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import gettext_lazy as _
from help.models import HelpUser from help.models import HelpUser

View file

@ -2,7 +2,7 @@ import uuid
from django.conf import settings from django.conf import settings
from django.db import models from django.db import models
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import gettext_lazy as _
class HelpUser(models.Model): class HelpUser(models.Model):

View file

@ -16,37 +16,54 @@ User = get_user_model()
class CustomerHostingPackageTest(TestCase): class CustomerHostingPackageTest(TestCase):
def test_get_disk_space_bytes(self): def setUp(self) -> None:
package = CustomerHostingPackage( self.user = User.objects.create(username="test")
diskspace=10, diskspace_unit=DISK_SPACE_UNITS.G self.template = HostingPackageTemplate.objects.create(
mailboxcount=10,
diskspace=100,
diskspace_unit=DISK_SPACE_UNITS.M,
description="Test package 1 - Description",
name="Test package 1",
) )
self.assertEqual(package.get_disk_space(), 10 * 1024**3)
def test_get_disk_space_mib(self): @override_settings(OSUSER_DEFAULT_GROUPS=[])
package = CustomerHostingPackage( def test_get_disk_space_bytes(self):
diskspace=10, diskspace_unit=DISK_SPACE_UNITS.G self.template.diskspace = 10
self.template.diskspace_unit = DISK_SPACE_UNITS.G
self.template.save()
package = CustomerHostingPackage.objects.create_from_template(
customer=self.user, template=self.template, name="customer",
) )
package.save()
self.assertEqual(package.get_disk_space(), 10 * 1024 ** 3)
@override_settings(OSUSER_DEFAULT_GROUPS=[])
def test_get_disk_space_mib(self):
self.template.diskspace = 10
self.template.diskspace_unit = DISK_SPACE_UNITS.G
self.template.save()
package = CustomerHostingPackage.objects.create_from_template(
customer=self.user, template=self.template, name="customer",
)
package.save()
self.assertEqual(package.get_disk_space(DISK_SPACE_UNITS.M), 10 * 1024) self.assertEqual(package.get_disk_space(DISK_SPACE_UNITS.M), 10 * 1024)
@override_settings(OSUSER_DEFAULT_GROUPS=[])
def test_get_quota(self): def test_get_quota(self):
package = CustomerHostingPackage( self.template.diskspace = 256
diskspace=256, diskspace_unit=DISK_SPACE_UNITS.M self.template.diskspace_unit = DISK_SPACE_UNITS.M
self.template.save()
package = CustomerHostingPackage.objects.create_from_template(
customer=self.user, template=self.template, name="customer",
) )
package.save()
self.assertEqual(package.get_quota(), (262144, 275251)) self.assertEqual(package.get_quota(), (262144, 275251))
@override_settings(OSUSER_DEFAULT_GROUPS=["testgroup"]) @override_settings(OSUSER_DEFAULT_GROUPS=["testgroup"])
def test_additional_group_not_defined(self): def test_additional_group_not_defined(self):
user = User.objects.create(username="test")
template = HostingPackageTemplate.objects.create(
description="Test package 1 - Description",
mailboxcount=10,
diskspace=100,
diskspace_unit=DISK_SPACE_UNITS.M,
name="Test package 1",
)
with self.assertRaises(ImproperlyConfigured) as ctx: with self.assertRaises(ImproperlyConfigured) as ctx:
package = CustomerHostingPackage.objects.create_from_template( package = CustomerHostingPackage.objects.create_from_template(
customer=user, template=template, name="Test customer package" customer=self.user, template=self.template, name="Test customer package",
) )
package.save() package.save()
self.assertIn("testgroup", str(ctx.exception)) self.assertIn("testgroup", str(ctx.exception))

View file

@ -1,5 +1,5 @@
from django.apps import AppConfig from django.apps import AppConfig
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import gettext_lazy as _
class InvoiceConfig(AppConfig): class InvoiceConfig(AppConfig):

View file

@ -3,7 +3,7 @@ from django.conf import settings
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.core.validators import FileExtensionValidator from django.core.validators import FileExtensionValidator
from django.db import models from django.db import models
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import gettext_lazy as _
CURRENCIES = [(1, "EUR")] CURRENCIES = [(1, "EUR")]

View file

@ -140,7 +140,7 @@ class MailAddressTest(TestCaseWithCeleryTasks):
def get_target(maf): def get_target(maf):
return maf.target return maf.target
self.assertQuerysetEqual( self.assertQuerySetEqual(
ma.mailaddressforward_set.all(), ["test2@example.org"], get_target ma.mailaddressforward_set.all(), ["test2@example.org"], get_target
) )
@ -152,7 +152,7 @@ class MailAddressTest(TestCaseWithCeleryTasks):
def get_target(maf): def get_target(maf):
return maf.target return maf.target
self.assertQuerysetEqual( self.assertQuerySetEqual(
ma.mailaddressforward_set.all(), ["test2@example.org"], get_target ma.mailaddressforward_set.all(), ["test2@example.org"], get_target
) )
@ -165,7 +165,7 @@ class MailAddressTest(TestCaseWithCeleryTasks):
def get_target(maf): def get_target(maf):
return maf.target return maf.target
self.assertQuerysetEqual( self.assertQuerySetEqual(
ma.mailaddressforward_set.all(), ["test3@example.org"], get_target ma.mailaddressforward_set.all(), ["test3@example.org"], get_target
) )
@ -178,7 +178,7 @@ class MailAddressTest(TestCaseWithCeleryTasks):
def get_target(maf): def get_target(maf):
return maf.target return maf.target
self.assertQuerysetEqual( self.assertQuerySetEqual(
ma.mailaddressforward_set.all(), ma.mailaddressforward_set.all(),
["test2@example.org", "test3@example.org"], ["test2@example.org", "test3@example.org"],
get_target, get_target,
@ -198,7 +198,7 @@ class MailAddressTest(TestCaseWithCeleryTasks):
def get_target(maf): def get_target(maf):
return maf.target return maf.target
self.assertQuerysetEqual( self.assertQuerySetEqual(
ma.mailaddressforward_set.all(), ["test2@example.org"], get_target ma.mailaddressforward_set.all(), ["test2@example.org"], get_target
) )
@ -213,7 +213,6 @@ class MailAddressTest(TestCaseWithCeleryTasks):
md = MailDomain.objects.create(domain="example.org") md = MailDomain.objects.create(domain="example.org")
ma = MailAddress(localpart="test", domain=md) ma = MailAddress(localpart="test", domain=md)
mafwds = ma.set_forward_addresses(["test2@example.org"], commit=False) mafwds = ma.set_forward_addresses(["test2@example.org"], commit=False)
self.assertEqual(ma.mailaddressforward_set.count(), 0)
self.assertEqual(mafwds[0].target, "test2@example.org") self.assertEqual(mafwds[0].target, "test2@example.org")
@ -242,14 +241,14 @@ class MailboxManagerTest(TestCaseWithCeleryTasks):
md = MailDomain.objects.create(domain="example.org") md = MailDomain.objects.create(domain="example.org")
address = MailAddress.objects.create(localpart="test", domain=md) address = MailAddress.objects.create(localpart="test", domain=md)
mailboxes = Mailbox.objects.unused_or_own(address, self.user) mailboxes = Mailbox.objects.unused_or_own(address, self.user)
self.assertQuerysetEqual(mailboxes, []) self.assertQuerySetEqual(mailboxes, [])
def test_unused_or_own_unassigned(self): def test_unused_or_own_unassigned(self):
md = MailDomain.objects.create(domain="example.org") md = MailDomain.objects.create(domain="example.org")
address = MailAddress.objects.create(localpart="test", domain=md) address = MailAddress.objects.create(localpart="test", domain=md)
mailboxes = [Mailbox.objects.create_mailbox(self.user) for _ in range(2)] mailboxes = [Mailbox.objects.create_mailbox(self.user) for _ in range(2)]
assignable = Mailbox.objects.unused_or_own(address, self.user) assignable = Mailbox.objects.unused_or_own(address, self.user)
self.assertQuerysetEqual( self.assertQuerySetEqual(
assignable, [repr(mb) for mb in mailboxes], transform=repr assignable, [repr(mb) for mb in mailboxes], transform=repr
) )
@ -259,7 +258,7 @@ class MailboxManagerTest(TestCaseWithCeleryTasks):
mailboxes = [Mailbox.objects.create_mailbox(self.user) for _ in range(2)] mailboxes = [Mailbox.objects.create_mailbox(self.user) for _ in range(2)]
address.set_mailbox(mailboxes[0]) address.set_mailbox(mailboxes[0])
assignable = Mailbox.objects.unused_or_own(address, self.user) assignable = Mailbox.objects.unused_or_own(address, self.user)
self.assertQuerysetEqual( self.assertQuerySetEqual(
assignable, [repr(mb) for mb in mailboxes], transform=repr assignable, [repr(mb) for mb in mailboxes], transform=repr
) )
@ -270,16 +269,16 @@ class MailboxManagerTest(TestCaseWithCeleryTasks):
mailboxes = [Mailbox.objects.create_mailbox(self.user) for _ in range(2)] mailboxes = [Mailbox.objects.create_mailbox(self.user) for _ in range(2)]
address2.set_mailbox(mailboxes[0]) address2.set_mailbox(mailboxes[0])
assignable = Mailbox.objects.unused_or_own(address, self.user) assignable = Mailbox.objects.unused_or_own(address, self.user)
self.assertQuerysetEqual(assignable, [repr(mailboxes[1])], transform=repr) self.assertQuerySetEqual(assignable, [repr(mailboxes[1])], transform=repr)
def test_unused_fresh(self): def test_unused_fresh(self):
mailboxes = Mailbox.objects.unused(self.user) mailboxes = Mailbox.objects.unused(self.user)
self.assertQuerysetEqual(mailboxes, []) self.assertQuerySetEqual(mailboxes, [])
def test_unused_unassigned(self): def test_unused_unassigned(self):
mailbox = Mailbox.objects.create_mailbox(self.user) mailbox = Mailbox.objects.create_mailbox(self.user)
mailboxes = Mailbox.objects.unused(self.user) mailboxes = Mailbox.objects.unused(self.user)
self.assertQuerysetEqual(mailboxes, [repr(mailbox)], transform=repr) self.assertQuerySetEqual(mailboxes, [repr(mailbox)], transform=repr)
def test_unused_assigned(self): def test_unused_assigned(self):
md = MailDomain.objects.create(domain="example.org") md = MailDomain.objects.create(domain="example.org")
@ -287,7 +286,7 @@ class MailboxManagerTest(TestCaseWithCeleryTasks):
mailboxes = [Mailbox.objects.create_mailbox(self.user) for _ in range(2)] mailboxes = [Mailbox.objects.create_mailbox(self.user) for _ in range(2)]
address.set_mailbox(mailboxes[0]) address.set_mailbox(mailboxes[0])
assignable = Mailbox.objects.unused(self.user) assignable = Mailbox.objects.unused(self.user)
self.assertQuerysetEqual(assignable, [repr(mailboxes[1])], transform=repr) self.assertQuerySetEqual(assignable, [repr(mailboxes[1])], transform=repr)
def test_create_mailbox_no_password(self): def test_create_mailbox_no_password(self):
mailbox = Mailbox.objects.create_mailbox(self.user) mailbox = Mailbox.objects.create_mailbox(self.user)

View file

@ -166,7 +166,7 @@ class DeleteSshPublicKeyTest(HostingPackageAwareTestMixin, TestCase):
kwargs={"package": str(self.package.pk), "pk": str(self.sshkey.pk)}, kwargs={"package": str(self.package.pk), "pk": str(self.sshkey.pk)},
) )
queryset = view.get_queryset() queryset = view.get_queryset()
self.assertQuerysetEqual(queryset, [repr(self.sshkey)], transform=repr) self.assertQuerySetEqual(queryset, [repr(self.sshkey)], transform=repr)
def test_get_context_data(self): def test_get_context_data(self):
self.client.login(username=TEST_USER, password=TEST_PASSWORD) self.client.login(username=TEST_USER, password=TEST_PASSWORD)
@ -234,7 +234,7 @@ class EditSshPublicKeyCommentTest(HostingPackageAwareTestMixin, TransactionTestC
kwargs={"package": str(self.package.pk), "pk": str(self.sshkey.pk)}, kwargs={"package": str(self.package.pk), "pk": str(self.sshkey.pk)},
) )
queryset = view.get_queryset() queryset = view.get_queryset()
self.assertQuerysetEqual(queryset, [repr(self.sshkey)], transform=repr) self.assertQuerySetEqual(queryset, [repr(self.sshkey)], transform=repr)
def test_get_form_kwargs(self): def test_get_form_kwargs(self):
self.client.login(username=TEST_USER, password=TEST_PASSWORD) self.client.login(username=TEST_USER, password=TEST_PASSWORD)

1040
poetry.lock generated

File diff suppressed because it is too large Load diff

View file

@ -7,15 +7,15 @@ license = "AGPL-3+"
readme = "README.md" readme = "README.md"
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = "^3.7" python = "^3.8"
django = "<4" django = "^4.2"
psycopg2-binary = "^2.9" psycopg2-binary = "^2.9"
celery = "^5.2.7" celery = "^5.2.7"
django-allauth = "^0.52.0" django-allauth = "^0.52.0"
django-crispy-forms = "^2.0" django-crispy-forms = "^2.0"
django-debug-toolbar = "^3.8" django-debug-toolbar = "^3.8"
django-model-utils = "^4.1" django-model-utils = "^4.1"
gvacommon = {version = "^0.6.0", source = "gnuviech"} gvacommon = {version = "^0.7.0", source = "gnuviech"}
passlib = "^1.7.4" passlib = "^1.7.4"
redis = "^4.5.1" redis = "^4.5.1"
requests-oauthlib = "^1.3.1" requests-oauthlib = "^1.3.1"
@ -40,8 +40,7 @@ isort = "<5"
[[tool.poetry.source]] [[tool.poetry.source]]
name = "gnuviech" name = "gnuviech"
url = "https://pypi.gnuviech-server.de/simple" url = "https://pypi.gnuviech-server.de/simple"
default = false priority = "explicit"
secondary = false
[build-system] [build-system]