mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-24 00:50:35 +00:00
Show mutual counts instead of totals for other users
This commit is contained in:
parent
4dacf4df3a
commit
62884c6111
3 changed files with 25 additions and 6 deletions
|
@ -6,14 +6,14 @@
|
||||||
{% with user|username as username %}
|
{% with user|username as username %}
|
||||||
<nav class="tabs">
|
<nav class="tabs">
|
||||||
<ul>
|
<ul>
|
||||||
{% url 'user-following' user|username as url %}
|
|
||||||
<li{% if url == request.path or url == request.path|add:'/' %} class="is-active"{% endif %}>
|
|
||||||
<a href="{{ url }}">{% trans "Following" %}</a>
|
|
||||||
</li>
|
|
||||||
{% url 'user-followers' user|username as url %}
|
{% url 'user-followers' user|username as url %}
|
||||||
<li{% if url == request.path or url == request.path|add:'/' %} class="is-active"{% endif %}>
|
<li{% if url == request.path or url == request.path|add:'/' %} class="is-active"{% endif %}>
|
||||||
<a href="{{ url }}">{% trans "Followers" %}</a>
|
<a href="{{ url }}">{% trans "Followers" %}</a>
|
||||||
</li>
|
</li>
|
||||||
|
{% url 'user-following' user|username as url %}
|
||||||
|
<li{% if url == request.path or url == request.path|add:'/' %} class="is-active"{% endif %}>
|
||||||
|
<a href="{{ url }}">{% trans "Following" %}</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% load humanize %}
|
{% load humanize %}
|
||||||
|
{% load bookwyrm_tags %}
|
||||||
|
|
||||||
<div class="media block">
|
<div class="media block">
|
||||||
<div class="media-left">
|
<div class="media-left">
|
||||||
|
@ -12,8 +13,19 @@
|
||||||
<p><a href="{{ user.remote_id }}">{{ user.username }}</a></p>
|
<p><a href="{{ user.remote_id }}">{{ user.username }}</a></p>
|
||||||
<p>{% blocktrans with date=user.created_date|naturaltime %}Joined {{ date }}{% endblocktrans %}</p>
|
<p>{% blocktrans with date=user.created_date|naturaltime %}Joined {{ date }}{% endblocktrans %}</p>
|
||||||
<p>
|
<p>
|
||||||
<a href="{{ user.local_path }}/followers">{% blocktrans count counter=user.followers.count %}{{ counter }} follower{% plural %}{{ counter }} followers{% endblocktrans %}</a>,
|
{% if is_self %}
|
||||||
<a href="{{ user.local_path }}/following">{% blocktrans with counter=user.following.count %}{{ counter }} following{% endblocktrans %}</a>
|
|
||||||
|
<a href="{% url 'user-followers' user|username %}">{% blocktrans count counter=user.followers.count %}{{ counter }} follower{% plural %}{{ counter }} followers{% endblocktrans %}</a>,
|
||||||
|
<a href="{% url 'user-following' user|username %}">{% blocktrans with counter=user.following.count %}{{ counter }} following{% endblocktrans %}</a>
|
||||||
|
|
||||||
|
{% else %}
|
||||||
|
|
||||||
|
{% mutuals_count user as mutuals %}
|
||||||
|
<a href="{% url 'user-followers' user|username %}">
|
||||||
|
{% blocktrans with mutuals_display=mutuals|intcomma count counter=mutuals %}{{ mutuals_display }} follower you follow{% plural %}{{ mutuals_display }} followers you follow{% endblocktrans %}
|
||||||
|
</a>
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -235,3 +235,10 @@ def get_lang():
|
||||||
"""get current language, strip to the first two letters"""
|
"""get current language, strip to the first two letters"""
|
||||||
language = utils.translation.get_language()
|
language = utils.translation.get_language()
|
||||||
return language[0 : language.find("-")]
|
return language[0 : language.find("-")]
|
||||||
|
|
||||||
|
|
||||||
|
@register.simple_tag(takes_context=True)
|
||||||
|
def mutuals_count(context, user):
|
||||||
|
"""how many users that you follow, follow them"""
|
||||||
|
viewer = context["request"].user
|
||||||
|
return user.followers.filter(id__in=viewer.following.all()).count()
|
||||||
|
|
Loading…
Reference in a new issue