-
{{ author.data.name }}
- {% if author.data.bio %} -{{ author.data.bio | author_bio }} +{{ author.name }}
+ {% if author.bio %} +{{ author.bio | author_bio }}{% endif %} {% for book in books %} diff --git a/fedireads/templates/book.html b/fedireads/templates/book.html index 60c67921..73e3c12d 100644 --- a/fedireads/templates/book.html +++ b/fedireads/templates/book.html @@ -3,7 +3,7 @@ {% block content %}-+
{{ book.data.title }}and You
{{ book.title }}and You{% if shelf %}On shelf
{% include 'snippets/shelve-button.html' with book=book pulldown=True %} @@ -27,13 +27,15 @@{{ shelf.name }}{% endif %}-
{{ book.data.title }}by ++ {% if book.parent_work %}
{{ book.title }}by {% include 'snippets/authors.html' with book=book %}Edition of {{ book.parent_work.title }}
{% endif %}+ {% include 'snippets/book_cover.html' with book=book size=large %}{{ active_tab }} rating: {{ rating | stars }}
{% if description %} -{{ book.data.description | description }}+{{ book.description | description }}{% endif %}diff --git a/fedireads/templates/snippets/authors.html b/fedireads/templates/snippets/authors.html index bc392089..1d619153 100644 --- a/fedireads/templates/snippets/authors.html +++ b/fedireads/templates/snippets/authors.html @@ -1 +1 @@ -by {{ book.authors.first.data.name }} +{{ book.authors.first.name }} diff --git a/fedireads/templates/snippets/book.html b/fedireads/templates/snippets/book.html index d25b36c8..2b28e76d 100644 --- a/fedireads/templates/snippets/book.html +++ b/fedireads/templates/snippets/book.html @@ -1,10 +1,10 @@ {% load fr_display %} {% include 'snippets/book_cover.html' with book=book %}- {{ book.data.title }} + {{ book.title }}
- {% include 'snippets/authors.html' with book=book %} + by {% include 'snippets/authors.html' with book=book %}
{% if rating %} @@ -12,7 +12,7 @@ {% endif %} {% if description %} -{{ book.data.description | description }}+{{ book.description | description }}{% endif %} {% include 'snippets/shelve-button.html' with book=book pulldown=shelf_pulldown %} diff --git a/fedireads/templates/snippets/shelf.html b/fedireads/templates/snippets/shelf.html index 651a4808..18794d0e 100644 --- a/fedireads/templates/snippets/shelf.html +++ b/fedireads/templates/snippets/shelf.html @@ -33,19 +33,19 @@ {% include 'snippets/book_cover.html' with book=book %}- {{ book.data.title }} + {{ book.title }} {{ book.authors.first.data.name }} - {{ book.data.first_publish_date }} + {{ book.first_publish_date }} {{ book.added_date | naturalday }} - OpenLibrary + OpenLibrary {% if ratings %}diff --git a/fedireads/templates/snippets/status.html b/fedireads/templates/snippets/status.html index 04942d1f..fa58fee4 100644 --- a/fedireads/templates/snippets/status.html +++ b/fedireads/templates/snippets/status.html @@ -1,7 +1,7 @@ {% load fr_display %} {% if activity.status_type == 'Review' %} - {% include 'snippets/status_banner.html' with content="reviewed "|add:activity.book.data.title|add:"" %} + {% include 'snippets/status_banner.html' with content="reviewed "|add:activity.book.title|add:"" %}{% include 'snippets/book.html' with book=activity.book size=large %} diff --git a/fedireads/templatetags/fr_display.py b/fedireads/templatetags/fr_display.py index 41d5591d..2f5b5ac6 100644 --- a/fedireads/templatetags/fr_display.py +++ b/fedireads/templatetags/fr_display.py @@ -11,6 +11,7 @@ def dict_key(d, k): '''Returns the given key from a dictionary.''' return d.get(k) or 0 + @register.filter(name='stars') def stars(number): ''' turn integers into stars ''' @@ -20,16 +21,19 @@ def stars(number): number = 0 return ('★' * number) + '☆' * (5 - number) + @register.filter(name='description') def description_format(description): ''' handle the various OL description formats ''' - if isinstance(description, dict) and 'value' in description: - description = description['value'] + if not description: + return '' + if '----------' in description: description = description.split('----------')[0] return description.strip() + @register.filter(name='author_bio') def bio_format(bio): ''' clean up OL author bios ''' diff --git a/fedireads/utils/models.py b/fedireads/utils/models.py index dfb491e2..93821ca1 100644 --- a/fedireads/utils/models.py +++ b/fedireads/utils/models.py @@ -1,3 +1,4 @@ +''' base model with default fields ''' from django.db import models from fedireads.settings import DOMAIN diff --git a/fedireads/views.py b/fedireads/views.py index 3dab26d7..ee293aad 100644 --- a/fedireads/views.py +++ b/fedireads/views.py @@ -190,26 +190,33 @@ def book_page(request, book_identifier, tab='friends'): ''' info about a book ''' book = openlibrary.get_or_create_book(book_identifier) - user_reviews = models.Review.objects.filter(user=request.user, book=book).all() + if isinstance(book, models.Work): + book_reviews = models.Review.objects.filter( + Q(book=book) | Q(book__parent_work=book), + ) + else: + book_reviews = models.Review.objects.filter(book=book) + + user_reviews = book_reviews.filter( + user=request.user, + ).all() if tab == 'friends': - reviews = models.Review.objects.filter( + reviews = book_reviews.filter( Q(user__followers=request.user, privacy='public') | \ + Q(user=request.user) | \ Q(mention_users=request.user), - book=book, ) elif tab == 'local': - reviews = models.Review.objects.filter( + reviews = book_reviews.filter( Q(privacy='public') | \ Q(mention_users=request.user), user__local=True, - book=book, ) else: - reviews = models.Review.objects.filter( + reviews = book_reviews.filter( Q(privacy='public') | \ Q(mention_users=request.user), - book=book, ) try: