mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 11:31:08 +00:00
Only show editions with the author on the author page
This commit is contained in:
parent
43202f5bb7
commit
553f170f89
3 changed files with 12 additions and 1 deletions
|
@ -241,6 +241,10 @@ class Work(OrderedCollectionPageMixin, Book):
|
|||
"""in case the default edition is not set"""
|
||||
return self.editions.order_by("-edition_rank").first()
|
||||
|
||||
def author_edition(self, author):
|
||||
"""in case the default edition doesn't have the required author"""
|
||||
return self.editions.filter(authors=author).order_by("-edition_rank").first()
|
||||
|
||||
def to_edition_list(self, **kwargs):
|
||||
"""an ordered collection of editions"""
|
||||
return self.to_ordered_collection(
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
{% load markdown %}
|
||||
{% load humanize %}
|
||||
{% load utilities %}
|
||||
{% load book_display_tags %}
|
||||
|
||||
{% block title %}{{ author.name }}{% endblock %}
|
||||
|
||||
|
@ -141,7 +142,7 @@
|
|||
<h2 class="title is-4">{% blocktrans with name=author.name %}Books by {{ name }}{% endblocktrans %}</h2>
|
||||
<div class="columns is-multiline is-mobile">
|
||||
{% for book in books %}
|
||||
{% with book=book.default_edition %}
|
||||
{% with book=book|author_edition:author %}
|
||||
<div class="column is-one-fifth-tablet is-half-mobile is-flex is-flex-direction-column">
|
||||
<div class="is-flex-grow-1">
|
||||
{% include 'landing/small-book.html' with book=book %}
|
||||
|
|
|
@ -20,3 +20,9 @@ def get_book_description(book):
|
|||
def get_book_file_links(book):
|
||||
"""links for a book"""
|
||||
return book.file_links.filter(domain__status="approved")
|
||||
|
||||
|
||||
@register.filter(name="author_edition")
|
||||
def get_author_edition(book, author):
|
||||
"""default edition for a book on the author page"""
|
||||
return book.author_edition(author)
|
||||
|
|
Loading…
Reference in a new issue