Fixes review name in pure serialization

This commit is contained in:
Mouse Reeve 2021-03-24 09:31:45 -07:00
parent a0793a15f5
commit bde6ce8525
3 changed files with 20 additions and 8 deletions

View file

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

View file

@ -304,13 +304,12 @@ class Review(Status):
@property
def pure_name(self):
""" clarify review names for mastodon serialization """
if self.rating:
return 'Review of "{}" ({:d} stars): {}'.format(
self.book.title,
self.rating,
self.name,
)
return 'Review of "{}": {}'.format(self.book.title, self.name)
template = get_template("snippets/generated_status/review_pure_name.html")
return template.render({
"book": self.book,
"rating": int(self.rating),
"name": self.name
}).strip()
@property
def pure_content(self):
@ -332,7 +331,7 @@ class ReviewRating(Review):
@property
def pure_content(self):
template = get_template("snippets/generated_status/rating.html")
return template.render({"book": self.book, "rating": self.rating}).strip()
return template.render({"book": self.book, "rating": int(self.rating)}).strip()
activity_serializer = activitypub.Rating
pure_type = "Note"

View file

@ -0,0 +1,10 @@
{% load i18n %}
{% if rating %}
{% blocktrans with book_title=book.title rating=rating 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 %}