Adds instance name filter to federated instance list view

This lets you look for a specific server in your (probably very long)
instance list.
This commit is contained in:
Mouse Reeve 2022-07-02 11:07:11 -07:00
parent e0a67f5e18
commit 13e23a868d
2 changed files with 6 additions and 1 deletions

View file

@ -2,6 +2,7 @@
{% block filter_fields %}
{% include 'settings/federation/software_filter.html' %}
{% include 'settings/users/server_filter.html' %}
{% endblock %}

View file

@ -29,6 +29,8 @@ class Federation(View):
filters = {}
if software := request.GET.get("application_type"):
filters["application_type"] = software
if server := request.GET.get("server"):
filters["server_name"] = server
servers = models.FederatedServer.objects.filter(status=status, **filters)
@ -60,7 +62,9 @@ class Federation(View):
"sort": sort,
"software_options": models.FederatedServer.objects.values_list(
"application_type", flat=True
).distinct().order_by("application_type"),
)
.distinct()
.order_by("application_type"),
"form": forms.ServerForm(),
}
return TemplateResponse(request, "settings/federation/instance_list.html", data)