{% load spirit_tags i18n %}

<div class="comment__text__poll" id="p{{ poll.pk }}">
  {% if poll.title %}
  <div class="comment__text__poll__title">
    {{ poll.title|safe }}
  </div>
  {% endif %}

  <div class="comment__text__poll__choices">
    <ul>
      {% for choice in poll.choices %}
      <li class="comment__text__poll__choices__choice">
        <div class="comment__text__poll__choices__choice__description">
          {% blocktrans trimmed with choice=choice.description|safe percentage=choice.votes_percentage|floatformat:"0"  %}
          {{ choice }}, {{ percentage }}%
          {% endblocktrans %}
          {% if choice.vote_count %}
          <a href="{% url "spirit:comment:poll:voters" pk=choice.pk %}">{% trans "View voters" %}</a>
          {% endif %}
        </div>
        <div class="comment__text__poll__choices__choice__bar" style="width:{{ choice.votes_percentage|floatformat:"0" }}%;"></div>
  </li>
  {% endfor %}
  </ul>
</div>

<div class="comment__text__poll__note">
  {% trans "Votes" %}: {{ poll.total_votes }}.
</div>

<div class="comment__text__poll__actions">
  {% if not poll.is_closed %}
  <a
    class="comment__text__poll__actions__action"
    href="?{% to_query_params show_poll=show_poll %}#p{{ poll.pk }}"
  ><i class="fa fa-eye"></i> {% trans "Show vote choices" %}</a>
  {% endif %}

  {% if user.is_authenticated and user.pk == comment.user.pk %}
  {% if poll.is_closed %}
  <a
    class="comment__text__poll__actions__action js-post"
    href="{% url "spirit:comment:poll:open" pk=poll.pk %}"
  ><i class="fa fa-unlock"></i> {% trans "open" %}</a>
  {% else %}
  <a
    class="comment__text__poll__actions__action js-post"
    href="{% url "spirit:comment:poll:close" pk=poll.pk %}"
  ><i class="fa fa-lock"></i> {% trans "close" %}</a>
  {% endif %}
  {% endif %}
</div>
</div>

