From 812f322141f034c00b3260e6fbb6b19174ff5e8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lera=20Elvo=C3=A9?= Date: Wed, 10 Jun 2026 18:16:08 +0300 Subject: [PATCH] add unsubscribe from all button to inbox --- app/routes/threads.py | 9 +++++++++ app/templates/users/inbox.html | 2 ++ 2 files changed, 11 insertions(+) diff --git a/app/routes/threads.py b/app/routes/threads.py index a92a0c7..5a5f5cf 100644 --- a/app/routes/threads.py +++ b/app/routes/threads.py @@ -1,6 +1,7 @@ from flask import Blueprint, redirect, url_for, render_template, request, abort from functools import wraps from ..auth import login_required, get_active_user, is_logged_in +from ..db import db from ..models import Threads, Posts, Topics, Users, Reactions, Subscriptions from ..util import get_form_checkbox, time_now import math @@ -170,6 +171,14 @@ def unsubscribe(thread_id): @login_required def unsubscribe_all(): user = get_active_user() + subs = Subscriptions.findall({'user_id': user.id}) + if not subs: + return redirect(url_for('users.inbox', username=user.username)) + with db.transaction(): + for sub in subs: + sub.delete() + + return redirect(url_for('users.inbox', username=user.username)) @bp.post('/subscriptions/mark-read/') @login_required diff --git a/app/templates/users/inbox.html b/app/templates/users/inbox.html index cc56fe0..30bed9b 100644 --- a/app/templates/users/inbox.html +++ b/app/templates/users/inbox.html @@ -13,6 +13,7 @@ {%- endif -%} {%- endset -%} {%- call() subheader('Your inbox', topline) -%} +{%- if subscriptions -%}
Actions
@@ -25,6 +26,7 @@
+{%- endif -%} {%- endcall -%} {%- if subscriptions | length > 0 -%}