From e8cfa99cd908aabd173304fee70f8ba6126c057d Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 10 Mar 2020 13:31:57 -0700 Subject: [PATCH] Highlight unread notifications --- fedireads/static/format.css | 4 ++++ fedireads/templates/notifications.html | 2 +- fedireads/views.py | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/fedireads/static/format.css b/fedireads/static/format.css index 6cd3ba08..64b0d8da 100644 --- a/fedireads/static/format.css +++ b/fedireads/static/format.css @@ -221,3 +221,7 @@ th, td { .post.depth-4 { margin-left: 3em; } + +.unread { + background-color: #F3FFBD; +} diff --git a/fedireads/templates/notifications.html b/fedireads/templates/notifications.html index e203fde0..81fd5a41 100644 --- a/fedireads/templates/notifications.html +++ b/fedireads/templates/notifications.html @@ -9,7 +9,7 @@ {% for notification in notifications %} -
+

{% if notification.notification_type == 'FAVORITE' %} {% include 'snippets/username.html' with user=notification.related_user %} diff --git a/fedireads/views.py b/fedireads/views.py index f06dd6cd..1d9f799c 100644 --- a/fedireads/views.py +++ b/fedireads/views.py @@ -139,12 +139,15 @@ def register(request): return redirect('/') +@login_required def notifications_page(request): ''' list notitications ''' notifications = request.user.notification_set.all() \ .order_by('-created_date') + unread = [n.id for n in notifications.filter(read=False)] data = { 'notifications': notifications, + 'unread': unread, } notifications.update(read=True) return TemplateResponse(request, 'notifications.html', data)