mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
@@ -229,23 +229,26 @@ class DomainFormOptions(forms.Form):
|
||||
da.role = "DomainAdmins"
|
||||
da.post_create(user)
|
||||
|
||||
dom_admin_username = self.cleaned_data["dom_admin_username"]
|
||||
mb = Mailbox(
|
||||
address=self.cleaned_data["dom_admin_username"], domain=domain,
|
||||
address=dom_admin_username, domain=domain,
|
||||
user=da, use_domain_quota=True
|
||||
)
|
||||
mb.set_quota(
|
||||
override_rules=user.has_perm("admin.change_domain"))
|
||||
mb.save(creator=user)
|
||||
|
||||
if domain.type == "domain" and \
|
||||
self.cleaned_data["create_aliases"] == "yes":
|
||||
condition = (
|
||||
domain.type == "domain" and
|
||||
self.cleaned_data["create_aliases"] == "yes" and
|
||||
dom_admin_username != "postmaster"
|
||||
)
|
||||
if condition:
|
||||
core_signals.can_create_object.send(
|
||||
self.__class__, context=user, object_type="mailbox_aliases")
|
||||
alias = Alias(
|
||||
address=u"postmaster@{}".format(domain.name),
|
||||
domain=domain, enabled=True
|
||||
)
|
||||
alias.save()
|
||||
address = u"postmaster@{}".format(domain.name)
|
||||
alias = Alias.objects.create(
|
||||
address=address, domain=domain, enabled=True)
|
||||
alias.set_recipients([mb.full_address])
|
||||
alias.post_create(user)
|
||||
|
||||
|
||||
@@ -51,18 +51,13 @@ class DomainTestCase(ModoTestCase):
|
||||
self.assertFalse(dom.admins)
|
||||
|
||||
def test_create_with_template(self):
|
||||
"""Test the creation of a domain with a template
|
||||
|
||||
"""
|
||||
"""Test the creation of a domain with a template."""
|
||||
values = {
|
||||
"name": "pouet.com", "quota": 100, "create_dom_admin": "yes",
|
||||
"dom_admin_username": "toto", "create_aliases": "yes",
|
||||
"type": "domain", "stepid": 'step3'
|
||||
}
|
||||
self.ajax_post(
|
||||
reverse("admin:domain_add"),
|
||||
values
|
||||
)
|
||||
self.ajax_post(reverse("admin:domain_add"), values)
|
||||
dom = Domain.objects.get(name="pouet.com")
|
||||
da = User.objects.get(username="toto@pouet.com")
|
||||
self.assertIn(da, dom.admins)
|
||||
@@ -73,6 +68,18 @@ class DomainTestCase(ModoTestCase):
|
||||
)
|
||||
self.assertTrue(da.can_access(al))
|
||||
|
||||
values = {
|
||||
"name": "pouet2.com", "quota": 100, "create_dom_admin": "yes",
|
||||
"dom_admin_username": "postmaster", "create_aliases": "yes",
|
||||
"type": "domain", "stepid": "step3"
|
||||
}
|
||||
self.ajax_post(reverse("admin:domain_add"), values)
|
||||
self.assertTrue(
|
||||
User.objects.filter(username="postmaster@pouet2.com").exists())
|
||||
self.assertFalse(
|
||||
Alias.objects.filter(
|
||||
address="postmaster@pouet2.com", internal=False).exists())
|
||||
|
||||
def test_create_with_template_and_empty_quota(self):
|
||||
"""Test the creation of a domain with a template and no quota"""
|
||||
values = {
|
||||
|
||||
Reference in New Issue
Block a user