mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-06-26 00:40:41 +00:00
23 lines
560 B
Python
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")
|