mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-27 18:40:31 +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):
|
||||
""" activitypub-aware boolean field """
|
||||
|
||||
def field_to_activity(self, value):
|
||||
return float(value)
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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