{% extends "two_column_body.html" %}
{% import "macros.html" as macros %}
<!-- tags.html -->
{% block title %}{{ page_title }}{% endblock %}
{% block content %}
    {% include "tags/header.html" %}
    {% if tags %}
        <table class="suggested-tags-table">
            <thead>
                <tr>
                    <th class="tags-col">{% trans %}Tag{% endtrans %}</th>
                    <th class="users-col">{% trans %}Suggested by{% endtrans %}</th>
                    <th class="decision-col">{% trans %}Your decision{% endtrans %}</th>
                    <th>{% trans %}Where the tag was used{% endtrans %}</th>
                </tr>
            </thead>
            <tbody>
            {% for tag in tags %}
                <tr class="suggested-tag-row" data-tag-id="{{ tag.id }}">
                    <td class="tags-col">
                        {{ macros.tag_widget(tag.name, is_link = False) }}
                        <span class="tag-number">&#215;{{ tag.used_count }}</span>
                    </td>
                    <td class="users-col">
                        {% for user in tag.suggested_by.all() %}
                            <p>{{ user.get_profile_link() }}</p>
                        {% endfor %}
                    </td>
                    <td colspan="2">
                        <table>{# inner table for the list of questions #}
                        {% if tag.threads.count() == 0 %}
                            <tr class="thread-info" data-thread-id="0">
                                <td class="per-thread-controls">
                                    <button class="accept">{% trans %}Accept{% endtrans %}</button>
                                    <button class="reject">{% trans %}Reject{% endtrans %}</button>
                                </td>
                                <td class="thread-links-col">
                                    <span>{% trans %}This tag has not yet been used{% endtrans %}</span>
                                </td>
                            </tr>
                        {% else %}
                            {% for thread in tag.threads.all() %}
                                <tr class="thread-info" data-thread-id="{{ thread.id }}">
                                    <td class="per-thread-controls">
                                        <button class="accept">{% trans %}Accept{% endtrans %}</button>
                                        <button class="reject">{% trans %}Reject{% endtrans %}</button>
                                    </td>
                                    <td class="thread-links-col">
                                        <a href="{{ thread.get_absolute_url() }}"
                                        >{{ thread.title|escape }}</a>
                                    </td>
                                </tr>
                            {% endfor %}
                        {% endif %}
                        </table>
                    </td>
                </tr>
                <tr class="per-tag-controls" data-tag-id="{{ tag.id }}">
                    <td colspan="4">
                        {% if tag.threads.count() > 1 %}
                            <button class="accept">{% trans name=tag.name %}Apply tag "{{ name }}" to the above{% endtrans %}</button>
                            <button class="reject">{% trans %}Reject tag{% endtrans %}</button>
                        {% endif %}
                    </td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
    {% else %}
        <span>{% trans %}Nothing found{% endtrans %}</span>
    {% endif %}
{% endblock %}
{% block endjs %}
    <script type="text/javascript">
        askbot['urls']['moderateSuggestedTag'] = '{% url "moderate_suggested_tag" %}';
    </script>
    <script type="text/javascript" src="{{ '/js/tag_moderation.js'|media }}"></script>
{% endblock %}
