diff --git a/bookwyrm/templates/settings/federation.html b/bookwyrm/templates/settings/federation.html index cfcf4d9c8..696d7a205 100644 --- a/bookwyrm/templates/settings/federation.html +++ b/bookwyrm/templates/settings/federation.html @@ -8,13 +8,25 @@ - - + {% url 'settings-federation' as url %} + + + {% for server in servers %} + diff --git a/bookwyrm/templates/snippets/table-sort-header.html b/bookwyrm/templates/snippets/table-sort-header.html new file mode 100644 index 000000000..bb34591d4 --- /dev/null +++ b/bookwyrm/templates/snippets/table-sort-header.html @@ -0,0 +1,13 @@ +{% load i18n %} + + {{ text }} + {% if sort == field %} + + {% trans "Sorted asccending" %} + + {% elif sort == "-"|add:field %} + + {% trans "Sorted descending" %} + + {% endif %} + diff --git a/bookwyrm/views/federation.py b/bookwyrm/views/federation.py index 92f590bcb..8a246e28c 100644 --- a/bookwyrm/views/federation.py +++ b/bookwyrm/views/federation.py @@ -27,8 +27,14 @@ class Federation(View): page = 1 servers = models.FederatedServer.objects.all() + + sort = request.GET.get('sort') + sort_fields = ['created_date', 'application_type', 'server_name'] + if sort in sort_fields + ["-{:s}".format(f) for f in sort_fields]: + servers = servers.order_by(sort) + paginated = Paginator(servers, PAGE_LENGTH) - data = {"servers": paginated.page(page)} + data = {"servers": paginated.page(page), "sort": sort} return TemplateResponse(request, "settings/federation.html", data)
{% trans "Server name" %}{% trans "Software" %} + {% trans "Server name" as text %} + {% include 'snippets/table-sort-header.html' with field="server_name" sort=sort text=text %} + + {% trans "Date federated" as text %} + {% include 'snippets/table-sort-header.html' with field="created_date" sort=sort text=text %} + + {% trans "Software" as text %} + {% include 'snippets/table-sort-header.html' with field="application_type" sort=sort text=text %} + {% trans "Status" %}
{{ server.server_name }}{{ server.created_date }} {{ server.application_type }} ({{ server.application_version }}) {{ server.status }}