{% extends "pretixcontrol/organizers/base.html" %}
{% load i18n %}
{% load bootstrap3 %}
{% block inner %}
    <form action="" method="post" class="form-horizontal form-permissions">
        {% csrf_token %}
        <p>
            {% blocktrans trimmed %}
                You can use the following list to control who can create new events in the name of
                this organizer and who can add more people to this list. This does <strong>not</strong>
                control who has access to a particular event. You can control the access to an
                event in the "Permissions" section of the event's settings. A user does not need to
                be on the list here to get access to an event.
            {% endblocktrans %}
        </p>
        <p>
            {% trans "Everyone on this list can control the organizer settings on this page." %}
        </p>

        {% bootstrap_formset_errors formset %}
        {{ formset.management_form }}
        <div class="table-responsive">
            <table class="table table-striped table-condensed">
                <thead>
                <tr>
                    <th>{% trans "User" %}</th>
                    <th>{% trans "Create events" %}</th>
                    <th>{% trans "Change permissions" %}</th>
                    <th>{% trans "Delete" %}</th>
                </tr>
                </thead>
                <tbody>
                {% for form in formset %}
                    <tr>
                        <td>
                            {{ form.id }}
                            {% if form.instance.user %}
                                {{ form.instance.user }}
                            {% else %}
                                {{ form.instance.invite_email }}
                                <span class="fa fa-envelope-o" data-toggle="tooltip"
                                        title="{% trans "invited, pending response" %}"></span>
                            {% endif %}
                        </td>
                        <td>{{ form.can_create_events }}</td>
                        <td>{{ form.can_change_permissions }}</td>
                        <td>{{ form.DELETE }}</td>
                    </tr>
                {% endfor %}
                </tbody>
                <tfoot>
                <tr>
                    <td colspan="9">
                        <strong>{% trans "Adding a new user" %}</strong><br>
                        {% blocktrans trimmed %}
                            To add a new user, you can enter their email address here. If they
                            already have a pretix account, they will immediately be added to the team.
                            Otherwise, they will be sent an email with an invitation.
                        {% endblocktrans %}
                    </td>

                </tr>
                <tr>
                    <td>
                        <div class="row-fluid">
                            <div class="col-sm-12">
                                {% bootstrap_field add_form.user layout='inline' %}
                            </div>
                        </div>
                    </td>
                    <td>{{ add_form.can_create_events }}</td>
                    <td>{{ add_form.can_change_permissions }}</td>
                </tr>
                </tfoot>
            </table>
        </div>
        <div class="form-group submit-group">
            <button type="submit" class="btn btn-primary btn-save">
                {% trans "Save" %}
            </button>
        </div>

    </form>
{% endblock %}
