Fixes decimaal formatting

This commit is contained in:
Mouse Reeve 2021-03-24 09:51:49 -07:00
parent a26bf2859b
commit 8b9528ae95
3 changed files with 16 additions and 1 deletions

View file

@ -448,3 +448,8 @@ class IntegerField(ActivitypubFieldMixin, models.IntegerField):
class DecimalField(ActivitypubFieldMixin, models.DecimalField):
""" activitypub-aware boolean field """
def field_to_activity(self, value):
if not value:
return None
return float(value)

View file

@ -1,3 +1,3 @@
{% load i18n %}{% load humanize %}
{% blocktrans with title=book.title path=book.remote_id rating=rating count counter=rating %}Rated <em><a href="{{ path }}">{{ title }}</a></em>: {{ rating }} star{% plural %}Rated <em><a href="{{ path }}">{{ title }}</a></em>: {{ rating }} stars{% endblocktrans %}
{% blocktrans with title=book.title path=book.remote_id rating=rating|floatformat:"0" count counter=rating %}Rated <em><a href="{{ path }}">{{ title }}</a></em>: {{ rating }} star{% plural %}Rated <em><a href="{{ path }}">{{ title }}</a></em>: {{ rating }} stars{% endblocktrans %}

View file

@ -0,0 +1,10 @@
{% load i18n %}
{% 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 %}
{% else %}
{% blocktrans with book_title=book.title review_title=name %}Review of <em>{{ book_title }}</em>: {{ review_title }}{% endblocktrans %}
{% endif %}