diff options
-rw-r--r-- | app/templates/notifications/list.html | 6 | ||||
-rw-r--r-- | app/views/notifications.py | 9 |
2 files changed, 14 insertions, 1 deletions
diff --git a/app/templates/notifications/list.html b/app/templates/notifications/list.html index fb133e8..d6de54e 100644 --- a/app/templates/notifications/list.html +++ b/app/templates/notifications/list.html @@ -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 }}"> diff --git a/app/views/notifications.py b/app/views/notifications.py index 4515ae5..23dbb31 100644 --- a/app/views/notifications.py +++ b/app/views/notifications.py @@ -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")) |