Render rating status from template

This commit is contained in:
Mouse Reeve 2021-03-13 18:24:35 -08:00
parent a75e4a7404
commit aa2950daf3
2 changed files with 8 additions and 1 deletions

View file

@ -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"

View file

@ -0,0 +1,5 @@
{% load i18n %}{% load humanize %}{{% spaceless %}
{% blocktrans with title=book.title path=book.local_path rating=rating %}Rated <em><a href="{{ path }}">{{ title }}</a> </em>: {{ rating }} stars{% endblocktrans %}
{% endspaceless %}