Sort shelves by shelfbook updated date

This commit is contained in:
Mouse Reeve 2020-12-30 16:07:29 -08:00
parent 670036f8a9
commit 885bb023a3
3 changed files with 8 additions and 3 deletions

View file

@ -122,7 +122,7 @@
<div class="block">
<div>
{% include 'snippets/shelf.html' with shelf=shelf ratings=ratings %}
{% include 'snippets/shelf.html' with shelf=shelf books=books ratings=ratings %}
</div>
</div>
{% endblock %}

View file

@ -1,6 +1,6 @@
{% load humanize %}
{% load bookwyrm_tags %}
{% if shelf.books.all|length > 0 %}
{% if books|length > 0 %}
<table class="table is-striped is-fullwidth">
<tr class="book-preview">
@ -34,7 +34,7 @@
</th>
{% endif %}
</tr>
{% for book in shelf.books.all %}
{% for book in books %}
<tr class="book-preview">
<td>
{% include 'snippets/book_cover.html' with book=book size="small" %}

View file

@ -765,12 +765,17 @@ def shelf_page(request, username, shelf_identifier):
if is_api_request(request):
return ActivitypubResponse(shelf.to_activity(**request.GET))
books = models.ShelfBook.objects.filter(
added_by=user, shelf=shelf
).order_by('-updated_date').all()
data = {
'title': '%s\'s %s shelf' % (user.display_name, shelf.name),
'user': user,
'is_self': is_self,
'shelves': shelves.all(),
'shelf': shelf,
'books': [b.book for b in books],
}
return TemplateResponse(request, 'shelf.html', data)