From 1cc63c6d456f867791867787d6ee6377abec3128 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 7 May 2021 13:55:41 -0700 Subject: [PATCH 1/2] Adds filtered view for notifications --- bookwyrm/urls.py | 5 +++++ bookwyrm/views/notifications.py | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index 3e7dea58a..3fdced387 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -139,6 +139,11 @@ urlpatterns = [ path("", views.Home.as_view(), name="landing"), re_path(r"^discover/?$", views.Discover.as_view()), re_path(r"^notifications/?$", views.Notifications.as_view(), name="notifications"), + re_path( + r"^notifications/(?Pmentions)/?$", + views.Notifications.as_view(), + name="notifications", + ), re_path(r"^directory/?", views.Directory.as_view(), name="directory"), # Get started re_path( diff --git a/bookwyrm/views/notifications.py b/bookwyrm/views/notifications.py index 3d08cade5..b96bc9259 100644 --- a/bookwyrm/views/notifications.py +++ b/bookwyrm/views/notifications.py @@ -11,10 +11,14 @@ from django.views import View class Notifications(View): """notifications view""" - def get(self, request): + def get(self, request, notification_type=None): """people are interacting with you, get hyped""" notifications = request.user.notification_set.all().order_by("-created_date") - unread = [n.id for n in notifications.filter(read=False)] + if notification_type == "mentions": + notifications = notifications.filter( + notification_type__in=["REPLY", "MENTION", "TAG"] + ) + unread = [n.id for n in notifications.filter(read=False)[:50]] data = { "notifications": notifications[:50], "unread": unread, From 852f8da62e4fa3b5a65c200109d7f0455feae881 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 7 May 2021 14:00:55 -0700 Subject: [PATCH 2/2] Adds tabs to notifications --- bookwyrm/templates/notifications.html | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/bookwyrm/templates/notifications.html b/bookwyrm/templates/notifications.html index 8f8fede2f..ed623b129 100644 --- a/bookwyrm/templates/notifications.html +++ b/bookwyrm/templates/notifications.html @@ -6,13 +6,30 @@ {% block title %}{% trans "Notifications" %}{% endblock %} {% block content %} -
-

{% trans "Notifications" %}

+
+
+

{% trans "Notifications" %}

+
-
+ {% csrf_token %}
+
+ +
+