mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
take care of domain aliases
This commit is contained in:
@@ -62,7 +62,12 @@ class Repair(BaseCommand):
|
||||
elif isinstance(obj, models.DomainAlias):
|
||||
admin = obj.target.admins.first()
|
||||
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:
|
||||
# domain has no admin. use the first superuser found
|
||||
admin = User.objects.filter(is_superuser=True,
|
||||
|
||||
@@ -39,3 +39,8 @@ class RepairTestCase(ModoTestCase):
|
||||
management.call_command("modo", "repair", "--quiet", "--dry-run")
|
||||
# assert its not fixed
|
||||
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