forked from mirrors/bookwyrm
Merge branch 'bookwyrm-social:main' into storygraph-import
This commit is contained in:
commit
df99060898
3 changed files with 31 additions and 5 deletions
|
@ -6,13 +6,30 @@
|
|||
{% block title %}{% trans "Notifications" %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="block">
|
||||
<h1 class="title">{% trans "Notifications" %}</h1>
|
||||
<header class="columns">
|
||||
<div class="column">
|
||||
<h1 class="title">{% trans "Notifications" %}</h1>
|
||||
</div>
|
||||
|
||||
<form name="clear" action="/notifications" method="POST">
|
||||
<form name="clear" action="/notifications" method="POST" class="column is-narrow">
|
||||
{% csrf_token %}
|
||||
<button class="button is-danger is-light" type="submit" class="secondary">{% trans "Delete notifications" %}</button>
|
||||
</form>
|
||||
</header>
|
||||
|
||||
<div class="block">
|
||||
<nav class="tabs">
|
||||
<ul>
|
||||
{% url 'notifications' as tab_url %}
|
||||
<li {% if tab_url == request.path %}class="is-active"{% endif %}>
|
||||
<a href="{{ tab_url }}">{% trans "All" %}</a>
|
||||
</li>
|
||||
{% url 'notifications' 'mentions' as tab_url %}
|
||||
<li {% if tab_url == request.path %}class="is-active"{% endif %}>
|
||||
<a href="{{ tab_url }}">{% trans "Mentions" %}</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
<div class="block">
|
||||
|
|
|
@ -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/(?P<notification_type>mentions)/?$",
|
||||
views.Notifications.as_view(),
|
||||
name="notifications",
|
||||
),
|
||||
re_path(r"^directory/?", views.Directory.as_view(), name="directory"),
|
||||
# Get started
|
||||
re_path(
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue