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

Improve code of dashboard.

parent deec0fe5
No related branches found
No related tags found
1 merge request!100Resolve "Dashboard"
Pipeline #561 failed
......@@ -10,7 +10,7 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="description" content="Selbst programmierte Anwendungen für den Schullaltag am Katharineum zu Lübeck">
<meta name="description" content="AlekSIS is a web-based school information system (SIS) which can be used to manage and/or publish organisational data of educational institutions.">
<title>AlekSIS - School Information System</title>
......
......@@ -24,18 +24,14 @@ from .util import messages
def index(request: HttpRequest) -> HttpResponse:
context = {}
user = request.user
if user.is_authenticated:
if request.user.is_authenticated:
activities = request.user.person.activities.all()[:5]
notifications = (
request.user.person.notifications.all().filter(user=request.user.person).order_by("-created_at")[:5]
request.user.person.notifications.all()[:5]
)
unread_notifications = (
request.user.person.notifications.all()
.filter(user=request.user.person, read=False)
.order_by("-created_at")
request.user.person.notifications.all().filter(read=False)
)
context["activities"] = activities
......@@ -259,13 +255,15 @@ def edit_schoolterm(request: HttpRequest) -> HttpResponse:
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.read = True
notification.save()
if notification.user == request.user:
notification.read = True
notification.save()
else:
messages.danger(request, _("You are not allowed to mark notifications from other users 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