{% extends "hyperkitty/user_profile/base.html" %}
{% load i18n %}
{% load hk_generic %}
{% load pagination %}


{% block user_profile_content %}

    {% if votes %}
        <table class="table table-bordered table-sm d-md-none">
            <tbody>
            {% for vote in votes %}
                {% ifchanged vote.email.mailinglist.name %}
                <tr class="list-address">
                    <td>{{ vote.email.mailinglist.name }}</td>
                </tr>
                {% endifchanged %}
                <tr>
                    <td>
                        <a href="{% url 'hk_message_index' mlist_fqdn=vote.email.mailinglist.name message_id_hash=vote.email.message_id_hash %}"
                            >{{ vote.email.subject }}</a>
                        <br>
                        {% trans "Original author:" %} {{ vote.email.sender_name|default:vote.email.sender.address }}
                        <br>
                        {% trans "Started on:" %} {{ vote.email.date|date:"D, j M Y H:i" }}
                        <br>
                        <form method="post" class="likeform"
                              action="{% url 'hk_message_vote' mlist_fqdn=vote.email.mailinglist.name message_id_hash=vote.email.message_id_hash %}">
                            {% csrf_token %}
                            <input type="hidden" name="vote" value="0" />
                            {% if vote.value == 1 %}
                            <span class="youlike">{% trans "You like it" %}
                            {% elif vote.value == -1 %}
                            <span class="youdislike">{% trans "You dislike it" %}
                            {% endif %}
                            (<a href="#cancelvote" class="cancel">{% trans "cancel" %}</a>)</span>
                        </form>
                    </td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
        <table class="table table-striped table-bordered table-sm d-none d-md-table">
            <thead>
                <tr>
                    <th>{% trans "List" %}</th>
                    <th>{% trans "Subject" %}</th>
                    <th>{% trans "Original author" %}</th>
                    <th>{% trans "Start date" %}</th>
                    <th>{% trans "Vote" %}</th>
                </tr>
            </thead>
            <tbody>
            {% for vote in votes %}
                <tr>
                    <td>
                        <span class="hidden-md hidden-lg">{{ vote.email.mailinglist.name|until:"@" }}</span>
                        <span class="hidden-sm">{{ vote.email.mailinglist.name }}</span>
                    </td>
                    <td><a href="{% url 'hk_message_index' mlist_fqdn=vote.email.mailinglist.name message_id_hash=vote.email.message_id_hash %}"
                            >{{ vote.email.subject }}</a></td>
                    <td>{{ vote.email.sender_name|default:vote.email.sender.address }}</td>
                    <td>{{ vote.email.date|date:"l, j F Y H:i:s" }}</td>
                    <td>
                        <form method="post" class="likeform"
                              action="{% url 'hk_message_vote' mlist_fqdn=vote.email.mailinglist.name message_id_hash=vote.email.message_id_hash %}">
                            {% csrf_token %}
                            <input type="hidden" name="vote" value="0" />
                            {% if vote.value == 1 %}
                            <span class="youlike">{% trans "You like it" %}
                            {% elif vote.value == -1 %}
                            <span class="youdislike">{% trans "You dislike it" %}
                            {% endif %}
                            (<a href="#cancelvote" class="cancel">{% trans "cancel" %}</a>)</span>
                        </form>
                    </td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
        {% paginator votes qsprefix="v" bydate=True %}
    {% else %}
        <p>{% trans "No vote yet." %}</p>
    {% endif %}

{% endblock %}
