add unsubscribe from all button to inbox
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
from flask import Blueprint, redirect, url_for, render_template, request, abort
|
from flask import Blueprint, redirect, url_for, render_template, request, abort
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from ..auth import login_required, get_active_user, is_logged_in
|
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 ..models import Threads, Posts, Topics, Users, Reactions, Subscriptions
|
||||||
from ..util import get_form_checkbox, time_now
|
from ..util import get_form_checkbox, time_now
|
||||||
import math
|
import math
|
||||||
@@ -170,6 +171,14 @@ def unsubscribe(thread_id):
|
|||||||
@login_required
|
@login_required
|
||||||
def unsubscribe_all():
|
def unsubscribe_all():
|
||||||
user = get_active_user()
|
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/')
|
@bp.post('/subscriptions/mark-read/')
|
||||||
@login_required
|
@login_required
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
{%- endset -%}
|
{%- endset -%}
|
||||||
{%- call() subheader('Your inbox', topline) -%}
|
{%- call() subheader('Your inbox', topline) -%}
|
||||||
|
{%- if subscriptions -%}
|
||||||
<fieldset class="plank even no-shadow minimal subheader-actions">
|
<fieldset class="plank even no-shadow minimal subheader-actions">
|
||||||
<legend>Actions</legend>
|
<legend>Actions</legend>
|
||||||
<form method="POST" action="{{url_for('threads.mark_read')}}">
|
<form method="POST" action="{{url_for('threads.mark_read')}}">
|
||||||
@@ -25,6 +26,7 @@
|
|||||||
<button class="warn">Unsubscribe from all</button>
|
<button class="warn">Unsubscribe from all</button>
|
||||||
</form>
|
</form>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
{%- endif -%}
|
||||||
{%- endcall -%}
|
{%- endcall -%}
|
||||||
{%- if subscriptions | length > 0 -%}
|
{%- if subscriptions | length > 0 -%}
|
||||||
<div class="plank">
|
<div class="plank">
|
||||||
|
|||||||
Reference in New Issue
Block a user