diff --git a/bookwyrm/templates/user/relationships/layout.html b/bookwyrm/templates/user/relationships/layout.html index e83e53471..5baaf1f96 100644 --- a/bookwyrm/templates/user/relationships/layout.html +++ b/bookwyrm/templates/user/relationships/layout.html @@ -6,14 +6,14 @@ {% with user|username as username %} {% endwith %} diff --git a/bookwyrm/templates/user/user_preview.html b/bookwyrm/templates/user/user_preview.html index c641c58fb..89b545cec 100644 --- a/bookwyrm/templates/user/user_preview.html +++ b/bookwyrm/templates/user/user_preview.html @@ -1,5 +1,6 @@ {% load i18n %} {% load humanize %} +{% load bookwyrm_tags %}
@@ -12,8 +13,19 @@

{{ user.username }}

{% blocktrans with date=user.created_date|naturaltime %}Joined {{ date }}{% endblocktrans %}

- {% blocktrans count counter=user.followers.count %}{{ counter }} follower{% plural %}{{ counter }} followers{% endblocktrans %}, - {% blocktrans with counter=user.following.count %}{{ counter }} following{% endblocktrans %} + {% if is_self %} + + {% blocktrans count counter=user.followers.count %}{{ counter }} follower{% plural %}{{ counter }} followers{% endblocktrans %}, + {% blocktrans with counter=user.following.count %}{{ counter }} following{% endblocktrans %} + + {% else %} + + {% mutuals_count user as mutuals %} + + {% blocktrans with mutuals_display=mutuals|intcomma count counter=mutuals %}{{ mutuals_display }} follower you follow{% plural %}{{ mutuals_display }} followers you follow{% endblocktrans %} + + + {% endif %}

diff --git a/bookwyrm/templatetags/bookwyrm_tags.py b/bookwyrm/templatetags/bookwyrm_tags.py index 2ed0cbc2b..2697d3ced 100644 --- a/bookwyrm/templatetags/bookwyrm_tags.py +++ b/bookwyrm/templatetags/bookwyrm_tags.py @@ -235,3 +235,10 @@ def get_lang(): """get current language, strip to the first two letters""" language = utils.translation.get_language() 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()