feat: add button to mark all notifications as read and fix action

This commit is contained in:
2025-07-13 00:31:21 +02:00
parent a4b8486bd4
commit afedf2d0bd
2 changed files with 17 additions and 4 deletions

View File

@@ -5,9 +5,22 @@
{% block content %}
<div class="block">
<h1 class="title is-1">{% translate 'Benachrichtigungen' %}</h1>
{% with notifications=notifications_unread %}
{% include "fellchensammlung/lists/list-notifications.html" %}
{% endwith %}
{% if notifications_unread|length > 0 %}
<div class="block">
<form class="button is-danger" method="POST">
{% csrf_token %}
<input type="hidden" name="action" value="notification_mark_all_read">
<button class="" type="submit" id="submit">
{% trans 'Alle Benachrichtigungen als gelesen markieren' %}
</button>
</form>
</div>
{% endif %}
<div class="block">
{% with notifications=notifications_unread %}
{% include "fellchensammlung/lists/list-notifications.html" %}
{% endwith %}
</div>
</div>
<div class="block">

View File

@@ -563,7 +563,7 @@ def process_notification_actions(request, action):
return render(request, "fellchensammlung/errors/403.html", status=403)
notification.mark_read()
elif action == "notification_mark_all_read":
notifications = Notification.objects.filter(user=request.user, mark_read=False)
notifications = Notification.objects.filter(user_to_notify=request.user, read=False)
for notification in notifications:
notification.mark_read()
return None