Expands filtering and sorting on invite requests page

This commit is contained in:
Mouse Reeve 2021-04-04 10:36:28 -07:00
parent ecf489b0bd
commit 03ba01a790
2 changed files with 13 additions and 4 deletions

View file

@ -28,13 +28,17 @@
{% include 'settings/invite_request_filters.html' %}
<table class="table is-striped">
<table class="table is-striped is-fullwidth">
{% url 'settings-invite-requests' as url %}
<tr>
<th>
{% trans "Date" as text %}
{% trans "Date requested" as text %}
{% include 'snippets/table-sort-header.html' with field="created_date" sort=sort text=text %}
</th>
<th>
{% trans "Date accepted" as text %}
{% include 'snippets/table-sort-header.html' with field="invite__invitees__created_date" sort=sort text=text %}
</th>
<th>{% trans "Email" %}</th>
<th>
{% trans "Status" as text %}
@ -48,6 +52,7 @@
{% for req in requests %}
<tr>
<td>{{ req.created_date | naturaltime }}</td>
<td>{{ req.invite.invitees.first.created_date | naturaltime }}</td>
<td>{{ req.email }}</td>
<td>
{% if req.invite.times_used %}

View file

@ -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})