Merge pull request #872 from mouse-reeve/invite-management

Expands filtering and sorting on invite requests page
This commit is contained in:
Mouse Reeve 2021-04-04 10:58:57 -07:00 committed by GitHub
commit 2d044746de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 6 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 %}
@ -58,7 +63,7 @@
{% trans "Requested" %}
{% endif %}
</td>
<td class="field is-grouped">
<td><div class="field is-grouped">
{# no invite OR invite not yet used #}
{% if not req.invite.times_used %}
<form name="send-invite" method="post">
@ -93,7 +98,7 @@
{% endif %}
</form>
{% endif %}
</td>
</div></td>
</tr>
{% endfor %}
</table>

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