Pass existing rating to stars form element as variable

This commit is contained in:
Mouse Reeve 2021-04-04 09:05:21 -07:00
parent 4c2f1db6a6
commit 521f917d01
2 changed files with 4 additions and 4 deletions

View file

@ -13,7 +13,7 @@
type="radio"
name="rating"
value="0"
{% if book|user_rating:user == 0 %}checked{% endif %}
{% if default_rating == 0 or not default_rating %}checked{% endif %}
>
<label class="is-sr-only" for="{{ type|slugify }}-{{ book.id }}-no-rating">
@ -27,13 +27,13 @@
type="radio"
name="rating"
value="{{ forloop.counter }}"
{% if book|user_rating:user == forloop.counter %}checked{% endif %}
{% if default_rating == forloop.counter %}checked{% endif %}
/>
<label
class="
icon
{% if forloop.counter <= book|user_rating:user %}
{% if forloop.counter <= default_rating %}
icon-star-full
{% else %}
icon-star-empty

View file

@ -9,7 +9,7 @@
<input type="hidden" name="book" value="{{ book.id }}">
<input type="hidden" name="privacy" value="public">
{% include 'snippets/form_rate_stars.html' with book=book classes='mb-1 has-text-warning-dark' %}
{% include 'snippets/form_rate_stars.html' with book=book classes='mb-1 has-text-warning-dark' default_rating=book|user_rating:request.user %}
<div class="field has-addons hidden">
<div class="control">