Skip to content
Snippets Groups Projects
Verified Commit 9b99b876 authored by Tom Teichler's avatar Tom Teichler :beers:
Browse files

Add function to mark notifications as read.

parent c651ef22
No related branches found
No related tags found
1 merge request!100Resolve "Dashboard"
......@@ -33,7 +33,7 @@
{% if notifications %}
<ul class="collection">
{% for notification in notifications %}
{% for notification in unread_notifications %}
<li class="collection-item">
<span class="badge new primary-color">{{ notification.app }}</span>
<span class="title">{{ notification.title }}</span>
......@@ -48,6 +48,9 @@
<a href="{{ notification.link }}">{% blocktrans %}More information →{% endblocktrans %}</a>
</p>
{% endif %}
<p>
<a href="{% url 'notification_mark_read' notification.id %}">{% blocktrans %}Mark as read{% endblocktrans%}</a>
</p>
</li>
{% endfor %}
</ul>
......
......@@ -29,6 +29,7 @@ urlpatterns = [
path("group/<int:id_>", views.group, name="group_by_id"),
path("group/<int:id_>/edit", views.edit_group, name="edit_group_by_id"),
path("", views.index, name="index"),
path("notifications/mark-read/<int:id_>", views.notification_mark_read, name="notification_mark_read"),
path("maintenance-mode/", include("maintenance_mode.urls")),
path("impersonate/", include("impersonate.urls")),
path("__i18n__/", include("django.conf.urls.i18n")),
......
......@@ -15,7 +15,7 @@ from .forms import (
EditTermForm,
PersonsAccountsFormSet,
)
from .models import Activity, Group, Person, School
from .models import Activity, Group, Notification, Person, School
from .tables import GroupsTable, PersonsTable
from .util import messages
......@@ -244,3 +244,15 @@ def edit_schoolterm(request: HttpRequest) -> HttpResponse:
context["edit_term_form"] = edit_term_form
return render(request, "core/edit_schoolterm.html", context)
@admin_required
def notification_mark_read(request: HttpRequest, id_: int) -> HttpResponse:
context = {}
notification = get_object_or_404(Notification, pk=id_)
Notification.objects.get(id=notification).delete()
messages.success(request, _("Marked as read"))
return redirect("index")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment