Adds counts of blocked and federated instances

This commit is contained in:
Mouse Reeve 2022-02-28 12:27:54 -08:00
parent 991461221d
commit f4aa202292
2 changed files with 8 additions and 2 deletions

View file

@ -16,11 +16,11 @@
<ul> <ul>
{% url 'settings-federation' status='federated' as url %} {% url 'settings-federation' status='federated' as url %}
<li {% if request.path in url %}class="is-active" aria-current="page"{% endif %}> <li {% if request.path in url %}class="is-active" aria-current="page"{% endif %}>
<a href="{{ url }}">{% trans "Federated" %}</a> <a href="{{ url }}">{% trans "Federated" %} ({{ federated_count }})</a>
</li> </li>
{% url 'settings-federation' status='blocked' as url %} {% url 'settings-federation' status='blocked' as url %}
<li {% if url in request.path %}class="is-active" aria-current="page"{% endif %}> <li {% if url in request.path %}class="is-active" aria-current="page"{% endif %}>
<a href="{{ url }}">{% trans "Blocked" %}</a> <a href="{{ url }}">{% trans "Blocked" %} ({{ blocked_count }})</a>
</li> </li>
</ul> </ul>
</div> </div>

View file

@ -37,6 +37,12 @@ class Federation(View):
page = paginated.get_page(request.GET.get("page")) page = paginated.get_page(request.GET.get("page"))
data = { data = {
"federated_count": models.FederatedServer.objects.filter(
status="federated"
).count(),
"blocked_count": models.FederatedServer.objects.filter(
status="blocked"
).count(),
"servers": page, "servers": page,
"page_range": paginated.get_elided_page_range( "page_range": paginated.get_elided_page_range(
page.number, on_each_side=2, on_ends=1 page.number, on_each_side=2, on_ends=1