{% extends "postorius/base.html" %}
{% load i18n %}
{% load nav_helpers %}
{% load pagination %}
{% load date_helpers %}
{% load tz %}

{% block head_title %}
{{ page_title }} | {{ list.fqdn_listname }} - {{ block.super }}
{% endblock %}

{% block content %}

    {% list_nav 'list_subscription_requests' page_title page_subtitle %}

    {% if paginated_requests.paginator.count > 0 %}
        <div class="table-responsive">
            <table class="table table-bordered table-striped">
                <thead>
                    <tr>
                        <th>{% trans 'E-Mail Address' %}</th>
                        <th>{% trans 'Date' %}</th>
                        <th>{% trans 'Actions' %}</th>
                    </tr>
                </thead>
                <tbody>
                    {% for request in paginated_requests.object_list %}
                    <tr>
                        <td>
                          {% if request.display_name %}
                              "{{ request.display_name }}" &lt;{{ request.email }}&gt;
                          {% else %}
                              {{ request.email }}
                          {% endif %}
                        </td>
                        <td>
                            {{ request.request_date|datetime_parse|localtime|date:"DATETIME_FORMAT" }}
                        </td>
                        <td>
                        <form action="{% url 'handle_subscription_request' list.list_id request.token %}" method="POST">
                            {% csrf_token %}
                            <input type="submit" class="btn btn-xs btn-success" name='accept' value="{% trans 'Accept' %}">
                            <input type="submit" class="btn btn-xs btn-danger" name='discard' value="{% trans 'Discard' %}">
                            <a href="{% url 'list_bans' list.list_id %}?email={{ request.email }}" class="btn btn-xs btn-danger">{% trans 'Ban' %}</a>
                            <textarea class="align-middle" rows="1" name="reason" placeholder="{% trans 'Rejection reason' %}"></textarea>
                            <input type="submit" class="btn btn-xs btn-danger" name='reject' value="{% trans 'Reject' %}">
                            <input type="hidden" name="kind" value="{{request_type}}" />
                        </form>
                        </td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
        {% paginator paginated_requests %}
    {% else %}
        <p>{% trans 'There are currently no subscription requests for this list.' %}</p>
    {% endif %}
{% endblock %}
