Move /email_sent/ to flask endpoint, to allow translation

This commit is contained in:
rubenwardy 2022-01-20 21:55:16 +00:00
parent b6fe0466ca
commit a47e6e8998
4 changed files with 36 additions and 15 deletions

@ -140,7 +140,7 @@ def handle_register(form):
send_anon_email.delay(form.email.data, gettext("Email already in use"), send_anon_email.delay(form.email.data, gettext("Email already in use"),
gettext("We were unable to create the account as the email is already in use by %(display_name)s. Try a different email address.", gettext("We were unable to create the account as the email is already in use by %(display_name)s. Try a different email address.",
display_name=user_by_email.display_name)) display_name=user_by_email.display_name))
return redirect(url_for("flatpage", path="email_sent")) return redirect(url_for("users.email_sent"))
elif EmailSubscription.query.filter_by(email=form.email.data, blacklisted=True).count() > 0: elif EmailSubscription.query.filter_by(email=form.email.data, blacklisted=True).count() > 0:
flash(gettext("That email address has been unsubscribed/blacklisted, and cannot be used"), "danger") flash(gettext("That email address has been unsubscribed/blacklisted, and cannot be used"), "danger")
return return
@ -165,7 +165,7 @@ def handle_register(form):
send_verify_email.delay(form.email.data, token) send_verify_email.delay(form.email.data, token)
return redirect(url_for("flatpage", path="email_sent")) return redirect(url_for("users.email_sent"))
@bp.route("/user/register/", methods=["GET", "POST"]) @bp.route("/user/register/", methods=["GET", "POST"])
@ -224,7 +224,7 @@ def forgot_password():
</p> </p>
""") """)
return redirect(url_for("flatpage", path="email_sent")) return redirect(url_for("users.email_sent"))
return render_template("users/forgot_password.html", form=form) return render_template("users/forgot_password.html", form=form)
@ -280,7 +280,7 @@ def handle_set_password(form):
send_verify_email.delay(form.email.data, token) send_verify_email.delay(form.email.data, token)
flash(gettext("Your password has been changed successfully."), "success") flash(gettext("Your password has been changed successfully."), "success")
return redirect(url_for("flatpage", path="email_sent")) return redirect(url_for("users.email_sent"))
db.session.commit() db.session.commit()
flash(gettext("Your password has been changed successfully."), "success") flash(gettext("Your password has been changed successfully."), "success")
@ -398,7 +398,7 @@ def unsubscribe_verify():
db.session.commit() db.session.commit()
send_unsubscribe_verify.delay(form.email.data) send_unsubscribe_verify.delay(form.email.data)
return redirect(url_for("flatpage", path="email_sent")) return redirect(url_for("users.email_sent"))
return render_template("users/unsubscribe.html", form=form) return render_template("users/unsubscribe.html", form=form)
@ -428,3 +428,8 @@ def unsubscribe():
return unsubscribe_manage(sub) return unsubscribe_manage(sub)
return unsubscribe_verify() return unsubscribe_verify()
@bp.route("/email_sent/")
def email_sent():
return render_template("users/email_sent.html")

@ -148,7 +148,7 @@ def handle_email_notifications(user, prefs: UserNotificationPreferences, is_new,
db.session.commit() db.session.commit()
send_verify_email.delay(newEmail, token) send_verify_email.delay(newEmail, token)
return redirect(url_for("flatpage", path="email_sent")) return redirect(url_for("users.email_sent"))
db.session.commit() db.session.commit()
return redirect(url_for("users.email_notifications", username=user.username)) return redirect(url_for("users.email_notifications", username=user.username))

@ -1,9 +0,0 @@
title: Check your email
toc: False
We've sent an email to the address you specified.
You'll need to click the link in the email to confirm it
**The link will expire in 12 hours**
<a class="btn btn-secondary" href="/help/faq/#my-verification-email-never-arrived">My email never arrived</a>

@ -0,0 +1,25 @@
{% extends "base.html" %}
{% block title %}
{{ _("Check Your Email") }}
{% endblock %}
{% block content %}
<h1>{{ self.title() }}</h1>
<p>
{{ _("We've sent an email to the address you specified.") }}
{{ _("You'll need to click the link in the email to confirm it.") }}</p>
<p>
<strong>
{{ _("The link will expire in 12 hours") }}
</strong>
</p>
<p>
<a class="btn btn-secondary" href="/help/faq/#my-verification-email-never-arrived">
{{ _("My email never arrived") }}
</a>
</p>
{% endblock %}