diff --git a/admin/mailu/admin/views/alternatives.py b/admin/mailu/admin/views/alternatives.py index b3b4ab3b..ce237d45 100644 --- a/admin/mailu/admin/views/alternatives.py +++ b/admin/mailu/admin/views/alternatives.py @@ -19,7 +19,8 @@ def alternative_create(domain_name): if form.validate_on_submit(): conflicting_domain = models.Domain.query.get(form.name.data) conflicting_alternative = models.Alternative.query.get(form.name.data) - if conflicting_domain or conflicting_alternative: + conflicting_relay = models.Relay.query.get(form.name.data) + if conflicting_domain or conflicting_alternative or conflicting_relay: flask.flash('Domain %s is already used' % form.name.data, 'error') else: alternative = models.Alternative(domain=domain) diff --git a/admin/mailu/admin/views/domains.py b/admin/mailu/admin/views/domains.py index 371b46f9..cebe5c8b 100644 --- a/admin/mailu/admin/views/domains.py +++ b/admin/mailu/admin/views/domains.py @@ -18,7 +18,8 @@ def domain_create(): if form.validate_on_submit(): conflicting_domain = models.Domain.query.get(form.name.data) conflicting_alternative = models.Alternative.query.get(form.name.data) - if conflicting_domain or conflicting_alternative: + conflicting_relay = models.Relay.query.get(form.name.data) + if conflicting_domain or conflicting_alternative or conflicting_relay: flask.flash('Domain %s is already used' % form.name.data, 'error') else: domain = models.Domain()