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:
parent
0f18e59d67
commit
4af1a39ca4
93 changed files with 3598 additions and 2725 deletions
|
@ -2,21 +2,20 @@
|
|||
This module contains the hosting package models.
|
||||
|
||||
"""
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import transaction
|
||||
from django.db import models
|
||||
from django.db import models, transaction
|
||||
from django.urls import reverse
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.translation import ugettext_lazy as _, ungettext
|
||||
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.utils.translation import ngettext
|
||||
from model_utils import Choices
|
||||
from model_utils.models import TimeStampedModel
|
||||
|
||||
from domains.models import HostingDomain
|
||||
from managemails.models import Mailbox
|
||||
from osusers.models import AdditionalGroup, Group, User as OsUser
|
||||
from osusers.models import AdditionalGroup, Group
|
||||
from osusers.models import User as OsUser
|
||||
from userdbs.models import DB_TYPES, UserDatabase
|
||||
|
||||
DISK_SPACE_UNITS = Choices((0, "M", _("MiB")), (1, "G", _("GiB")), (2, "T", _("TiB")))
|
||||
|
@ -24,7 +23,6 @@ DISK_SPACE_UNITS = Choices((0, "M", _("MiB")), (1, "G", _("GiB")), (2, "T", _("T
|
|||
DISK_SPACE_FACTORS = ((1, None, None), (1024, 1, None), (1024 * 1024, 1024, 1))
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class HostingPackageBase(TimeStampedModel):
|
||||
description = models.TextField(_("description"), blank=True)
|
||||
mailboxcount = models.PositiveIntegerField(_("mailbox count"))
|
||||
|
@ -57,7 +55,6 @@ class HostingOption(TimeStampedModel):
|
|||
"""
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class DiskSpaceOptionBase(models.Model):
|
||||
diskspace = models.PositiveIntegerField(_("disk space"))
|
||||
diskspace_unit = models.PositiveSmallIntegerField(
|
||||
|
@ -87,7 +84,6 @@ class DiskSpaceOption(DiskSpaceOptionBase, HostingOption):
|
|||
unique_together = ["diskspace", "diskspace_unit"]
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class UserDatabaseOptionBase(models.Model):
|
||||
number = models.PositiveIntegerField(_("number of databases"), default=1)
|
||||
db_type = models.PositiveSmallIntegerField(_("database type"), choices=DB_TYPES)
|
||||
|
@ -99,7 +95,7 @@ class UserDatabaseOptionBase(models.Model):
|
|||
verbose_name_plural = _("Database options")
|
||||
|
||||
def __str__(self):
|
||||
return ungettext(
|
||||
return ngettext(
|
||||
"{type} database", "{count} {type} databases", self.number
|
||||
).format(type=self.get_db_type_display(), count=self.number)
|
||||
|
||||
|
@ -115,7 +111,6 @@ class UserDatabaseOption(UserDatabaseOptionBase, HostingOption):
|
|||
unique_together = ["number", "db_type"]
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class MailboxOptionBase(models.Model):
|
||||
"""
|
||||
Base class for mailbox options.
|
||||
|
@ -131,7 +126,7 @@ class MailboxOptionBase(models.Model):
|
|||
verbose_name_plural = _("Mailbox options")
|
||||
|
||||
def __str__(self):
|
||||
return ungettext(
|
||||
return ngettext(
|
||||
"{count} additional mailbox", "{count} additional mailboxes", self.number
|
||||
).format(count=self.number)
|
||||
|
||||
|
@ -177,7 +172,6 @@ class CustomerHostingPackageManager(models.Manager):
|
|||
return package
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class CustomerHostingPackage(HostingPackageBase):
|
||||
"""
|
||||
This class defines customer specific hosting packages.
|
||||
|
@ -269,7 +263,7 @@ class CustomerHostingPackage(HostingPackageBase):
|
|||
) + option.diskspace
|
||||
min_unit = option.diskspace_unit
|
||||
if unit is None:
|
||||
return DISK_SPACE_FACTORS[min_unit][0] * diskspace * 1024 ** 2
|
||||
return DISK_SPACE_FACTORS[min_unit][0] * diskspace * 1024**2
|
||||
if unit > min_unit:
|
||||
return DISK_SPACE_FACTORS[unit][min_unit] * diskspace
|
||||
return DISK_SPACE_FACTORS[min_unit][unit] * diskspace
|
||||
|
@ -287,7 +281,7 @@ class CustomerHostingPackage(HostingPackageBase):
|
|||
"""
|
||||
if unit is None:
|
||||
return (
|
||||
DISK_SPACE_FACTORS[self.diskspace_unit][0] * self.diskspace * 1024 ** 2
|
||||
DISK_SPACE_FACTORS[self.diskspace_unit][0] * self.diskspace * 1024**2
|
||||
)
|
||||
if unit > self.diskspace_unit:
|
||||
return DISK_SPACE_FACTORS[unit][self.diskspace_unit] * self.diskspace
|
||||
|
@ -382,7 +376,6 @@ class CustomerHostingPackage(HostingPackageBase):
|
|||
return super(CustomerHostingPackage, self).save(*args, **kwargs)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class CustomerHostingPackageDomain(TimeStampedModel):
|
||||
"""
|
||||
This class defines the relationship from a hosting package to a hosting
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue