From d1d743281a5ccf25ce0d903fb2eae01ba2b3231c Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 1 Mar 2022 10:28:51 -0800 Subject: [PATCH 1/2] Cleans up display of superlatives on about page --- bookwyrm/templates/about/about.html | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/bookwyrm/templates/about/about.html b/bookwyrm/templates/about/about.html index 553bfee1..f1ddd2f3 100644 --- a/bookwyrm/templates/about/about.html +++ b/bookwyrm/templates/about/about.html @@ -14,23 +14,25 @@ {% cache 604800 about_page %} {% get_book_superlatives as superlatives %} -
-

- {% blocktrans with site_name=site.name %}Welcome to {{ site_name }}!{% endblocktrans %} -

+
+
+

+ {% blocktrans with site_name=site.name %}Welcome to {{ site_name }}!{% endblocktrans %} +

-

- {% blocktrans trimmed with site_name=site.name %} - {{ site_name }} is part of BookWyrm, a network of independent, self-directed communities for readers. - While you can interact seamlessly with users anywhere in the BookWyrm network, this community is unique. - {% endblocktrans %} -

+

+ {% blocktrans trimmed with site_name=site.name %} + {{ site_name }} is part of BookWyrm, a network of independent, self-directed communities for readers. + While you can interact seamlessly with users anywhere in the BookWyrm network, this community is unique. + {% endblocktrans %} +

+
{% if superlatives.top_rated %} {% with book=superlatives.top_rated.default_edition rating=superlatives.top_rated.rating %}
-
+
{% include 'snippets/book_cover.html' with book=book cover_class='is-h-m' size='medium' aria='show' %} @@ -49,7 +51,7 @@ {% if superlatives.wanted %} {% with book=superlatives.wanted.default_edition %}
-
+
{% include 'snippets/book_cover.html' with book=book cover_class='is-h-m' size='medium' aria='show' %} @@ -68,7 +70,7 @@ {% if superlatives.controversial %} {% with book=superlatives.controversial.default_edition %}
-
+
{% include 'snippets/book_cover.html' with book=book cover_class='is-h-m' size='medium' aria='show' %} From 5d7e6b872a9cc576b03fbd42b6d6ebc6775e5963 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 1 Mar 2022 10:34:17 -0800 Subject: [PATCH 2/2] Fixes localizing query for superlatives --- bookwyrm/templatetags/landing_page_tags.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/bookwyrm/templatetags/landing_page_tags.py b/bookwyrm/templatetags/landing_page_tags.py index e7d94360..ea2512cc 100644 --- a/bookwyrm/templatetags/landing_page_tags.py +++ b/bookwyrm/templatetags/landing_page_tags.py @@ -16,11 +16,15 @@ def get_book_superlatives(): models.Work.objects.annotate( rating=Avg( "editions__review__rating", - filter=Q(editions__review__local=True, editions__review__deleted=False), + filter=Q( + editions__review__user__local=True, editions__review__deleted=False + ), ), rating_count=Count( "editions__review", - filter=Q(editions__review__local=True, editions__review__deleted=False), + filter=Q( + editions__review__user__local=True, editions__review__deleted=False + ), ), ) .annotate(weighted=F("rating") * F("rating_count") / total_ratings) @@ -33,11 +37,15 @@ def get_book_superlatives(): models.Work.objects.annotate( deviation=StdDev( "editions__review__rating", - filter=Q(editions__review__local=True, editions__review__deleted=False), + filter=Q( + editions__review__user__local=True, editions__review__deleted=False + ), ), rating_count=Count( "editions__review", - filter=Q(editions__review__local=True, editions__review__deleted=False), + filter=Q( + editions__review__user__local=True, editions__review__deleted=False + ), ), ) .annotate(weighted=F("deviation") * F("rating_count") / total_ratings)