Display start and finish dates in books list.

This commit is contained in:
Adam Kelly 2020-04-15 13:06:23 +01:00
parent 53ff28b5dc
commit 8e12071b99
2 changed files with 18 additions and 0 deletions

View file

@ -18,6 +18,12 @@
<th> <th>
Shelved Shelved
</th> </th>
<th>
Started
</th>
<th>
Finished
</th>
<th> <th>
External links External links
</th> </th>
@ -44,6 +50,13 @@
<td> <td>
{{ book.created_date | naturalday }} {{ book.created_date | naturalday }}
</td> </td>
{% latest_read_through book user as read_through %}
<td>
{{ read_through.start_date | naturalday |default_if_none:""}}
</td>
<td>
{{ read_through.finish_date | naturalday |default_if_none:""}}
</td>
<td> <td>
<a href="https://openlibrary.org/book/{{ book.openlibrary_key }}" target="_blank">OpenLibrary</a> <a href="https://openlibrary.org/book/{{ book.openlibrary_key }}" target="_blank">OpenLibrary</a>
</td> </td>

View file

@ -168,3 +168,8 @@ def current_shelf(context, book):
return None return None
return shelf.name return shelf.name
@register.simple_tag(takes_context=False)
def latest_read_through(book, user):
return models.ReadThrough.objects.filter(
user=user,
book=book).order_by('-created_date').first()