{% load i18n %}
{% load icons %}
{% load permissions %}
{% load translations %}

<div class="container-fluid">
{% for suggestion in suggestions %}
<div class="row history-row">
    <div class="col-xs-2 history-event">
        <strong>{{ suggestion.get_user_display }}</strong>
        <p class="text-muted">
        {% trans "Suggestion added" %}
        </p>
        {% if user_can_vote_suggestion %}
        <p class="help-block">
        {% blocktrans count count=suggestion.get_num_votes %}{{ count }} vote{% plural %}{{ count }} votes{% endblocktrans %}
        </p>
        {% endif %}
    </div>
    <div class="col-xs-10 history-data">
        {% if multi_unit %}
        <div class="btn-float pull-right flip">
            <a href="{{ suggestion.unit.get_absolute_url }}#suggestions" class="btn btn-link green" title="{% trans "View details" %}">{% icon "magnify-plus-outline.svg" %}</a>
        </div>
        {% else %}
        {% perm 'suggestion.delete' suggestion as user_can_delete_suggestion %}
        {% if user_can_vote_suggestion or user_can_accept_suggestion or user_can_delete_suggestion %}
        <div class="btn-float pull-right flip">
            {% if user_can_vote_suggestion %}
            <button type="submit" class="btn btn-link green" name="upvote" value="{{ suggestion.id }}" title="{% trans "Vote for" %}">{% icon "thumb-up.svg" %}</button>
            <button type="submit" class="btn btn-link red" name="downvote" value="{{ suggestion.id }}" title="{% trans "Vote against" %}">{% icon "thumb-down.svg" %}</button>
            {% endif %}
            {% if user_can_accept_suggestion %}
            <button type="submit" class="btn btn-link green" name="accept" value="{{ suggestion.id }}" title="{% trans "Accept" %}">{% icon "check.svg" %}</button>
            <button type="submit" class="btn btn-link green" name="accept_edit" value="{{ suggestion.id }}" title="{% trans "Accept and edit" %}">{% icon "pencil.svg" %}</button>
            {% endif %}
            {% if user_can_delete_suggestion %}
            {% if has_antispam and suggestion.user != user %}
            <button type="submit" class="btn btn-link red" name="spam" value="{{ suggestion.id }}" title="{% trans "Mark as spam" %}">{% icon "spam.svg" %}</button>
            {% endif %}
            <button type="submit" class="btn btn-link red" name="delete" value="{{ suggestion.id }}" title="{% trans "Delete" %}">{% icon "delete.svg" %}</button>
            {% endif %}
            {% if suggestion.user and not suggestion.user.is_anonymous %}
              {% perm 'project.permissions' suggestion.unit.translation as user_can_edit_permissions %}
              {% if user_can_edit_permissions %}
                <a class="btn btn-link red" href="{% url 'manage-access' project=suggestion.unit.translation.component.project.slug %}?block_user={{ suggestion.user.username }}#block-user" title="{% trans "Block user" %}">{% icon "account-cancel.svg" %}</a>
              {% endif %}
            {% endif %}
        </div>
        {% endif %}
        {% endif %}
        <div class="comment-content">
            {% format_translation suggestion.target suggestion.unit.translation.language suggestion.unit.translation.plural %}
            <p class="help-block">{% trans "Suggested change:" %}</p>
            {% format_translation suggestion.target suggestion.unit.translation.language suggestion.unit.translation.plural suggestion.unit.target %}

            {% with suggestion_checks=suggestion.get_checks %}
            {% if suggestion_checks %}
            <p class="help-block">{% trans "Failing checks:" %}</p>
            {% for check in suggestion.get_checks %}
                <span class="badge badge-danger" title="{{ check.get_description }}">{{ check.get_name }}</span>
            {% endfor %}
            {% endif %}
            {% endwith %}

            <span class="pull-right flip text-muted">{{ suggestion.timestamp|naturaltime }}</span>
            <div class="clearfix"></div>
        </div>
    </div>
</div>
{% endfor %}
</div>
