mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-12-01 12:03:55 +01:00
take care of domain aliases
This commit is contained in:
@@ -62,7 +62,12 @@ class Repair(BaseCommand):
|
|||||||
elif isinstance(obj, models.DomainAlias):
|
elif isinstance(obj, models.DomainAlias):
|
||||||
admin = obj.target.admins.first()
|
admin = obj.target.admins.first()
|
||||||
else:
|
else:
|
||||||
admin = obj.domain.admins.first()
|
if obj.domain:
|
||||||
|
admin = obj.domain.admins.first()
|
||||||
|
else:
|
||||||
|
# Alias is an internal alias for domain alias
|
||||||
|
# we don't care if it's not owned
|
||||||
|
continue
|
||||||
if not admin:
|
if not admin:
|
||||||
# domain has no admin. use the first superuser found
|
# domain has no admin. use the first superuser found
|
||||||
admin = User.objects.filter(is_superuser=True,
|
admin = User.objects.filter(is_superuser=True,
|
||||||
|
|||||||
@@ -39,3 +39,8 @@ class RepairTestCase(ModoTestCase):
|
|||||||
management.call_command("modo", "repair", "--quiet", "--dry-run")
|
management.call_command("modo", "repair", "--quiet", "--dry-run")
|
||||||
# assert its not fixed
|
# assert its not fixed
|
||||||
self.assertIs(get_object_owner(mbox), None)
|
self.assertIs(get_object_owner(mbox), None)
|
||||||
|
|
||||||
|
def test_management_command_with_nul_domain(self):
|
||||||
|
""" Just assume nothing raise when an alias has no domain"""
|
||||||
|
models.Alias.objects.create(address='@modoboa.xxx')
|
||||||
|
management.call_command("modo", "repair", "--quiet")
|
||||||
|
|||||||
Reference in New Issue
Block a user