forked from mirrors/bookwyrm
Merge pull request #736 from mouse-reeve/rating-template
Render rating status from template
This commit is contained in:
commit
def834a0ac
2 changed files with 6 additions and 1 deletions
|
@ -5,6 +5,7 @@ import re
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
from django.core.validators import MaxValueValidator, MinValueValidator
|
from django.core.validators import MaxValueValidator, MinValueValidator
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
from django.template.loader import get_template
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from model_utils.managers import InheritanceManager
|
from model_utils.managers import InheritanceManager
|
||||||
|
|
||||||
|
@ -309,7 +310,8 @@ class ReviewRating(Review):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def pure_content(self):
|
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
|
activity_serializer = activitypub.Rating
|
||||||
pure_type = "Note"
|
pure_type = "Note"
|
||||||
|
|
3
bookwyrm/templates/snippets/generated_status/rating.html
Normal file
3
bookwyrm/templates/snippets/generated_status/rating.html
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{% load i18n %}{% load humanize %}
|
||||||
|
|
||||||
|
{% blocktrans with title=book.title path=book.remote_id rating=rating count counter=rating %}Rated <em><a href="{{ path }}">{{ title }}</a></em>: {{ rating }} star{% plural %}Rated <em><a href="{{ path }}">{{ title }}</a></em>: {{ rating }} stars{% endblocktrans %}
|
Loading…
Reference in a new issue