Merge branch 'main' into delete-and-redraft

This commit is contained in:
Mouse Reeve
2021-04-04 09:05:12 -07:00
11 changed files with 405 additions and 456 deletions

View File

@ -122,12 +122,18 @@
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
<p class="mb-2"><label class="label" for="id_first_published_date">{% trans "First published date:" %}</label> {{ form.first_published_date }} </p>
<p class="mb-2">
<label class="label" for="id_first_published_date">{% trans "First published date:" %}</label>
<input type="date" name="first_published_date" class="input" id="id_first_published_date"{% if book.first_published_date %} value="{{ book.first_published_date|date:'Y-m-d' }}"{% endif %}>
</p>
{% for error in form.first_published_date.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
<p class="mb-2"><label class="label" for="id_published_date">{% trans "Published date:" %}</label> {{ form.published_date }} </p>
<p class="mb-2">
<label class="label" for="id_published_date">{% trans "Published date:" %}</label>
<input type="date" name="published_date" class="input" id="id_published_date"{% if book.published_date %} value="{{ book.published_date|date:'Y-m-d' }}"{% endif %}>
</p>
{% for error in form.published_date.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}

View File

@ -57,7 +57,7 @@
{% for book in goal.books %}
<div class="column is-one-fifth">
<div class="is-clipped">
<a href="{{ book.local_path }}">{% include 'snippets/book_cover.html' with book=book.book %}</a>
<a href="{{ book.book.local_path }}">{% include 'snippets/book_cover.html' with book=book.book %}</a>
</div>
</div>
{% endfor %}

View File

@ -27,16 +27,8 @@
{% if type == 'review' %}
<fieldset>
<legend class="is-sr-only">{% trans "Rating" %}</legend>
<div class="field is-grouped stars form-rate-stars">
<label class="is-sr-only" for="no-rating-{{ book.id }}">{% trans "No rating" %}</label>
<input class="is-sr-only" type="radio" name="rating" value="" id="no-rating-{{ book.id }}" {% if not draft or not draft.rating %}checked{% endif %}>
{% for i in '12345'|make_list %}
<input class="is-sr-only" id="book{{book.id}}-star-{{ forloop.counter }}" type="radio" name="rating" value="{{ forloop.counter }}" {% if draft and draft.rating == forloop.counter %}checked{% endif %}>
<label class="icon icon-star-empty" for="book{{book.id}}-star-{{ forloop.counter }}">
<span class="is-sr-only">{{ forloop.counter }} star{{ forloop.counter | pluralize }}</span>
</label>
{% endfor %}
</div>
{% include 'snippets/form_rate_stars.html' with book=book type=type|default:'summary' default_rating=draft.rating %}
</fieldset>
{% endif %}

View File

@ -0,0 +1,54 @@
{% spaceless %}
{% load i18n %}
{% load bookwyrm_tags %}
<div class="
field is-grouped
stars form-rate-stars
{% if classes %}{{classes}}{% endif%}
">
<input
id="{{ type|slugify }}-{{ book.id }}-no-rating"
class="is-sr-only"
type="radio"
name="rating"
value="0"
{% if book|user_rating:user == 0 %}checked{% endif %}
>
<label class="is-sr-only" for="{{ type|slugify }}-{{ book.id }}-no-rating">
{% trans "No rating" %}
</label>
{% for i in '12345'|make_list %}
<input
id="{{ type|slugify }}-book{{ book.id }}-star-{{ forloop.counter }}"
class="is-sr-only"
type="radio"
name="rating"
value="{{ forloop.counter }}"
{% if book|user_rating:user == forloop.counter %}checked{% endif %}
/>
<label
class="
icon
{% if forloop.counter <= book|user_rating:user %}
icon-star-full
{% else %}
icon-star-empty
{% endif %}
"
for="{{ type|slugify }}-book{{ book.id }}-star-{{ forloop.counter }}"
>
<span class="is-sr-only">
{% blocktranslate trimmed count rating=forloop.counter %}
{{ rating }} star
{% plural %}
{{ rating }} stars
{% endblocktranslate %}
</span>
</label>
{% endfor %}
</div>
{% endspaceless %}

View File

@ -8,18 +8,8 @@
<input type="hidden" name="user" value="{{ request.user.id }}">
<input type="hidden" name="book" value="{{ book.id }}">
<input type="hidden" name="privacy" value="public">
<input type="hidden" name="rating" value="{{ forloop.counter }}">
<div class="field is-grouped stars form-rate-stars mb-1 has-text-warning-dark">
<label class="is-sr-only" for="rating-no-rating-{{ book.id }}">{% trans "No rating" %}</label>
<input class="is-sr-only" type="radio" name="rating" value="" id="rating-no-rating-{{ book.id }}" checked>
{% for i in '12345'|make_list %}
<input class="is-sr-only" id="rating-book{{book.id}}-star-{{ forloop.counter }}" type="radio" name="rating" value="{{ forloop.counter }}" {% if book|user_rating:user == forloop.counter %}checked{% endif %}>
<label class="icon icon-star-empty" for="rating-book{{book.id}}-star-{{ forloop.counter }}">
<span class="is-sr-only">{{ forloop.counter }} star{{ forloop.counter | pluralize }}</span>
</label>
{% endfor %}
</div>
{% include 'snippets/form_rate_stars.html' with book=book classes='mb-1 has-text-warning-dark' %}
<div class="field has-addons hidden">
<div class="control">

View File

@ -1,8 +1,27 @@
{% spaceless %}
{% load i18n %}
<p class="stars">
<span class="is-sr-only">{% if rating %}{{ rating|floatformat }} star{{ rating|floatformat | pluralize }}{% else %}{% trans "No rating" %}{% endif %}</span>
{% for i in '12345'|make_list %}
<span class="icon is-small mr-1 icon-star-{% if rating >= forloop.counter %}full{% elif rating|floatformat:0 >= forloop.counter|floatformat:0 %}half{% else %}empty{% endif %}" aria-hidden="true">
<span class="is-sr-only">
{% if rating %}
{% blocktranslate trimmed with rating=rating|floatformat count counter=rating|length %}
{{ rating }} star
{% plural %}
{{ rating }} stars
{% endblocktranslate %}
{% else %}
{% trans "No rating" %}
{% endif %}
</span>
{% for i in '12345'|make_list %}
<span
class="
icon is-small mr-1
icon-star-{% if rating >= forloop.counter %}full{% elif rating|floatformat:0 >= forloop.counter|floatformat:0 %}half{% else %}empty{% endif %}
"
aria-hidden="true"
></span>
{% endfor %}
</p>
{% endspaceless %}