From aa2950daf35041d3e4d4e9b9b330d885daab6e70 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 13 Mar 2021 18:24:35 -0800 Subject: [PATCH] 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 %}