Add clear all button to notifications page

This commit is contained in:
rubenwardy 2018-05-29 17:20:11 +01:00
parent 7e80adad56
commit 52fdc8c212
No known key found for this signature in database
GPG Key ID: A1E29D52FF81513C
2 changed files with 14 additions and 1 deletions

View File

@ -5,6 +5,12 @@ Notifications
{% endblock %}
{% block content %}
{% if current_user.notifications %}
<form method="post" action="{{ url_for('clear_notifications_page') }}">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<input type="submit" value="Clear All" />
</form>
{% endif %}
<ul>
{% for n in current_user.notifications %}
<li><a href="{{ n.url }}">

View File

@ -23,4 +23,11 @@ from app.models import *
@app.route("/notifications/")
@login_required
def notifications_page():
return render_template("notifications/list.html")
return render_template("notifications/list.html")
@app.route("/notifications/clear/", methods=["POST"])
@login_required
def clear_notifications_page():
current_user.notifications.clear()
db.session.commit()
return redirect(url_for("notifications_page"))