Avoid duplicating relays with alternatives or domains

master
kaiyou 7 years ago
parent 01ddfef149
commit d4254bfd1f

@ -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)

@ -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()

Loading…
Cancel
Save