From aa2950daf35041d3e4d4e9b9b330d885daab6e70 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 13 Mar 2021 18:24:35 -0800 Subject: [PATCH 1/4] Render rating status from template --- bookwyrm/models/status.py | 4 +++- bookwyrm/templates/snippets/generated_status/rating.html | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 bookwyrm/templates/snippets/generated_status/rating.html diff --git a/bookwyrm/models/status.py b/bookwyrm/models/status.py index c5e69936..0e18dc1b 100644 --- a/bookwyrm/models/status.py +++ b/bookwyrm/models/status.py @@ -5,6 +5,7 @@ import re from django.apps import apps from django.core.validators import MaxValueValidator, MinValueValidator from django.db import models +from django.template.loader import get_template from django.utils import timezone from model_utils.managers import InheritanceManager @@ -309,7 +310,8 @@ class ReviewRating(Review): @property def pure_content(self): - return 'Rated "{}": {:d} stars'.format(self.book.title, self.rating) + template = get_template("snippets/generated_status/rating.html") + 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 new file mode 100644 index 00000000..e4e42fca --- /dev/null +++ b/bookwyrm/templates/snippets/generated_status/rating.html @@ -0,0 +1,5 @@ +{% load i18n %}{% load humanize %}{{% spaceless %} + +{% blocktrans with title=book.title path=book.local_path rating=rating %}Rated {{ title }} : {{ rating }} stars{% endblocktrans %} + +{% endspaceless %} From 6bd0f94269e317a0e36bf7ea0cba191ad6d38dd3 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Mon, 15 Mar 2021 14:09:04 -0700 Subject: [PATCH 2/4] Adds plural version for rating text --- bookwyrm/templates/snippets/generated_status/rating.html | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/bookwyrm/templates/snippets/generated_status/rating.html b/bookwyrm/templates/snippets/generated_status/rating.html index e4e42fca..13afd94d 100644 --- a/bookwyrm/templates/snippets/generated_status/rating.html +++ b/bookwyrm/templates/snippets/generated_status/rating.html @@ -1,5 +1,3 @@ -{% load i18n %}{% load humanize %}{{% spaceless %} +{% load i18n %}{% load humanize %} -{% blocktrans with title=book.title path=book.local_path rating=rating %}Rated {{ title }} : {{ rating }} stars{% endblocktrans %} - -{% endspaceless %} +{% blocktrans with title=book.title path=book.remote_id rating=rating count counter=rating %}Rated {{ title }}: {{ rating }} star{% plural %}Rated {{ title }}: {{ rating }} stars{% endblocktrans %}