Adds filters ui to editions page

This commit is contained in:
Mouse Reeve 2021-03-29 10:58:35 -07:00
parent b13e8d75cd
commit 769ba6466c
5 changed files with 41 additions and 2 deletions

View file

@ -0,0 +1,6 @@
{% extends 'snippets/filters_panel/filters_panel.html' %}
{% block filter_fields %}
{% include 'book/language_filter.html' %}
{% include 'book/format_filter.html' %}
{% endblock %}

View file

@ -7,7 +7,11 @@
{% block content %}
<div class="block">
<h1 class="title">{% blocktrans with work_path=work.local_path work_title=work.title %}Editions of <a href="{{ work_path }}">"{{ work_title }}"</a>{% endblocktrans %}</h1>
</div>
{% include 'book/edition_filters.html' %}
<div class="block">
{% for book in editions %}
<div class="columns">
<div class="column is-2">
@ -30,4 +34,3 @@
{% endfor %}
</div>
{% endblock %}

View file

@ -0,0 +1,13 @@
{% extends 'snippets/filters_panel/filter_field.html' %}
{% load i18n %}
{% block filter %}
<label class="label is-block" for="id_format">{% trans "Format:" %}</label>
<div class="select">
<select id="format" name="format">
{% for format in formats %}{% if format %}
<option value="{{ format }}">{{ format|title }}</option>
{% endif %}{% endfor %}
</select>
</div>
{% endblock %}

View file

@ -0,0 +1,13 @@
{% extends 'snippets/filters_panel/filter_field.html' %}
{% load i18n %}
{% block filter %}
<label class="label is-block" for="id_language">{% trans "Language:" %}</label>
<div class="select">
<select id="language" name="language">
{% for language in languages %}
<option value="{{ language }}">{{ language }}</option>
{% endfor %}
</select>
</div>
{% endblock %}

View file

@ -252,10 +252,14 @@ class Editions(View):
if is_api_request(request):
return ActivitypubResponse(work.to_edition_list(**request.GET))
editions = work.editions.order_by("-edition_rank").all()
languages = set(sum([e.languages for e in editions], []))
data = {
"editions": work.editions.order_by("-edition_rank").all(),
"editions": editions,
"work": work,
"languages": languages,
"formats": set(e.physical_format.lower() for e in editions),
}
return TemplateResponse(request, "book/editions.html", data)