From a47e6e89983809c18bea497532f960b099f44425 Mon Sep 17 00:00:00 2001
From: rubenwardy
Date: Thu, 20 Jan 2022 21:55:16 +0000
Subject: [PATCH] Move /email_sent/ to flask endpoint, to allow translation
---
app/blueprints/users/account.py | 15 ++++++++++-----
app/blueprints/users/settings.py | 2 +-
app/flatpages/email_sent.md | 9 ---------
app/templates/users/email_sent.html | 25 +++++++++++++++++++++++++
4 files changed, 36 insertions(+), 15 deletions(-)
delete mode 100644 app/flatpages/email_sent.md
create mode 100644 app/templates/users/email_sent.html
diff --git a/app/blueprints/users/account.py b/app/blueprints/users/account.py
index 0c1070de..79c0d0fc 100644
--- a/app/blueprints/users/account.py
+++ b/app/blueprints/users/account.py
@@ -140,7 +140,7 @@ def handle_register(form):
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.",
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:
flash(gettext("That email address has been unsubscribed/blacklisted, and cannot be used"), "danger")
return
@@ -165,7 +165,7 @@ def handle_register(form):
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"])
@@ -224,7 +224,7 @@ def forgot_password():
""")
- return redirect(url_for("flatpage", path="email_sent"))
+ return redirect(url_for("users.email_sent"))
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)
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()
flash(gettext("Your password has been changed successfully."), "success")
@@ -398,7 +398,7 @@ def unsubscribe_verify():
db.session.commit()
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)
@@ -428,3 +428,8 @@ def unsubscribe():
return unsubscribe_manage(sub)
return unsubscribe_verify()
+
+
+@bp.route("/email_sent/")
+def email_sent():
+ return render_template("users/email_sent.html")
diff --git a/app/blueprints/users/settings.py b/app/blueprints/users/settings.py
index f5e2e873..d1cc5bf3 100644
--- a/app/blueprints/users/settings.py
+++ b/app/blueprints/users/settings.py
@@ -148,7 +148,7 @@ def handle_email_notifications(user, prefs: UserNotificationPreferences, is_new,
db.session.commit()
send_verify_email.delay(newEmail, token)
- return redirect(url_for("flatpage", path="email_sent"))
+ return redirect(url_for("users.email_sent"))
db.session.commit()
return redirect(url_for("users.email_notifications", username=user.username))
diff --git a/app/flatpages/email_sent.md b/app/flatpages/email_sent.md
deleted file mode 100644
index 255699fd..00000000
--- a/app/flatpages/email_sent.md
+++ /dev/null
@@ -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**
-
-My email never arrived
\ No newline at end of file
diff --git a/app/templates/users/email_sent.html b/app/templates/users/email_sent.html
new file mode 100644
index 00000000..b676ab8b
--- /dev/null
+++ b/app/templates/users/email_sent.html
@@ -0,0 +1,25 @@
+{% extends "base.html" %}
+
+{% block title %}
+{{ _("Check Your Email") }}
+{% endblock %}
+
+{% block content %}
+{{ self.title() }}
+
+
+ {{ _("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") }}
+
+
+
+
+
+ {{ _("My email never arrived") }}
+
+
+{% endblock %}
\ No newline at end of file