mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-26 19:41:11 +00:00
Merge pull request #1095 from bookwyrm-social/display-fixes
Display fixes
This commit is contained in:
commit
0bddad259b
8 changed files with 50 additions and 43 deletions
|
@ -194,7 +194,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="block" id="reviews">
|
<div class="block" id="reviews">
|
||||||
{% if request.user.is_authenticated %}
|
{% if request.user.is_authenticated %}
|
||||||
{% if user_statuses.review_count or user_statuses.comment_count or user_stuatses.quotation_count %}
|
{% if user_statuses.review_count or user_statuses.comment_count or user_statuses.quotation_count %}
|
||||||
<nav class="tabs">
|
<nav class="tabs">
|
||||||
<ul>
|
<ul>
|
||||||
{% url 'book' book.id as tab_url %}
|
{% url 'book' book.id as tab_url %}
|
||||||
|
@ -224,46 +224,26 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% for review in statuses %}
|
{% for status in statuses %}
|
||||||
<div
|
<div
|
||||||
class="block"
|
class="block"
|
||||||
|
{% if status.status_type == 'Review' or status.status_type == 'Rating' %}
|
||||||
itemprop="review"
|
itemprop="review"
|
||||||
itemscope
|
itemscope
|
||||||
itemtype="https://schema.org/Review"
|
itemtype="https://schema.org/Review"
|
||||||
|
{% endif %}
|
||||||
>
|
>
|
||||||
{% with status=review hide_book=True depth=1 %}
|
{% include 'snippets/status/status.html' with status=status hide_book=True depth=1 %}
|
||||||
{% include 'snippets/status/status.html' %}
|
|
||||||
{% endwith %}
|
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
{% if ratings %}
|
||||||
<div class="block is-flex is-flex-wrap-wrap">
|
<div class="block is-flex is-flex-wrap-wrap">
|
||||||
{% for rating in ratings %}
|
{% for rating in ratings %}
|
||||||
{% with user=rating.user %}
|
{% include 'book/rating.html' with user=rating.user rating=rating %}
|
||||||
<div class="block mr-5">
|
|
||||||
<div class="media">
|
|
||||||
<div class="media-left">
|
|
||||||
{% include 'snippets/avatar.html' %}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="media-content">
|
|
||||||
<div>
|
|
||||||
<a href="{{ user.local_path }}">{{ user.display_name }}</a>
|
|
||||||
</div>
|
|
||||||
<div class="is-flex">
|
|
||||||
<p class="mr-1">{% trans "rated it" %}</p>
|
|
||||||
|
|
||||||
{% include 'snippets/stars.html' with rating=rating.rating %}
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<a href="{{ rating.remote_id }}">{{ rating.published_date|naturaltime }}</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endwith %}
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
<div class="block">
|
<div class="block">
|
||||||
{% include 'snippets/pagination.html' with page=statuses path=request.path anchor="#reviews" %}
|
{% include 'snippets/pagination.html' with page=statuses path=request.path anchor="#reviews" %}
|
||||||
</div>
|
</div>
|
||||||
|
|
22
bookwyrm/templates/book/rating.html
Normal file
22
bookwyrm/templates/book/rating.html
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
{% load i18n %}{% load status_display %}
|
||||||
|
<div class="block mr-5">
|
||||||
|
<div class="media">
|
||||||
|
<div class="media-left">
|
||||||
|
{% include 'snippets/avatar.html' with user=user %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="media-content">
|
||||||
|
<div>
|
||||||
|
<a href="{{ user.local_path }}">{{ user.display_name }}</a>
|
||||||
|
</div>
|
||||||
|
<div class="is-flex">
|
||||||
|
<p class="mr-1">{% trans "rated it" %}</p>
|
||||||
|
|
||||||
|
{% include 'snippets/stars.html' with rating=rating.rating %}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<a href="{{ rating.remote_id }}">{{ rating.published_date|published_date }}</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -51,9 +51,9 @@
|
||||||
<p>
|
<p>
|
||||||
{% include 'snippets/stars.html' with rating=item.book|rating:request.user %}
|
{% include 'snippets/stars.html' with rating=item.book|rating:request.user %}
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<div>
|
||||||
{{ book|book_description|to_markdown|default:""|safe|truncatewords_html:20 }}
|
{{ book|book_description|to_markdown|default:""|safe|truncatewords_html:20 }}
|
||||||
</p>
|
</div>
|
||||||
{% include 'snippets/shelve_button/shelve_button.html' %}
|
{% include 'snippets/shelve_button/shelve_button.html' %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
|
|
||||||
<div class="card-content is-flex-grow-0">
|
<div class="card-content is-flex-grow-0">
|
||||||
<div {% if list.description %}title="{{ list.description }}"{% endif %}>
|
<div class="is-clipped" {% if list.description %}title="{{ list.description }}"{% endif %}>
|
||||||
{% if list.description %}
|
{% if list.description %}
|
||||||
{{ list.description|to_markdown|safe|truncatechars_html:30 }}
|
{{ list.description|to_markdown|safe|truncatechars_html:30 }}
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
|
@ -38,6 +38,9 @@
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="column">
|
||||||
<div class="box has-background-primary-light">
|
<div class="box has-background-primary-light">
|
||||||
{% if site.allow_registration %}
|
{% if site.allow_registration %}
|
||||||
<h2 class="title">{% trans "Create an Account" %}</h2>
|
<h2 class="title">{% trans "Create an Account" %}</h2>
|
||||||
|
@ -50,15 +53,15 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="column">
|
<div class="block">
|
||||||
<div class="block">
|
<div class="box">
|
||||||
{% include 'snippets/about.html' %}
|
{% include 'snippets/about.html' %}
|
||||||
|
|
||||||
<p class="block">
|
<p class="block">
|
||||||
<a href="{% url 'about' %}">{% trans "More about this site" %}</a>
|
<a href="{% url 'about' %}">{% trans "More about this site" %}</a>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
{% with results|first as local_results %}
|
{% with results|first as local_results %}
|
||||||
<ul class="block">
|
<ul class="block">
|
||||||
{% for result in local_results.results %}
|
{% for result in local_results.results %}
|
||||||
<li class="pd-4">
|
<li class="pd-4 mb-5">
|
||||||
{% include 'snippets/search_result_text.html' with result=result %}
|
{% include 'snippets/search_result_text.html' with result=result %}
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
@ -59,7 +59,6 @@ class BookViews(TestCase):
|
||||||
result.render()
|
result.render()
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
|
|
||||||
request = self.factory.get("")
|
|
||||||
with patch("bookwyrm.views.books.is_api_request") as is_api:
|
with patch("bookwyrm.views.books.is_api_request") as is_api:
|
||||||
is_api.return_value = True
|
is_api.return_value = True
|
||||||
result = view(request, self.book.id)
|
result = view(request, self.book.id)
|
||||||
|
|
|
@ -30,6 +30,7 @@ class Book(View):
|
||||||
|
|
||||||
def get(self, request, book_id, user_statuses=False):
|
def get(self, request, book_id, user_statuses=False):
|
||||||
"""info about a book"""
|
"""info about a book"""
|
||||||
|
user_statuses = user_statuses if request.user.is_authenticated else False
|
||||||
try:
|
try:
|
||||||
book = models.Book.objects.select_subclasses().get(id=book_id)
|
book = models.Book.objects.select_subclasses().get(id=book_id)
|
||||||
except models.Book.DoesNotExist:
|
except models.Book.DoesNotExist:
|
||||||
|
@ -51,9 +52,9 @@ class Book(View):
|
||||||
)
|
)
|
||||||
|
|
||||||
# the reviews to show
|
# the reviews to show
|
||||||
if user_statuses and request.user.is_authenticated:
|
if user_statuses:
|
||||||
if user_statuses == "review":
|
if user_statuses == "review":
|
||||||
queryset = book.review_set
|
queryset = book.review_set.select_subclasses()
|
||||||
elif user_statuses == "comment":
|
elif user_statuses == "comment":
|
||||||
queryset = book.comment_set
|
queryset = book.comment_set
|
||||||
else:
|
else:
|
||||||
|
@ -67,7 +68,9 @@ class Book(View):
|
||||||
"book": book,
|
"book": book,
|
||||||
"statuses": paginated.get_page(request.GET.get("page")),
|
"statuses": paginated.get_page(request.GET.get("page")),
|
||||||
"review_count": reviews.count(),
|
"review_count": reviews.count(),
|
||||||
"ratings": reviews.filter(Q(content__isnull=True) | Q(content="")),
|
"ratings": reviews.filter(Q(content__isnull=True) | Q(content=""))
|
||||||
|
if not user_statuses
|
||||||
|
else None,
|
||||||
"rating": reviews.aggregate(Avg("rating"))["rating__avg"],
|
"rating": reviews.aggregate(Avg("rating"))["rating__avg"],
|
||||||
"lists": privacy_filter(
|
"lists": privacy_filter(
|
||||||
request.user, book.list_set.filter(listitem__approved=True)
|
request.user, book.list_set.filter(listitem__approved=True)
|
||||||
|
|
Loading…
Reference in a new issue