{% extends "base.html" %}
{% block body %}
    {% include "messages.html" %}
    {% include "organization/requests/tabs.html" %}

    {% if formset.forms %}
        <form action="" method="post">
            {% csrf_token %}
            {{ formset.management_form }}
            <table>
                <tr>
                    <th>{{ _('User') }}</th>
                    <th>{{ _('Time') }}</th>
                    <th>{{ _('State') }}</th>
                    <th>{{ _('Reason') }}</th>
                    {% if formset.can_delete %}
                        <th>{{ _('Delete?') }}</th>
                    {% endif %}
                </tr>
                {% for form in formset %}
                    <tr id="request-{{ form.instance.id }}">
                        <td>{{ form.id }}{{ link_user(form.instance.user) }}</td>
                        <td><a href="{{ url('request_organization_detail', object.id, object.slug, form.instance.id) }}">
                            {{ form.instance.time|date(_("N j, Y, H:i")) }}
                        </a></td>
                        <td>{{ form.state }}</td>
                        <td>{{ form.instance.reason|truncatechars(50) }}</td>
                        {% if formset.can_delete %}
                            <td>{{ form.DELETE }}</td>
                        {% endif %}
                    </tr>
                {% endfor %}
            </table>
            <button type="submit">{{ _('Update') }}</button>
        </form>
    {% else %}
        <p>{{ _('There are no requests to approve.') }}</p>
    {% endif %}
{% endblock %}