mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 03:21:05 +00:00
Make invite requests sort-able
This commit is contained in:
parent
821baa5f18
commit
b5e98e0bdf
2 changed files with 16 additions and 3 deletions
|
@ -27,10 +27,17 @@
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
<table class="table is-striped">
|
<table class="table is-striped">
|
||||||
|
{% url 'settings-invite-requests' as url %}
|
||||||
<tr>
|
<tr>
|
||||||
<th>{% trans "Date" %}</th>
|
<th>
|
||||||
|
{% trans "Date" as text %}
|
||||||
|
{% include 'snippets/table-sort-header.html' with field="created_date" sort=sort text=text %}
|
||||||
|
</th>
|
||||||
<th>{% trans "Email" %}</th>
|
<th>{% trans "Email" %}</th>
|
||||||
<th>{% trans "Status" %}</th>
|
<th>
|
||||||
|
{% trans "Status" as text %}
|
||||||
|
{% include 'snippets/table-sort-header.html' with field="invite__times_used" sort=sort text=text %}
|
||||||
|
</th>
|
||||||
<th>{% trans "Action" %}</th>
|
<th>{% trans "Action" %}</th>
|
||||||
</tr>
|
</tr>
|
||||||
{% if not requests %}
|
{% if not requests %}
|
||||||
|
|
|
@ -92,9 +92,14 @@ class ManageInviteRequests(View):
|
||||||
except ValueError:
|
except ValueError:
|
||||||
page = 1
|
page = 1
|
||||||
|
|
||||||
|
sort = request.GET.get("sort")
|
||||||
|
sort_fields = ["created_date", "invite__times_used"]
|
||||||
|
if not sort in sort_fields + ["-{:s}".format(f) for f in sort_fields]:
|
||||||
|
sort = "-created_date"
|
||||||
|
|
||||||
paginated = Paginator(
|
paginated = Paginator(
|
||||||
models.InviteRequest.objects.filter(ignored=ignored).order_by(
|
models.InviteRequest.objects.filter(ignored=ignored).order_by(
|
||||||
"-created_date"
|
sort
|
||||||
),
|
),
|
||||||
PAGE_LENGTH,
|
PAGE_LENGTH,
|
||||||
)
|
)
|
||||||
|
@ -103,6 +108,7 @@ class ManageInviteRequests(View):
|
||||||
"ignored": ignored,
|
"ignored": ignored,
|
||||||
"count": paginated.count,
|
"count": paginated.count,
|
||||||
"requests": paginated.page(page),
|
"requests": paginated.page(page),
|
||||||
|
"sort": sort,
|
||||||
}
|
}
|
||||||
return TemplateResponse(request, "settings/manage_invite_requests.html", data)
|
return TemplateResponse(request, "settings/manage_invite_requests.html", data)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue