From 03ba01a790c7235c84b3019410bcb5132cabdc45 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sun, 4 Apr 2021 10:36:28 -0700 Subject: [PATCH] Expands filtering and sorting on invite requests page --- bookwyrm/templates/settings/manage_invite_requests.html | 9 +++++++-- bookwyrm/views/invite.py | 8 ++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/bookwyrm/templates/settings/manage_invite_requests.html b/bookwyrm/templates/settings/manage_invite_requests.html index 63730893..bbe3beb7 100644 --- a/bookwyrm/templates/settings/manage_invite_requests.html +++ b/bookwyrm/templates/settings/manage_invite_requests.html @@ -28,13 +28,17 @@ {% include 'settings/invite_request_filters.html' %} - +
{% url 'settings-invite-requests' as url %} + +
- {% trans "Date" as text %} + {% trans "Date requested" as text %} {% include 'snippets/table-sort-header.html' with field="created_date" sort=sort text=text %} + {% trans "Date accepted" as text %} + {% include 'snippets/table-sort-header.html' with field="invite__invitees__created_date" sort=sort text=text %} + {% trans "Email" %} {% trans "Status" as text %} @@ -48,6 +52,7 @@ {% for req in requests %}
{{ req.created_date | naturaltime }}{{ req.invite.invitees.first.created_date | naturaltime }} {{ req.email }} {% if req.invite.times_used %} diff --git a/bookwyrm/views/invite.py b/bookwyrm/views/invite.py index 665f98ce..61f031ef 100644 --- a/bookwyrm/views/invite.py +++ b/bookwyrm/views/invite.py @@ -99,7 +99,11 @@ class ManageInviteRequests(View): page = 1 sort = request.GET.get("sort") - sort_fields = ["created_date", "invite__times_used"] + sort_fields = [ + "created_date", + "invite__times_used", + "invite__invitees__created_date", + ] if not sort in sort_fields + ["-{:s}".format(f) for f in sort_fields]: sort = "-created_date" @@ -115,7 +119,7 @@ class ManageInviteRequests(View): if "requested" in status_filters: filters.append({"invite__isnull": True}) if "sent" in status_filters: - filters.append({"invite__isnull": False}) + filters.append({"invite__isnull": False, "invite__times_used": 0}) if "accepted" in status_filters: filters.append({"invite__isnull": False, "invite__times_used__gte": 1})