Updates templates for fav notifications

This commit is contained in:
Mouse Reeve 2022-07-04 21:32:53 -07:00
parent 971bed9942
commit f76d661e07
4 changed files with 64 additions and 12 deletions

View file

@ -34,11 +34,30 @@
{% endblocktrans %}
{% else %}
{% blocktrans trimmed %}
liked your <a href="{{ related_path }}">status</a>
{% if other_user_count == 0 %}
{% blocktrans trimmed %}
<a href="{{ related_user_link }}">{{ related_user }}</a> liked your <a href="{{ related_path }}">status</a>
{% endblocktrans %}
{% elif other_user_count == 1 %}
{% blocktrans trimmed %}
<a href="{{ related_user_link }}">{{ related_user }}</a>
and
<a href="{{ second_user_link }}">{{ second_user }}</a>
liked your <a href="{{ related_path }}">status</a>
{% endblocktrans %}
{% else %}
{% blocktrans trimmed %}
<a href="{{ related_user_link }}">{{ related_user }}</a> and {{ other_user_count }} others liked your <a href="{{ related_path }}">status</a>
{% endblocktrans %}
{% endif %}
{% endblocktrans %}
{% endif %}
{% endwith %}

View file

@ -1,5 +1,7 @@
{% load notification_page_tags %}
{% related_status notification as related_status %}
{% with related_users=notification.related_users.all %}
<div class="notification {% if notification.id in unread %}has-background-primary{% endif %}">
<div class="columns is-mobile {% if notification.id in unread %}has-text-white{% else %}has-text-more-muted{% endif %}">
<div class="column is-narrow is-size-3">
@ -9,13 +11,42 @@
</div>
<div class="column is-clipped">
{% if notification.related_users.count > 1 %}
<div class="block">
<ul class="is-flex">
{% for user in related_users|slice:10 %}
<li class="mr-2">
<a href="{{ user.local_path }}">
{% include 'snippets/avatar.html' with user=user %}
</a>
</li>
{% endfor %}
</ul>
</div>
{% endif %}
<div class="block content">
<p>
{% if notification.related_user %}
<a href="{{ notification.related_user.local_path }}">{% include 'snippets/avatar.html' with user=notification.related_user %}
{{ notification.related_user.display_name }}</a>
{% if notification.related_users.count == 1 %}
{% with user=related_users.first %}
{% spaceless %}
<a href="{{ user.local_path }}" class="mr-2">
{% include 'snippets/avatar.html' with user=user %}
</a>
{% endspaceless %}
{% endwith %}
{% endif %}
{% block description %}{% endblock %}
{% with related_user=related_users.first.display_name %}
{% with related_user_link=related_users.first.local_path %}
{% with second_user=related_users.all.1.display_name %}
{% with second_user_link=related_users.all.1.local_path %}
{% with other_user_count=notification.related_users.count|add:"-1" %}
{% block description %}{% endblock %}
{% endwith %}
{% endwith %}
{% endwith %}
{% endwith %}
{% endwith %}
</p>
</div>
@ -27,4 +58,4 @@
</div>
</div>
</div>
{% endwith %}

View file

@ -3,7 +3,6 @@
{% load i18n %}
{% block primary_link %}{% spaceless %}
{% url 'settings-report' notification.related_report.id %}
{% endspaceless %}{% endblock %}
{% block icon %}
@ -11,6 +10,6 @@
{% endblock %}
{% block description %}
{% url 'settings-report' notification.related_report.id as path %}
{% url 'settings-report' as path %}
{% blocktrans %}A new <a href="{{ path }}">report</a> needs moderation.{% endblocktrans %}
{% endblock %}

View file

@ -15,9 +15,12 @@ class Notifications(View):
"""people are interacting with you, get hyped"""
notifications = (
request.user.notification_set.all()
.order_by("-created_date")
.order_by("-updated_date")
.select_related(
"related_status",
"related_group",
)
.prefetch_related(
"related_statuses",
"related_import",
"related_reports",
"related_users",