Reverse order of notification related users

This commit is contained in:
Mouse Reeve 2022-07-12 10:32:56 -07:00
parent e3dbe5a142
commit 3670ae46ec
2 changed files with 11 additions and 6 deletions

View file

@ -2,7 +2,7 @@
{% load humanize %}
{% related_status notification as related_status %}
{% with related_users=notification.related_users.all.distinct %}
{% get_related_users notification as related_users %}
{% with related_user_count=notification.related_users.count %}
<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 %}">
@ -16,7 +16,7 @@
{% if related_user_count > 1 %}
<div class="block">
<ul class="is-flex">
{% for user in related_users|slice:10 %}
{% for user in related_users %}
<li class="mr-2">
<a href="{{ user.local_path }}">
{% include 'snippets/avatar.html' with user=user %}
@ -28,7 +28,7 @@
{% endif %}
<div class="block content">
{% if related_user_count == 1 %}
{% with user=related_users.first %}
{% with user=related_users.0 %}
{% spaceless %}
<a href="{{ user.local_path }}" class="mr-2">
{% include 'snippets/avatar.html' with user=user %}
@ -37,8 +37,8 @@
{% endwith %}
{% endif %}
{% with related_user=related_users.first.display_name %}
{% with related_user_link=related_users.first.local_path %}
{% with related_user=related_users.0.display_name %}
{% with related_user_link=related_users.0.local_path %}
{% with second_user=related_users.1.display_name %}
{% with second_user_link=related_users.1.local_path %}
{% with other_user_count=related_user_count|add:"-1" %}
@ -61,4 +61,3 @@
</div>
</div>
{% endwith %}
{% endwith %}

View file

@ -12,3 +12,9 @@ def related_status(notification):
if not notification.related_status:
return None
return load_subclass(notification.related_status)
@register.simple_tag(takes_context=False)
def get_related_users(notification):
"""Who actually was it who liked your post"""
return list(reversed(list(notification.related_users.distinct())))[:10]