moviewyrm/bookwyrm/templates/user/shelf/shelf.html

189 lines
7.2 KiB
HTML
Raw Normal View History

2021-08-17 17:57:32 +00:00
{% extends 'layout.html' %}
2020-12-13 02:25:04 +00:00
{% load bookwyrm_tags %}
2021-05-11 22:14:42 +00:00
{% load utilities %}
{% load humanize %}
{% load i18n %}
2020-11-10 21:39:37 +00:00
{% block title %}
{% include 'user/shelf/books_header.html' %}
{% endblock %}
2021-08-17 17:57:32 +00:00
{% block opengraph_images %}
{% include 'snippets/opengraph_images.html' with image=user.preview_image %}
{% endblock %}
{% block content %}
<header class="block">
2021-01-30 20:03:50 +00:00
<h1 class="title">
{% include 'user/shelf/books_header.html' %}
2021-01-30 20:03:50 +00:00
</h1>
</header>
2020-11-10 22:52:04 +00:00
<div class="block columns">
<div class="column">
<div class="tabs">
2020-11-10 22:52:04 +00:00
<ul>
2021-03-31 17:23:20 +00:00
<li class="{% if shelf.identifier == 'all' %}is-active{% endif %}">
<a href="{% url 'user-shelves' user|username %}"{% if shelf.identifier == 'all' %} aria-current="page"{% endif %}>
{% trans "All books" %}
</a>
2021-03-31 17:23:20 +00:00
</li>
{% for shelf_tab in shelves %}
<li class="{% if shelf_tab.identifier == shelf.identifier %}is-active{% endif %}">
<a
href="{{ shelf_tab.local_path }}"
{% if shelf_tab.identifier == shelf.identifier %} aria-current="page"{% endif %}
>
{% if shelf_tab.identifier == 'to-read' %}
{% trans "To Read" %}
{% elif shelf_tab.identifier == 'reading' %}
{% trans "Currently Reading" %}
{% elif shelf_tab.identifier == 'read' %}
{% trans "Read" %}
{% else %}
{{ shelf_tab.name }}
{% endif %}
</a>
2021-03-31 17:23:20 +00:00
</li>
{% endfor %}
2020-11-10 22:52:04 +00:00
</ul>
</div>
</div>
2020-11-10 21:39:37 +00:00
{% if is_self %}
<div class="column is-narrow">
{% trans "Create shelf" as button_text %}
{% include 'snippets/toggle/open_button.html' with text=button_text icon_with_text="plus" controls_text="create_shelf_form" focus="create_shelf_form_header" %}
2021-05-10 23:13:17 +00:00
<a class="button" href="{% url 'import' %}">{% trans "Import Books" %}</a>
2020-11-10 21:39:37 +00:00
</div>
{% endif %}
</div>
2021-02-03 20:36:20 +00:00
<div class="block">
{% include 'user/shelf/create_shelf_form.html' with controls_text='create_shelf_form' %}
</div>
2021-02-23 21:04:24 +00:00
<div class="block columns is-mobile">
2020-11-10 21:39:37 +00:00
<div class="column">
2020-11-11 00:18:48 +00:00
<h2 class="title is-3">
{{ shelf.name }}
<span class="subtitle">
{% include 'snippets/privacy-icons.html' with item=shelf %}
</span>
{% with count=books.paginator.count %}
{% if count %}
<p class="help">
{% blocktrans trimmed count counter=count with formatted_count=count|intcomma %}
{{ formatted_count }} book
{% plural %}
{{ formatted_count }} books
{% endblocktrans %}
{% if books.has_other_pages %}
{% blocktrans trimmed with start=books.start_index end=books.end_index %}
(showing {{ start }}-{{ end }})
{% endblocktrans %}
{% endif %}
</p>
{% endif %}
{% endwith %}
2020-11-11 00:18:48 +00:00
</h2>
2020-11-10 21:39:37 +00:00
</div>
{% if is_self and shelf.id %}
2020-11-10 21:39:37 +00:00
<div class="column is-narrow">
{% trans "Edit shelf" as button_text %}
{% include 'snippets/toggle/open_button.html' with text=button_text icon_with_text="pencil" controls_text="edit_shelf_form" focus="edit_shelf_form_header" %}
2020-11-10 21:39:37 +00:00
</div>
{% endif %}
</div>
2021-02-03 20:44:51 +00:00
<div class="block">
{% include 'user/shelf/edit_shelf_form.html' with controls_text="edit_shelf_form" %}
2020-11-11 04:11:21 +00:00
</div>
2020-09-29 21:11:55 +00:00
<div class="block">
2020-02-22 00:03:05 +00:00
<div>
{% if books|length > 0 %}
<table class="table is-striped is-fullwidth is-mobile">
<thead>
<tr>
<th>{% trans "Cover" %}</th>
<th>{% trans "Title" %}</th>
<th>{% trans "Author" %}</th>
<th>{% trans "Shelved" %}</th>
<th>{% trans "Started" %}</th>
<th>{% trans "Finished" %}</th>
2021-05-11 20:54:38 +00:00
{% if request.user.is_authenticated %}
<th>{% trans "Rating" %}</th>
{% endif %}
{% if shelf.user == request.user %}
<th aria-hidden="true"></th>
{% endif %}
</tr>
</thead>
<tbody>
{% for book in books %}
{% spaceless %}
<tr class="book-preview">
<td class="book-preview-top-row">
2021-05-24 14:18:05 +00:00
<a href="{{ book.local_path }}">{% include 'snippets/book_cover.html' with book=book cover_class='is-w-s-tablet is-h-s' size='small' %}</a>
</td>
<td data-title="{% trans "Title" %}">
<a href="{{ book.local_path }}">{{ book.title }}</a>
</td>
<td data-title="{% trans "Author" %}">
{% include 'snippets/authors.html' %}
</td>
<td data-title="{% trans "Shelved" %}">
{{ book.shelved_date|naturalday }}
</td>
{% latest_read_through book user as read_through %}
<td data-title="{% trans "Started" %}">
2021-05-11 22:14:42 +00:00
{{ read_through.start_date|naturalday|default_if_none:""}}
</td>
<td data-title="{% trans "Finished" %}">
2021-05-11 22:14:42 +00:00
{{ read_through.finish_date|naturalday|default_if_none:""}}
</td>
2021-05-11 20:54:38 +00:00
{% if request.user.is_authenticated %}
<td data-title="{% trans "Rating" %}">
2021-05-11 20:54:38 +00:00
{% include 'snippets/stars.html' with rating=book.rating %}
</td>
{% endif %}
{% if shelf.user == request.user %}
<td class="book-preview-top-row has-text-right">
{% with right=True %}
{% if not shelf.id %}
{% active_shelf book as current %}
{% include 'snippets/shelf_selector.html' with current=current.shelf class="is-small" %}
{% else %}
{% include 'snippets/shelf_selector.html' with current=shelf class="is-small" %}
{% endif %}
{% endwith %}
</td>
{% endif %}
</tr>
{% endspaceless %}
{% endfor %}
</tbody>
</table>
{% else %}
<p>{% trans "This shelf is empty." %}</p>
2021-03-31 17:23:20 +00:00
{% if shelf.id and 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">
{% trans "Delete shelf" %}
</button>
</form>
{% endif %}
{% endif %}
2020-02-22 00:03:05 +00:00
</div>
</div>
<div>
{% include 'snippets/pagination.html' with page=books path=request.path %}
</div>
2020-02-22 00:03:05 +00:00
{% endblock %}