mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
Merge branch 'master' into api-throttling
This commit is contained in:
+21
-2
@@ -94,6 +94,8 @@ Specific instructions
|
||||
2.0.4
|
||||
=====
|
||||
|
||||
The following modifications must be applied to the :file:`settings.py` file:
|
||||
|
||||
* Add ``'modoboa.core.context_processors.new_admin_url',`` at the end of `context_processors` list:
|
||||
|
||||
.. sourcecode:: python
|
||||
@@ -122,10 +124,27 @@ Specific instructions
|
||||
]
|
||||
|
||||
|
||||
* You now have the possibility to customize the url of the new-admin interface.
|
||||
* Add the following variable::
|
||||
|
||||
To do so please head up to :ref:`the custom configuration chapter <customization>` (advanced user).
|
||||
.. sourcecode:: python
|
||||
|
||||
PID_FILE_STORAGE_PATH = '/var/run'
|
||||
|
||||
* Update ``LOGGING`` variable to define an address for ``syslog-auth`` handler::
|
||||
|
||||
.. sourcecode:: python
|
||||
|
||||
'syslog-auth': {
|
||||
'class': 'logging.handlers.SysLogHandler',
|
||||
'facility': SysLogHandler.LOG_AUTH,
|
||||
'formatter': 'syslog',
|
||||
'address': '/dev/log'
|
||||
},
|
||||
|
||||
|
||||
* You now have the possibility to customize the url of the new-admin
|
||||
interface. To do so please head up to :ref:`the custom configuration
|
||||
chapter <customization>` (advanced user).
|
||||
|
||||
* Add ``DEFAULT_THROTTLE_RATES`` to ``REST_FRAMEWORK``:
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ class Domain(mixins.MessageLimitMixin, AdminObject):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
"""Save name for further use."""
|
||||
super(Domain, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
self.old_mail_homes = None
|
||||
self.oldname = self.name
|
||||
self.old_dkim_key_length = self.dkim_key_length
|
||||
@@ -320,7 +320,7 @@ class Domain(mixins.MessageLimitMixin, AdminObject):
|
||||
if self.old_dkim_key_length != self.dkim_key_length:
|
||||
self.dkim_public_key = ""
|
||||
self.dkim_private_key_path = ""
|
||||
super(Domain, self).save(*args, **kwargs)
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
def delete(self, fromuser, keepdir=False):
|
||||
"""Custom delete method."""
|
||||
@@ -336,7 +336,7 @@ class Domain(mixins.MessageLimitMixin, AdminObject):
|
||||
elif self.mailbox_set.count():
|
||||
Quota.objects.filter(username__contains="@%s" % self.name).delete()
|
||||
ungrant_access_to_objects(self.mailbox_set.all())
|
||||
super(Domain, self).delete()
|
||||
super().delete()
|
||||
|
||||
def __str__(self):
|
||||
return smart_text(self.name)
|
||||
@@ -364,27 +364,27 @@ class Domain(mixins.MessageLimitMixin, AdminObject):
|
||||
if domains_must_have_authorized_mx and not user.is_superuser:
|
||||
if not lib.domain_has_authorized_mx(self.name):
|
||||
raise BadRequest(
|
||||
_("No authorized MX record found for domain {}")
|
||||
_("{}: no authorized MX record found for domain")
|
||||
.format(self.name)
|
||||
)
|
||||
try:
|
||||
self.quota = int(row[2].strip())
|
||||
except ValueError:
|
||||
raise BadRequest(
|
||||
_("Invalid quota value for domain '{}'")
|
||||
_("{}: invalid quota value for domain")
|
||||
.format(self.name)
|
||||
)
|
||||
try:
|
||||
self.default_mailbox_quota = int(row[3].strip())
|
||||
except ValueError:
|
||||
raise BadRequest(
|
||||
_("Invalid default mailbox quota value for domain '{}'")
|
||||
_("{}: invalid default mailbox quota value for domain")
|
||||
.format(self.name)
|
||||
)
|
||||
if self.quota != 0 and self.default_mailbox_quota > self.quota:
|
||||
raise BadRequest(
|
||||
_("Default mailbox quota cannot be greater than domain "
|
||||
"quota")
|
||||
_("{}: default mailbox quota cannot be greater than domain "
|
||||
"quota").format(self.name)
|
||||
)
|
||||
self.enabled = (row[4].strip().lower() in ["true", "1", "yes", "y"])
|
||||
core_signals.can_create_object.send(
|
||||
|
||||
@@ -257,7 +257,9 @@ class Mailbox(mixins.MessageLimitMixin, AdminObject):
|
||||
if old_quota:
|
||||
quota_usage -= old_quota
|
||||
if quota_usage + self.quota > self.domain.quota:
|
||||
raise lib_exceptions.BadRequest(_("Domain quota exceeded"))
|
||||
raise lib_exceptions.BadRequest(
|
||||
_("{}: domain quota exceeded").format(self.domain.name)
|
||||
)
|
||||
|
||||
def get_quota(self):
|
||||
"""Get quota limit.
|
||||
|
||||
@@ -172,7 +172,7 @@ Domains.prototype = {
|
||||
if (this.navobj.getbaseurl() === "list") {
|
||||
args.objtype = "domain";
|
||||
this.options.eor_message = gettext("No more domain to show");
|
||||
} else if (this.navobj.getbaseurl() === "quota") {
|
||||
} else if (this.navobj.getbaseurl() === "quotas") {
|
||||
args.objtype = "quota";
|
||||
this.options.eor_message = gettext("No more quota to show");
|
||||
} else {
|
||||
|
||||
@@ -66,17 +66,18 @@ domainalias; domalias1.com; domain1.com; True
|
||||
f = ContentFile("domain; domain1.com; XX; 100; True",
|
||||
name="domains.csv")
|
||||
response = self.client.post(url, {"sourcefile": f})
|
||||
self.assertContains(response, "Invalid quota value")
|
||||
self.assertContains(response, "domain1.com: invalid quota value")
|
||||
f = ContentFile("domain; domain1.com; 100; XX; True",
|
||||
name="domains.csv")
|
||||
response = self.client.post(url, {"sourcefile": f})
|
||||
self.assertContains(response, "Invalid default mailbox quota")
|
||||
self.assertContains(
|
||||
response, "domain1.com: invalid default mailbox quota")
|
||||
f = ContentFile("domain; domain1.com; 10; 100; True",
|
||||
name="domains.csv")
|
||||
response = self.client.post(url, {"sourcefile": f})
|
||||
self.assertContains(
|
||||
response,
|
||||
"Default mailbox quota cannot be greater than domain quota")
|
||||
"domain1.com: default mailbox quota cannot be greater than domain quota")
|
||||
|
||||
@mock.patch.object(dns.resolver.Resolver, "resolve")
|
||||
@mock.patch("socket.getaddrinfo")
|
||||
@@ -97,7 +98,8 @@ domainalias; domalias1.com; domain1.com; True
|
||||
"sourcefile": f
|
||||
}
|
||||
)
|
||||
self.assertContains(resp, "No authorized MX record found for domain")
|
||||
self.assertContains(
|
||||
resp, "test3.com: no authorized MX record found for domain")
|
||||
|
||||
mock_getaddrinfo.side_effect = utils.mock_ip_query_result
|
||||
f = ContentFile(
|
||||
@@ -253,7 +255,7 @@ account; user1@test.com; toto; User; One; True; SimpleUsers; user1@test.com; 40
|
||||
reverse("admin:identity_import"),
|
||||
{"sourcefile": f, "crypt_password": True}
|
||||
)
|
||||
self.assertIn("Domain quota exceeded", resp.content.decode())
|
||||
self.assertIn("test.com: domain quota exceeded", resp.content.decode())
|
||||
|
||||
def test_import_missing_quota(self):
|
||||
f = ContentFile(b"""
|
||||
|
||||
@@ -329,7 +329,8 @@ LOGGING = {
|
||||
'syslog-auth': {
|
||||
'class': 'logging.handlers.SysLogHandler',
|
||||
'facility': SysLogHandler.LOG_AUTH,
|
||||
'formatter': 'syslog'
|
||||
'formatter': 'syslog',
|
||||
'address': '/dev/log'
|
||||
},
|
||||
'syslog-mail': {
|
||||
'class': 'logging.handlers.SysLogHandler',
|
||||
|
||||
Reference in New Issue
Block a user