diff --git a/bookwyrm/models/fields.py b/bookwyrm/models/fields.py index a5985e8de..e034d59ee 100644 --- a/bookwyrm/models/fields.py +++ b/bookwyrm/models/fields.py @@ -450,4 +450,6 @@ class DecimalField(ActivitypubFieldMixin, models.DecimalField): """ activitypub-aware boolean field """ def field_to_activity(self, value): + if not value: + return None return float(value) diff --git a/bookwyrm/models/status.py b/bookwyrm/models/status.py index e655616fa..adc9d39d6 100644 --- a/bookwyrm/models/status.py +++ b/bookwyrm/models/status.py @@ -306,7 +306,7 @@ class Review(Status): """ clarify review names for mastodon serialization """ template = get_template("snippets/generated_status/review_pure_name.html") return template.render( - {"book": self.book, "rating": int(self.rating), "name": self.name} + {"book": self.book, "rating": self.rating, "name": self.name} ).strip() @property @@ -329,7 +329,7 @@ class ReviewRating(Review): @property def pure_content(self): template = get_template("snippets/generated_status/rating.html") - return template.render({"book": self.book, "rating": int(self.rating)}).strip() + return template.render({"book": self.book, "rating": self.rating}).strip() activity_serializer = activitypub.Rating pure_type = "Note" diff --git a/bookwyrm/templates/snippets/generated_status/rating.html b/bookwyrm/templates/snippets/generated_status/rating.html index 13afd94de..c23d0eb8c 100644 --- a/bookwyrm/templates/snippets/generated_status/rating.html +++ b/bookwyrm/templates/snippets/generated_status/rating.html @@ -1,3 +1,3 @@ {% load i18n %}{% load humanize %} -{% blocktrans with title=book.title path=book.remote_id rating=rating count counter=rating %}Rated {{ title }}: {{ rating }} star{% plural %}Rated {{ title }}: {{ rating }} stars{% endblocktrans %} +{% blocktrans with title=book.title path=book.remote_id rating=rating|floatformat:"0" count counter=rating %}Rated {{ title }}: {{ rating }} star{% plural %}Rated {{ title }}: {{ rating }} stars{% endblocktrans %} diff --git a/bookwyrm/templates/snippets/generated_status/review_pure_name.html b/bookwyrm/templates/snippets/generated_status/review_pure_name.html index 3c133678b..f58643840 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 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 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 %} {% else %}