From c36e6f1ad5f5bae32acf494ce17eeb8c487c2bce Mon Sep 17 00:00:00 2001 From: rimu <3310831+rimu@users.noreply.github.com> Date: Sat, 24 Feb 2024 14:19:07 +1300 Subject: [PATCH] unsubscribe to unread notifs email --- app/templates/email/unread_notifications.html | 3 +-- app/templates/email/unread_notifications.txt | 2 +- .../user/email_notifs_unsubscribed.html | 17 +++++++++++++++++ app/user/routes.py | 9 +++++++++ 4 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 app/templates/user/email_notifs_unsubscribed.html diff --git a/app/templates/email/unread_notifications.html b/app/templates/email/unread_notifications.html index ac2c13ba..7d1e9a06 100644 --- a/app/templates/email/unread_notifications.html +++ b/app/templates/email/unread_notifications.html @@ -15,5 +15,4 @@ {% endfor %} {% endif %} -

Unsubscribe from these emails by un-ticking the 'Receive email - about missed notifications' checkbox.

\ No newline at end of file +

Unsubscribe from these emails

\ No newline at end of file diff --git a/app/templates/email/unread_notifications.txt b/app/templates/email/unread_notifications.txt index f8e06ba4..0b1d0878 100644 --- a/app/templates/email/unread_notifications.txt +++ b/app/templates/email/unread_notifications.txt @@ -5,4 +5,4 @@ Here's some notifications you've missed since your last visit: - {{ notification.title }} - {{ url_for('user.notification_goto', notification_id=notification.id, _external=True) }} {% endfor %} -Unsubscribe from these emails by un-ticking the 'Receive email about missed notifications' checkbox at {{ url_for('user.change_settings', _external=True) }}. +Unsubscribe from these emails at {{ url_for('user.user_email_notifs_unsubscribe', user_id=user.id, token=user.verification_token, _external=True) }}. diff --git a/app/templates/user/email_notifs_unsubscribed.html b/app/templates/user/email_notifs_unsubscribed.html new file mode 100644 index 00000000..b8b02885 --- /dev/null +++ b/app/templates/user/email_notifs_unsubscribed.html @@ -0,0 +1,17 @@ +{% extends 'base.html' %} +{% from 'bootstrap/form.html' import render_form %} + +{% block app_content %} +
+
+
+
+
{{ _('Unsubscribed') }}
+

{{ _('You have unsubscribed from emails about unread notifications. We might email you for other reasons, though.') }}

+

{{ _('More email settings') }}

+
+
+
+
+ +{% endblock %} diff --git a/app/user/routes.py b/app/user/routes.py index 94c0c4e0..ac4a53dc 100644 --- a/app/user/routes.py +++ b/app/user/routes.py @@ -701,3 +701,12 @@ def user_newsletter_unsubscribe(user_id, token): user.newsletter = False db.session.commit() return render_template('user/newsletter_unsubscribed.html') + + +@bp.route('/user/email_notifs///unsubscribe', methods=['GET', 'POST']) +def user_email_notifs_unsubscribe(user_id, token): + user = User.query.filter(User.id == user_id, User.verification_token == token).first() + if user: + user.email_unread = False + db.session.commit() + return render_template('user/email_notifs_unsubscribed.html')