mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-29 21:11:16 +00:00
Fixes review name in pure serialization
This commit is contained in:
parent
a0793a15f5
commit
bde6ce8525
3 changed files with 20 additions and 8 deletions
|
@ -448,3 +448,6 @@ class IntegerField(ActivitypubFieldMixin, models.IntegerField):
|
||||||
|
|
||||||
class DecimalField(ActivitypubFieldMixin, models.DecimalField):
|
class DecimalField(ActivitypubFieldMixin, models.DecimalField):
|
||||||
""" activitypub-aware boolean field """
|
""" activitypub-aware boolean field """
|
||||||
|
|
||||||
|
def field_to_activity(self, value):
|
||||||
|
return float(value)
|
||||||
|
|
|
@ -304,13 +304,12 @@ class Review(Status):
|
||||||
@property
|
@property
|
||||||
def pure_name(self):
|
def pure_name(self):
|
||||||
""" clarify review names for mastodon serialization """
|
""" clarify review names for mastodon serialization """
|
||||||
if self.rating:
|
template = get_template("snippets/generated_status/review_pure_name.html")
|
||||||
return 'Review of "{}" ({:d} stars): {}'.format(
|
return template.render({
|
||||||
self.book.title,
|
"book": self.book,
|
||||||
self.rating,
|
"rating": int(self.rating),
|
||||||
self.name,
|
"name": self.name
|
||||||
)
|
}).strip()
|
||||||
return 'Review of "{}": {}'.format(self.book.title, self.name)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def pure_content(self):
|
def pure_content(self):
|
||||||
|
@ -332,7 +331,7 @@ class ReviewRating(Review):
|
||||||
@property
|
@property
|
||||||
def pure_content(self):
|
def pure_content(self):
|
||||||
template = get_template("snippets/generated_status/rating.html")
|
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
|
activity_serializer = activitypub.Rating
|
||||||
pure_type = "Note"
|
pure_type = "Note"
|
||||||
|
|
|
@ -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 %}
|
Loading…
Reference in a new issue