forked from mirrors/bookwyrm
Adds filtered view for notifications
This commit is contained in:
parent
78f3e2efc2
commit
1cc63c6d45
2 changed files with 11 additions and 2 deletions
|
@ -139,6 +139,11 @@ urlpatterns = [
|
||||||
path("", views.Home.as_view(), name="landing"),
|
path("", views.Home.as_view(), name="landing"),
|
||||||
re_path(r"^discover/?$", views.Discover.as_view()),
|
re_path(r"^discover/?$", views.Discover.as_view()),
|
||||||
re_path(r"^notifications/?$", views.Notifications.as_view(), name="notifications"),
|
re_path(r"^notifications/?$", views.Notifications.as_view(), name="notifications"),
|
||||||
|
re_path(
|
||||||
|
r"^notifications/(?P<notification_type>mentions)/?$",
|
||||||
|
views.Notifications.as_view(),
|
||||||
|
name="notifications",
|
||||||
|
),
|
||||||
re_path(r"^directory/?", views.Directory.as_view(), name="directory"),
|
re_path(r"^directory/?", views.Directory.as_view(), name="directory"),
|
||||||
# Get started
|
# Get started
|
||||||
re_path(
|
re_path(
|
||||||
|
|
|
@ -11,10 +11,14 @@ from django.views import View
|
||||||
class Notifications(View):
|
class Notifications(View):
|
||||||
"""notifications view"""
|
"""notifications view"""
|
||||||
|
|
||||||
def get(self, request):
|
def get(self, request, notification_type=None):
|
||||||
"""people are interacting with you, get hyped"""
|
"""people are interacting with you, get hyped"""
|
||||||
notifications = request.user.notification_set.all().order_by("-created_date")
|
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 = {
|
data = {
|
||||||
"notifications": notifications[:50],
|
"notifications": notifications[:50],
|
||||||
"unread": unread,
|
"unread": unread,
|
||||||
|
|
Loading…
Reference in a new issue