Fixes labels

This commit is contained in:
Mouse Reeve 2021-09-10 14:41:55 -07:00
parent daf42a30da
commit 8840e09eac
2 changed files with 13 additions and 1 deletions

View file

@ -1,5 +1,6 @@
{% spaceless %}
{% load i18n %}
{% load stars %}
<div class="
field is-grouped
@ -24,7 +25,7 @@
class="is-sr-only"
for="{{ type|slugify }}_book{{ book.id }}_star_{{ forloop.counter0 }}_half"
>
{% blocktranslate trimmed count rating=forloop.counter0 with half_rating=forloop.counter0|add:""|add:"0.5" %}
{% blocktranslate trimmed count rating=forloop.counter0 with half_rating=forloop.counter0|half_star %}
{{ half_rating }} star
{% plural %}
{{ half_rating }} stars

View file

@ -0,0 +1,11 @@
""" template filters """
from django import template
register = template.Library()
@register.filter(name="half_star")
def get_half_star(value):
"""one of those things that's weirdly hard with templates"""
return f"{value}.5"