Compare commits
No commits in common. "affb49a9714590d52fb897f6db764d5cc85023b2" and "4577ec4896fef2f2d697478857ed3cc6dfb539f6" have entirely different histories.
affb49a971
...
4577ec4896
11 changed files with 615 additions and 522 deletions
|
@ -7,7 +7,6 @@ from __future__ import absolute_import, unicode_literals
|
|||
from crispy_forms.helper import FormHelper
|
||||
from crispy_forms.layout import Submit
|
||||
from django import forms
|
||||
from django.apps import apps
|
||||
from django.conf import settings
|
||||
from django.contrib.sites.models import Site
|
||||
from django.contrib.sites.requests import RequestSite
|
||||
|
@ -42,7 +41,7 @@ class ContactForm(forms.Form):
|
|||
def get_context(self):
|
||||
if not self.is_valid():
|
||||
raise ValueError("Cannot generate context from invalid contact form")
|
||||
if apps.is_installed("django.contrib.sites"):
|
||||
if Site._meta.installed:
|
||||
site = Site.objects.get_current()
|
||||
else:
|
||||
site = RequestSite(self.request)
|
||||
|
|
|
@ -76,6 +76,9 @@ SITES_SITE_NAME = get_env_variable("GVA_SITE_NAME")
|
|||
# See: https://docs.djangoproject.com/en/dev/ref/settings/#use-i18n
|
||||
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
|
||||
USE_TZ = True
|
||||
# ######### END GENERAL CONFIGURATION
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from django.contrib import admin
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from help.models import HelpUser
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ import uuid
|
|||
|
||||
from django.conf import settings
|
||||
from django.db import models
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
|
||||
class HelpUser(models.Model):
|
||||
|
|
|
@ -16,54 +16,37 @@ User = get_user_model()
|
|||
|
||||
|
||||
class CustomerHostingPackageTest(TestCase):
|
||||
def setUp(self) -> None:
|
||||
self.user = User.objects.create(username="test")
|
||||
self.template = HostingPackageTemplate.objects.create(
|
||||
mailboxcount=10,
|
||||
diskspace=100,
|
||||
diskspace_unit=DISK_SPACE_UNITS.M,
|
||||
description="Test package 1 - Description",
|
||||
name="Test package 1",
|
||||
)
|
||||
|
||||
@override_settings(OSUSER_DEFAULT_GROUPS=[])
|
||||
def test_get_disk_space_bytes(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 = CustomerHostingPackage(
|
||||
diskspace=10, diskspace_unit=DISK_SPACE_UNITS.G
|
||||
)
|
||||
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 = CustomerHostingPackage(
|
||||
diskspace=10, diskspace_unit=DISK_SPACE_UNITS.G
|
||||
)
|
||||
package.save()
|
||||
self.assertEqual(package.get_disk_space(DISK_SPACE_UNITS.M), 10 * 1024)
|
||||
|
||||
@override_settings(OSUSER_DEFAULT_GROUPS=[])
|
||||
def test_get_quota(self):
|
||||
self.template.diskspace = 256
|
||||
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 = CustomerHostingPackage(
|
||||
diskspace=256, diskspace_unit=DISK_SPACE_UNITS.M
|
||||
)
|
||||
package.save()
|
||||
self.assertEqual(package.get_quota(), (262144, 275251))
|
||||
|
||||
@override_settings(OSUSER_DEFAULT_GROUPS=["testgroup"])
|
||||
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:
|
||||
package = CustomerHostingPackage.objects.create_from_template(
|
||||
customer=self.user, template=self.template, name="Test customer package",
|
||||
customer=user, template=template, name="Test customer package"
|
||||
)
|
||||
package.save()
|
||||
self.assertIn("testgroup", str(ctx.exception))
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from django.apps import AppConfig
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
|
||||
class InvoiceConfig(AppConfig):
|
||||
|
|
|
@ -3,7 +3,7 @@ from django.conf import settings
|
|||
from django.core.exceptions import ValidationError
|
||||
from django.core.validators import FileExtensionValidator
|
||||
from django.db import models
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
CURRENCIES = [(1, "EUR")]
|
||||
|
||||
|
|
|
@ -140,7 +140,7 @@ class MailAddressTest(TestCaseWithCeleryTasks):
|
|||
def get_target(maf):
|
||||
return maf.target
|
||||
|
||||
self.assertQuerySetEqual(
|
||||
self.assertQuerysetEqual(
|
||||
ma.mailaddressforward_set.all(), ["test2@example.org"], get_target
|
||||
)
|
||||
|
||||
|
@ -152,7 +152,7 @@ class MailAddressTest(TestCaseWithCeleryTasks):
|
|||
def get_target(maf):
|
||||
return maf.target
|
||||
|
||||
self.assertQuerySetEqual(
|
||||
self.assertQuerysetEqual(
|
||||
ma.mailaddressforward_set.all(), ["test2@example.org"], get_target
|
||||
)
|
||||
|
||||
|
@ -165,7 +165,7 @@ class MailAddressTest(TestCaseWithCeleryTasks):
|
|||
def get_target(maf):
|
||||
return maf.target
|
||||
|
||||
self.assertQuerySetEqual(
|
||||
self.assertQuerysetEqual(
|
||||
ma.mailaddressforward_set.all(), ["test3@example.org"], get_target
|
||||
)
|
||||
|
||||
|
@ -178,7 +178,7 @@ class MailAddressTest(TestCaseWithCeleryTasks):
|
|||
def get_target(maf):
|
||||
return maf.target
|
||||
|
||||
self.assertQuerySetEqual(
|
||||
self.assertQuerysetEqual(
|
||||
ma.mailaddressforward_set.all(),
|
||||
["test2@example.org", "test3@example.org"],
|
||||
get_target,
|
||||
|
@ -198,7 +198,7 @@ class MailAddressTest(TestCaseWithCeleryTasks):
|
|||
def get_target(maf):
|
||||
return maf.target
|
||||
|
||||
self.assertQuerySetEqual(
|
||||
self.assertQuerysetEqual(
|
||||
ma.mailaddressforward_set.all(), ["test2@example.org"], get_target
|
||||
)
|
||||
|
||||
|
@ -213,6 +213,7 @@ class MailAddressTest(TestCaseWithCeleryTasks):
|
|||
md = MailDomain.objects.create(domain="example.org")
|
||||
ma = MailAddress(localpart="test", domain=md)
|
||||
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")
|
||||
|
||||
|
||||
|
@ -241,14 +242,14 @@ class MailboxManagerTest(TestCaseWithCeleryTasks):
|
|||
md = MailDomain.objects.create(domain="example.org")
|
||||
address = MailAddress.objects.create(localpart="test", domain=md)
|
||||
mailboxes = Mailbox.objects.unused_or_own(address, self.user)
|
||||
self.assertQuerySetEqual(mailboxes, [])
|
||||
self.assertQuerysetEqual(mailboxes, [])
|
||||
|
||||
def test_unused_or_own_unassigned(self):
|
||||
md = MailDomain.objects.create(domain="example.org")
|
||||
address = MailAddress.objects.create(localpart="test", domain=md)
|
||||
mailboxes = [Mailbox.objects.create_mailbox(self.user) for _ in range(2)]
|
||||
assignable = Mailbox.objects.unused_or_own(address, self.user)
|
||||
self.assertQuerySetEqual(
|
||||
self.assertQuerysetEqual(
|
||||
assignable, [repr(mb) for mb in mailboxes], transform=repr
|
||||
)
|
||||
|
||||
|
@ -258,7 +259,7 @@ class MailboxManagerTest(TestCaseWithCeleryTasks):
|
|||
mailboxes = [Mailbox.objects.create_mailbox(self.user) for _ in range(2)]
|
||||
address.set_mailbox(mailboxes[0])
|
||||
assignable = Mailbox.objects.unused_or_own(address, self.user)
|
||||
self.assertQuerySetEqual(
|
||||
self.assertQuerysetEqual(
|
||||
assignable, [repr(mb) for mb in mailboxes], transform=repr
|
||||
)
|
||||
|
||||
|
@ -269,16 +270,16 @@ class MailboxManagerTest(TestCaseWithCeleryTasks):
|
|||
mailboxes = [Mailbox.objects.create_mailbox(self.user) for _ in range(2)]
|
||||
address2.set_mailbox(mailboxes[0])
|
||||
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):
|
||||
mailboxes = Mailbox.objects.unused(self.user)
|
||||
self.assertQuerySetEqual(mailboxes, [])
|
||||
self.assertQuerysetEqual(mailboxes, [])
|
||||
|
||||
def test_unused_unassigned(self):
|
||||
mailbox = Mailbox.objects.create_mailbox(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):
|
||||
md = MailDomain.objects.create(domain="example.org")
|
||||
|
@ -286,7 +287,7 @@ class MailboxManagerTest(TestCaseWithCeleryTasks):
|
|||
mailboxes = [Mailbox.objects.create_mailbox(self.user) for _ in range(2)]
|
||||
address.set_mailbox(mailboxes[0])
|
||||
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):
|
||||
mailbox = Mailbox.objects.create_mailbox(self.user)
|
||||
|
|
|
@ -166,7 +166,7 @@ class DeleteSshPublicKeyTest(HostingPackageAwareTestMixin, TestCase):
|
|||
kwargs={"package": str(self.package.pk), "pk": str(self.sshkey.pk)},
|
||||
)
|
||||
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):
|
||||
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)},
|
||||
)
|
||||
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):
|
||||
self.client.login(username=TEST_USER, password=TEST_PASSWORD)
|
||||
|
|
1036
poetry.lock
generated
1036
poetry.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -7,15 +7,15 @@ license = "AGPL-3+"
|
|||
readme = "README.md"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.8"
|
||||
django = "^4.2"
|
||||
python = "^3.7"
|
||||
django = "<4"
|
||||
psycopg2-binary = "^2.9"
|
||||
celery = "^5.2.7"
|
||||
django-allauth = "^0.52.0"
|
||||
django-crispy-forms = "^2.0"
|
||||
django-debug-toolbar = "^3.8"
|
||||
django-model-utils = "^4.1"
|
||||
gvacommon = {version = "^0.7.0", source = "gnuviech"}
|
||||
gvacommon = {version = "^0.6.0", source = "gnuviech"}
|
||||
passlib = "^1.7.4"
|
||||
redis = "^4.5.1"
|
||||
requests-oauthlib = "^1.3.1"
|
||||
|
@ -40,7 +40,8 @@ isort = "<5"
|
|||
[[tool.poetry.source]]
|
||||
name = "gnuviech"
|
||||
url = "https://pypi.gnuviech-server.de/simple"
|
||||
priority = "explicit"
|
||||
default = false
|
||||
secondary = false
|
||||
|
||||
|
||||
[build-system]
|
||||
|
|
Loading…
Reference in a new issue