bookwyrm/bookwyrm/templatetags/book_display_tags.py
2022-08-07 13:26:05 -07:00

23 lines
560 B
Python

""" template filters """
from django import template
register = template.Library()
@register.filter(name="book_description")
def get_book_description(book):
"""use the work's text if the book doesn't have it"""
if book.description:
return book.description
if book.parent_work:
# this shoud always be true
return book.parent_work.description
return None
@register.simple_tag(takes_context=False)
def get_book_file_links(book):
"""links for a book"""
return book.file_links.filter(domain__status="approved")