Fixes formatting rating value in template

This commit is contained in:
Mouse Reeve 2021-03-24 10:07:39 -07:00
parent 8b9528ae95
commit e3350e58d0
2 changed files with 25 additions and 2 deletions

View file

@ -1,7 +1,7 @@
{% load i18n %} {% load i18n %}
{% if rating %} {% if rating %}
{% blocktrans with book_title=book.title rating=rating|floatformat:"0" review_title=name count counter=rating %}Review of <em>{{ book_title }}</em> ({{ rating }} star): {{ review_title }}{% plural %}Review of <em>{{ book_title }}</em> ({{ rating }} stars): {{ review_title }}{% endblocktrans %} {% blocktrans with book_title=book.title display_rating=rating|floatformat:"0" review_title=name count counter=rating %}Review of <em>{{ book_title }}</em> ({{ display_rating }} star): {{ review_title }}{% plural %}Review of <em>{{ book_title }}</em> ({{ display_rating }} stars): {{ review_title }}{% endblocktrans %}
{% else %} {% else %}

View file

@ -275,7 +275,30 @@ class Status(TestCase):
self.assertEqual(activity["id"], status.remote_id) self.assertEqual(activity["id"], status.remote_id)
self.assertEqual(activity["type"], "Article") self.assertEqual(activity["type"], "Article")
self.assertEqual( self.assertEqual(
activity["name"], 'Review of "%s" (3 stars): Review name' % self.book.title activity["name"],
"Review of <em>%s</em> (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 <em>%s</em>: Review name" % self.book.title
) )
self.assertEqual(activity["content"], "test content") self.assertEqual(activity["content"], "test content")
self.assertEqual(activity["attachment"][0].type, "Document") self.assertEqual(activity["attachment"][0].type, "Document")