diff --git a/modoboa/admin/forms.py b/modoboa/admin/forms.py index 63be15029..1459d4593 100644 --- a/modoboa/admin/forms.py +++ b/modoboa/admin/forms.py @@ -161,7 +161,7 @@ class DomainFormOptions(forms.Form): da.post_create(user) mb = Mailbox(address=self.cleaned_data["dom_admin_username"], domain=domain, user=da, use_domain_quota=True) - mb.set_quota() + mb.set_quota(override_rules=user.has_perm("admin.change_domain")) mb.save(creator=user) if self.cleaned_data["create_aliases"] == "yes": diff --git a/modoboa/admin/tests.py b/modoboa/admin/tests.py index e894462e4..60d380a20 100644 --- a/modoboa/admin/tests.py +++ b/modoboa/admin/tests.py @@ -55,6 +55,21 @@ class DomainTestCase(ModoTestCase): self.assertIn(da.mailbox_set.all()[0], al.mboxes.all()) self.assertTrue(da.can_access(al)) + def test_create_with_template_and_empty_quota(self): + """Test the creation of a domain with a template and no quota""" + values = { + "name": "pouet.com", "quota": 0, "create_dom_admin": "yes", + "dom_admin_username": "toto", "create_aliases": "yes", + "stepid": 2 + } + self.check_ajax_post(reverse("modoboa.admin.views.newdomain"), values) + dom = Domain.objects.get(name="pouet.com") + da = User.objects.get(username="toto@pouet.com") + self.assertIn(da, dom.admins) + al = Alias.objects.get(address="postmaster", domain__name="pouet.com") + self.assertIn(da.mailbox_set.all()[0], al.mboxes.all()) + self.assertTrue(da.can_access(al)) + def test_modify(self): """Test the modification of a domain