Fix custom domain has been added before

This commit is contained in:
Son NK 2020-01-01 23:51:40 +01:00
parent 5d25310105
commit ee3c75244e

View file

@ -31,12 +31,18 @@ def custom_domain():
if request.method == "POST": if request.method == "POST":
if request.form.get("form-name") == "create": if request.form.get("form-name") == "create":
if new_custom_domain_form.validate(): if new_custom_domain_form.validate():
new_domain = new_custom_domain_form.domain.data
if CustomDomain.get_by(domain=new_domain):
flash(f"{new_domain} already added", "warning")
else:
new_custom_domain = CustomDomain.create( new_custom_domain = CustomDomain.create(
domain=new_custom_domain_form.domain.data, user_id=current_user.id domain=new_domain, user_id=current_user.id
) )
db.session.commit() db.session.commit()
flash(f"New domain {new_custom_domain.domain} is created", "success") flash(
f"New domain {new_custom_domain.domain} is created", "success"
)
return redirect( return redirect(
url_for( url_for(