From 73e38f9050af0bf7c1f63a233add9ec4fe67f316 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Wed, 24 Mar 2021 10:07:39 -0700 Subject: [PATCH] Fixes formatting rating value in template --- .../generated_status/review_pure_name.html | 2 +- bookwyrm/tests/models/test_status_model.py | 25 ++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/bookwyrm/templates/snippets/generated_status/review_pure_name.html b/bookwyrm/templates/snippets/generated_status/review_pure_name.html index f58643840..a8d3fa5b8 100644 --- a/bookwyrm/templates/snippets/generated_status/review_pure_name.html +++ b/bookwyrm/templates/snippets/generated_status/review_pure_name.html @@ -1,7 +1,7 @@ {% load i18n %} {% if rating %} -{% blocktrans with book_title=book.title rating=rating|floatformat:"0" review_title=name count counter=rating %}Review of {{ book_title }} ({{ rating }} star): {{ review_title }}{% plural %}Review of {{ book_title }} ({{ rating }} stars): {{ review_title }}{% endblocktrans %} +{% blocktrans with book_title=book.title display_rating=rating|floatformat:"0" review_title=name count counter=rating %}Review of {{ book_title }} ({{ display_rating }} star): {{ review_title }}{% plural %}Review of {{ book_title }} ({{ display_rating }} stars): {{ review_title }}{% endblocktrans %} {% else %} diff --git a/bookwyrm/tests/models/test_status_model.py b/bookwyrm/tests/models/test_status_model.py index 54fe7fee9..05cd2f000 100644 --- a/bookwyrm/tests/models/test_status_model.py +++ b/bookwyrm/tests/models/test_status_model.py @@ -277,7 +277,30 @@ class Status(TestCase): self.assertEqual(activity["id"], status.remote_id) self.assertEqual(activity["type"], "Article") self.assertEqual( - activity["name"], 'Review of "%s" (3 stars): Review name' % self.book.title + activity["name"], + "Review of %s (3 stars): Review name" % self.book.title, + ) + self.assertEqual(activity["content"], "test content") + self.assertEqual(activity["attachment"][0].type, "Document") + self.assertEqual( + activity["attachment"][0].url, + "https://%s%s" % (settings.DOMAIN, self.book.cover.url), + ) + self.assertEqual(activity["attachment"][0].name, "Test Edition") + + def test_review_to_pure_activity_no_rating(self, *_): + """ subclass of the base model version with a "pure" serializer """ + status = models.Review.objects.create( + name="Review name", + content="test content", + user=self.local_user, + book=self.book, + ) + activity = status.to_activity(pure=True) + self.assertEqual(activity["id"], status.remote_id) + self.assertEqual(activity["type"], "Article") + self.assertEqual( + activity["name"], "Review of %s: Review name" % self.book.title ) self.assertEqual(activity["content"], "test content") self.assertEqual(activity["attachment"][0].type, "Document")