moviewyrm/bookwyrm/templates/snippets/shelf.html
2021-02-23 13:04:24 -08:00

92 lines
2 KiB
HTML

{% load humanize %}
{% load bookwyrm_tags %}
{% if books|length > 0 %}
<div class="table-container">
<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 books %}
<tr class="book-preview">
<td>
<a href="{{ book.local_path }}">{% include 'snippets/book_cover.html' with book=book size="small" %}</a>
</td>
<td>
<a href="{{ book.local_path }}">{{ book.title }}</a>
</td>
<td>
{{ book.authors.first.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 %}
{% if shelf.user == request.user %}
<td>
{% include 'snippets/shelf_selector.html' with current=shelf %}
</td>
{% endif %}
</tr>
{% endfor %}
</table>
</div>
{% else %}
<p>This shelf is empty.</p>
{% if shelf.editable %}
<form name="delete-shelf" action="/delete-shelf/{{ shelf.id }}" method="post">
{% csrf_token %}
<input type="hidden" name="user" value="{{ request.user.id }}">
<button class="button is-danger is-light" type="submit">
Delete shelf
</button>
</form>
{% endif %}
{% endif %}