From 55a601de5a5ec211340d3735346328eb2f73064b Mon Sep 17 00:00:00 2001 From: Dimitri Huisman Date: Thu, 17 Feb 2022 13:09:15 +0000 Subject: [PATCH] Add missing import for validators, improve behaviour when an error occurs. --- core/admin/mailu/ui/views/domains.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/admin/mailu/ui/views/domains.py b/core/admin/mailu/ui/views/domains.py index 8d9d5aa4..4010e2ae 100644 --- a/core/admin/mailu/ui/views/domains.py +++ b/core/admin/mailu/ui/views/domains.py @@ -2,6 +2,7 @@ from mailu import models from mailu.ui import ui, forms, access from flask import current_app as app +import validators import flask import flask_login import wtforms_components @@ -26,13 +27,13 @@ def domain_create(): flask.flash('Domain %s is already used' % form.name.data, 'error') else: domain = models.Domain() - form.populate_obj(domain) + form.populate_obj(domain) models.db.session.add(domain) models.db.session.commit() flask.flash('Domain %s created' % domain) + return flask.redirect(flask.url_for('.domain_list')) else: flask.flash('Domain %s is invalid' % form.name.data, 'error') - return flask.redirect(flask.url_for('.domain_list')) return flask.render_template('domain/create.html', form=form)