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>
Shelved
</th>
<th>
Started
</th>
<th>
Finished
</th>
<th>
External links
</th>
@ -44,6 +50,13 @@
<td>
{{ book.created_date | naturalday }}
</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>
<a href="https://openlibrary.org/book/{{ book.openlibrary_key }}" target="_blank">OpenLibrary</a>
</td>

View file

@ -168,3 +168,8 @@ def current_shelf(context, book):
return None
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()