moviewyrm/bookwyrm/templates/snippets/shelf.html
2020-10-30 14:01:43 -07:00

87 lines
2 KiB
HTML

{% load humanize %}
{% load fr_display %}
{% if shelf.books.all|length > 0 %}
<table class="table is-striped is-fullwidth">
<tr class="book-preview">
<th>
Cover
</th>
<th>
Title
</th>
<th>
Author
</th>
<th>
Published
</th>
<th>
Shelved
</th>
<th>
Started
</th>
<th>
Finished
</th>
<th>
External links
</th>
{% if ratings %}
<th>
Rating
</th>
{% endif %}
</tr>
{% for book in shelf.books.all %}
<tr class="book-preview">
<td>
{% include 'snippets/book_cover.html' with book=book size="small" %}
</td>
<td>
<a href="/book/{{ book.id }}">{{ book.title }}</a>
</td>
<td>
{{ book.authors.first.display_name }}
</td>
<td>
{% if book.first_published_date %}{{ book.first_published_date }}{% endif %}
</td>
<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>
{% if ratings %}
<td>
{% include 'snippets/stars.html' with rating=ratings|dict_key:book.id %}
</td>
{% endif %}
<td>
<form name="unshelve" action="/unshelve/" method="post">
{% csrf_token %}
<input type="hidden" name="book" value="{{ book.id }}">
<input type="hidden" name="shelf" value="{{ shelf.id }}">
<button class="button is-small" type="submit" style="">
<span class="icon icon-x">
<span class="is-sr-only">Remove from shelf</span>
</span>
</button>
</form>
</td>
</tr>
{% endfor %}
</table>
{% else %}
<p>This shelf is empty.</p>
{% endif %}