{% extends 'settings/layout.html' %}
{% load i18n %}
{% load humanize %}

{% block title %}{% trans "Email Blocklist" %}{% endblock %}

{% block header %}{% trans "Email Blocklist" %}{% endblock %}

{% block edit-button %}
{% trans "Add domain" as button_text %}
{% include 'snippets/toggle/open_button.html' with controls_text="add_domain" icon_with_text="plus" text=button_text focus="add_domain_header" %}
{% endblock %}

{% block panel %}
{% include 'settings/domain_form.html' with controls_text="add_domain" class="block" %}

<p class="notification block">
    {% trans "When someone tries to register with an email from this domain, no account will be created. The registration process will appear to have worked." %}
</p>

<table class="table is-striped is-fullwidth">
    <tr>
        {% url 'settings-federation' as url %}
        <th>
            {% trans "Domain" %}
        </th>
        <th>{% trans "Users" %}</th>
        <th>
            {% trans "Options" %}
        </th>
    </tr>
    {% for domain in domains %}
    <tr>
        <td>{{ domain.domain }}</td>
        <td>
            <a href="{% url 'settings-users' %}?email=@{{ domain.domain }}">
            {% with user_count=domain.users.count %}
                {% blocktrans trimmed count conter=user_count with display_count=user_count|intcomma %}
                {{ display_count }} user
                {% plural %}
                {{ display_count }} users
                {% endblocktrans %}
            {% endwith %}
            </a>
        </td>
        <td>
            <form name="remove-{{ domain.id }}" action="{% url 'settings-email-blocks-delete' domain.id %}" method="post">
                {% csrf_token %}
                {% trans "Delete" as button_text %}
                <button class="button" type="submit">
                    <span class="icon icon-x" title="{{ button_text }}" aria-hidden="true"></span>
                    <span class="is-hidden-mobile">{{ button_text }}</span>
                </button>
            </form>
        </td>
    </tr>
    {% endfor %}
</table>

{% endblock %}