add option to clear read history - privacy #331

This commit is contained in:
rimu 2024-09-30 14:09:29 +13:00
parent bc4fa5b202
commit a2db4c669e
2 changed files with 38 additions and 5 deletions

View file

@ -16,11 +16,15 @@
</ol>
</nav>
<h1>{{ _('Read posts') }}</h1>
<div class="post_list">
{% for post in posts.items -%}
{% include 'post/_post_teaser.html' %}
{% endfor -%}
</div>
{% if posts %}
<div class="post_list">
{% for post in posts.items -%}
{% include 'post/_post_teaser.html' %}
{% endfor -%}
</div>
{% else %}
<p>{{ _('No posts yet.') }}</p>
{% endif -%}
<nav aria-label="Pagination" class="mt-4" role="navigation">
{% if prev_url %}
@ -35,5 +39,24 @@
{% endif %}
</nav>
</div>
<aside id="side_pane" class="col-12 col-md-4 side_pane" role="complementary">
{% if current_user.is_authenticated and current_user.id == user.id %}
<div class="card mb-3">
<div class="card-header">
<h2>{{ _('Manage') }}</h2>
</div>
<div class="card-body">
<div class="row">
<div class="col-6">
<a href="{{ url_for('user.user_read_posts_delete') }}" class="btn btn-primary" style="float: right;">{{ _('Delete history') }}</a>
</div>
<div class="col-6">
</div>
</div>
</div>
</div>
{% endif %}
</aside>
</div>
{% endblock %}

View file

@ -1173,6 +1173,7 @@ def fediverse_redirect(actor):
form.instance_url.data = send_to
return render_template('user/fediverse_redirect.html', form=form, user=user, send_to=send_to, current_app=current_app)
@bp.route('/read-posts')
@login_required
def user_read_posts():
@ -1203,3 +1204,12 @@ def user_read_posts():
joined_communities=joined_communities(current_user.get_id()),
menu_topics=menu_topics(), site=g.site,
next_url=next_url, prev_url=prev_url)
@bp.route('/read-posts/delete')
@login_required
def user_read_posts_delete():
db.session.execute(text('DELETE FROM "read_posts" WHERE user_id = :user_id'), {'user_id': current_user.id})
db.session.commit()
flash(_('Reading history has been deleted'))
return redirect(url_for('user.user_read_posts'))