diff --git a/bookwyrm/templates/book/edition_filters.html b/bookwyrm/templates/book/edition_filters.html new file mode 100644 index 00000000..a55b72af --- /dev/null +++ b/bookwyrm/templates/book/edition_filters.html @@ -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 %} diff --git a/bookwyrm/templates/book/editions.html b/bookwyrm/templates/book/editions.html index b77dc1a6..7290cce9 100644 --- a/bookwyrm/templates/book/editions.html +++ b/bookwyrm/templates/book/editions.html @@ -7,7 +7,11 @@ {% block content %}

{% blocktrans with work_path=work.local_path work_title=work.title %}Editions of "{{ work_title }}"{% endblocktrans %}

+
+{% include 'book/edition_filters.html' %} + +
{% for book in editions %}
@@ -30,4 +34,3 @@ {% endfor %}
{% endblock %} - diff --git a/bookwyrm/templates/book/format_filter.html b/bookwyrm/templates/book/format_filter.html new file mode 100644 index 00000000..7bd8f6c7 --- /dev/null +++ b/bookwyrm/templates/book/format_filter.html @@ -0,0 +1,13 @@ +{% extends 'snippets/filters_panel/filter_field.html' %} +{% load i18n %} + +{% block filter %} + +
+ +
+{% endblock %} diff --git a/bookwyrm/templates/book/language_filter.html b/bookwyrm/templates/book/language_filter.html new file mode 100644 index 00000000..fc21d5e2 --- /dev/null +++ b/bookwyrm/templates/book/language_filter.html @@ -0,0 +1,13 @@ +{% extends 'snippets/filters_panel/filter_field.html' %} +{% load i18n %} + +{% block filter %} + +
+ +
+{% endblock %} diff --git a/bookwyrm/views/books.py b/bookwyrm/views/books.py index 5c8eab4c..6d10e131 100644 --- a/bookwyrm/views/books.py +++ b/bookwyrm/views/books.py @@ -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)