moviewyrm/bookwyrm/templates/lists/list.html

173 lines
8.2 KiB
HTML
Raw Normal View History

2021-01-31 20:07:54 +00:00
{% extends 'lists/list_layout.html' %}
2021-02-28 02:48:10 +00:00
{% load i18n %}
2021-01-31 18:34:25 +00:00
{% load bookwyrm_tags %}
2021-01-31 05:33:41 +00:00
{% block panel %}
2021-01-31 20:07:54 +00:00
{% if request.user == list.user and pending_count %}
2021-01-31 20:30:33 +00:00
<div class="block content">
2021-01-31 20:07:54 +00:00
<p>
<a href="{% url 'list-curate' list.id %}">{{ pending_count }} book{{ pending_count | pluralize }} awaiting your approval</a>
</p>
2021-01-31 19:45:16 +00:00
</div>
{% endif %}
2021-01-31 18:34:25 +00:00
2021-01-31 20:30:33 +00:00
<div class="columns mt-3">
2021-01-31 18:34:25 +00:00
<section class="column is-three-quarters">
{% if request.GET.updated %}
<div class="notification is-primary">
{% if list.curation != "open" and request.user != list.user %}
{% trans "You successfully suggested a book for this list!" %}
{% else %}
{% trans "You successfully added a book to this list!" %}
{% endif %}
</div>
{% endif %}
2021-04-08 16:05:21 +00:00
{% if not items.object_list.exists %}
2021-02-28 02:48:10 +00:00
<p>{% trans "This list is currently empty" %}</p>
2021-01-31 17:08:06 +00:00
{% else %}
2021-04-08 16:05:21 +00:00
<ol start="{{ items.start_index }}">
2021-01-31 19:21:50 +00:00
{% for item in items %}
<li class="block mb-5">
2021-01-31 18:34:25 +00:00
<div class="card">
{% with book=item.book %}
<div
class="
card-content p-0 mb-0
columns is-mobile is-gapless
"
>
2021-04-28 08:47:14 +00:00
<div class="column is-2-mobile is-cover align to-t">
<a href="{{ item.book.local_path }}" aria-hidden="true">
2021-04-28 08:47:14 +00:00
{% include 'snippets/book_cover.html' with cover_class='is-w-auto is-h-m-tablet' %}
</a>
</div>
<div class="column ml-3">
2021-04-30 20:21:19 +00:00
<p>
{% include 'snippets/book_titleby.html' %}
</p>
<p>
{% include 'snippets/stars.html' with rating=item.book|rating:request.user %}
</p>
<p>
{{ book|book_description|to_markdown|default:""|safe|truncatewords_html:20 }}
</p>
{% include 'snippets/shelve_button/shelve_button.html' %}
</div>
2021-01-31 18:34:25 +00:00
</div>
{% endwith %}
2021-04-20 20:02:43 +00:00
<div class="card-footer has-background-white-bis is-align-items-baseline">
2021-01-31 18:34:25 +00:00
<div class="card-footer-item">
2021-04-20 20:02:43 +00:00
<div>
2021-03-02 17:25:45 +00:00
<p>{% blocktrans with username=item.user.display_name user_path=user.local_path %}Added by <a href="{{ user_path }}">{{ username }}</a>{% endblocktrans %}</p>
2021-04-20 20:02:43 +00:00
</div>
2021-01-31 18:34:25 +00:00
</div>
{% if list.user == request.user or list.curation == 'open' and item.user == request.user %}
2021-04-20 20:02:43 +00:00
<div class="card-footer-item">
<form name="set-position" method="post" action="{% url 'list-set-book-position' item.id %}">
<div class="field has-addons mb-0">
{% csrf_token %}
<div class="control">
<input id="input-list-position" class="input is-small" type="number" min="1" name="position" value="{{ item.order }}">
</div>
<div class="control">
<button type="submit" class="button is-info is-small is-tablet">{% trans "Set" %}</button>
</div>
</div>
<label for="input-list-position" class="help">{% trans "List position" %}</label>
</form>
</div>
2021-01-31 20:15:38 +00:00
<form name="add-book" method="post" action="{% url 'list-remove-book' list.id %}" class="card-footer-item">
2021-01-31 18:34:25 +00:00
{% csrf_token %}
2021-01-31 20:15:38 +00:00
<input type="hidden" name="item" value="{{ item.id }}">
2021-02-28 02:48:10 +00:00
<button type="submit" class="button is-small is-danger">{% trans "Remove" %}</button>
2021-01-31 18:34:25 +00:00
</form>
{% endif %}
2021-01-31 18:34:25 +00:00
</div>
</div>
</li>
2021-01-31 17:08:06 +00:00
{% endfor %}
2021-01-31 18:34:25 +00:00
</ol>
2021-01-31 17:08:06 +00:00
{% endif %}
{% include "snippets/pagination.html" with page=items %}
2021-01-31 17:08:06 +00:00
</section>
<section class="column is-one-quarter">
2021-04-08 16:05:21 +00:00
<h2>{% trans "Sort List" %}</h2>
<form name="sort" action="{% url 'list' list.id %}" method="GET" class="block">
<label class="label" for="id_sort_by">{% trans "Sort By" %}</label>
<div class="select is-fullwidth">
{{ sort_form.sort_by }}
</div>
<label class="label" for="id_direction">{% trans "Direction" %}</label>
<div class="select is-fullwidth">
{{ sort_form.direction }}
</div>
<div>
<button class="button is-primary is-fullwidth" type="submit">
{% trans "Sort List" %}
</button>
</div>
</form>
{% if request.user.is_authenticated and not list.curation == 'closed' or request.user == list.user %}
2021-02-28 02:48:10 +00:00
<h2>{% if list.curation == 'open' or request.user == list.user %}{% trans "Add Books" %}{% else %}{% trans "Suggest Books" %}{% endif %}</h2>
2021-01-31 19:11:26 +00:00
<form name="search" action="{% url 'list' list.id %}" method="GET" class="block">
<div class="field has-addons">
<div class="control">
2021-02-28 02:48:10 +00:00
<input aria-label="{% trans 'Search for a book' %}" class="input" type="text" name="q" placeholder="{% trans 'Search for a book' %}" value="{{ query }}">
2021-01-31 19:11:26 +00:00
</div>
<div class="control">
<button class="button" type="submit">
2021-02-28 02:48:10 +00:00
<span class="icon icon-search" title="{% trans 'Search' %}">
<span class="is-sr-only">{% trans "search" %}</span>
2021-01-31 19:11:26 +00:00
</span>
</button>
</div>
</div>
{% if query %}
2021-02-28 02:48:10 +00:00
<p class="help"><a href="{% url 'list' list.id %}">{% trans "Clear search" %}</a></p>
2021-01-31 19:11:26 +00:00
{% endif %}
</form>
2021-01-31 19:13:05 +00:00
{% if not suggested_books %}
2021-02-28 02:48:10 +00:00
{% if query %}
<p>{% blocktrans %}No books found matching the query "{{ query }}"{% endblocktrans %}</p>{% else %}
<p>{% trans "No books found" %}</p>
{% endif %}
2021-01-31 19:13:05 +00:00
{% endif %}
{% if suggested_books|length > 0 %}
{% for book in suggested_books %}
<div class="columns is-mobile is-gapless">
<a
2021-04-28 08:47:14 +00:00
class="column is-2-mobile is-3-tablet is-cover align to-c"
href="{{ book.local_path }}"
aria-hidden="true"
>
2021-04-28 08:47:14 +00:00
{% include 'snippets/book_cover.html' with book=book cover_class='is-w-auto is-h-s-mobile align to-t' %}
</a>
<div class="column ml-3">
<p>{% include 'snippets/book_titleby.html' with book=book %}</p>
<form
class="mt-1"
name="add-book"
method="post"
action="{% url 'list-add-book' %}{% if query %}?q={{ query }}{% endif %}"
>
{% csrf_token %}
<input type="hidden" name="book" value="{{ book.id }}">
<input type="hidden" name="list" value="{{ list.id }}">
<button type="submit" class="button is-small is-link">{% if list.curation == 'open' or request.user == list.user %}{% trans "Add" %}{% else %}{% trans "Suggest" %}{% endif %}</button>
</form>
</div>
</div>
{% endfor %}
{% endif %}
2021-01-31 18:34:25 +00:00
{% endif %}
2021-04-08 16:05:21 +00:00
</section>
2021-01-31 17:08:06 +00:00
</div>
2021-01-31 05:33:41 +00:00
{% endblock %}