mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-18 05:51:26 +02:00
@@ -170,6 +170,8 @@ class Alias(AdminObject):
|
||||
ext_rcpts = []
|
||||
for rcpt in row[3:]:
|
||||
rcpt = rcpt.strip()
|
||||
if not rcpt:
|
||||
continue
|
||||
localpart, domname = split_mailbox(rcpt)
|
||||
try:
|
||||
Domain.objects.get(name=domname)
|
||||
@@ -177,14 +179,16 @@ class Alias(AdminObject):
|
||||
ext_rcpts += [rcpt]
|
||||
continue
|
||||
try:
|
||||
target = Alias.objects.get(domain__name=domname, address=localpart)
|
||||
target = Alias.objects.get(
|
||||
domain__name=domname, address=localpart
|
||||
)
|
||||
if target.full_address == self.full_address:
|
||||
target = None
|
||||
except Alias.DoesNotExist:
|
||||
target = None
|
||||
if target is None:
|
||||
try:
|
||||
target = Mailbox.objects.get(address=localpart,
|
||||
target = Mailbox.objects.get(address=localpart,
|
||||
domain__name=domname)
|
||||
except Mailbox.DoesNotExist:
|
||||
raise BadRequest(_("Local recipient %s not found" % rcpt))
|
||||
|
||||
@@ -170,3 +170,17 @@ account; sa@test.com; toto; Super; Admin; True; SuperAdmins; superadmin@test.com
|
||||
)
|
||||
with self.assertRaises(User.DoesNotExist):
|
||||
User.objects.get(username="sa@test.com")
|
||||
|
||||
def test_import_alias_with_empty_values(self):
|
||||
f = ContentFile(b"""
|
||||
alias;user.alias@test.com;True;user@test.com;;;;;;;;;;;;;;;;
|
||||
""", name="identities.csv")
|
||||
self.clt.post(
|
||||
reverse("modoboa.extensions.admin.views.import.import_identities"),
|
||||
{"sourcefile": f, "crypt_password": True,
|
||||
"continue_if_exists": True}
|
||||
)
|
||||
alias = Alias.objects.get(
|
||||
domain__name="test.com", address="user.alias"
|
||||
)
|
||||
self.assertEqual(alias.type, "alias")
|
||||
|
||||
Reference in New Issue
Block a user