{% extends "base.html" %}

{% block title %}{{ _('Subscriber Overview') }}{% endblock %}

{% block content %}
<h2>{{ _('Subscriber Overview') }}</h2>

{%- include "flash.html" %} {# Show flash messages #}

{% if subscribers %}
<table class="striped">
    <thead>
        <tr>
            <th>{{ _('Email') }}</th>
            <th>{{ _('Subscribed Lists') }}</th>
            <th>{{ _('Bounces') }}</th>
        </tr>
    </thead>
    <tbody>
        {% for email, details in subscribers.items() %}
        {%- if is_email_a_list(email) %}{% set list = is_email_a_list(email) %}{% endif %}
        <tr>
            <td>
                <a href="{{ url_for('subscribers.by_email', email=email) }}">{{ email }}</a>
                {% if list %}
                ({{ _('List') }}{%- if list.deleted %} - <strong>{{ _('Deactivated') }}</strong>{% endif %})
                {% endif %}
            </td>
            <td>
                {% if details.lists %}
                    {% for list in details.lists %}
                        <a href="{{ url_for('lists.subscribers_manage', list_id=list.id) }}">{{ list.display }}</a>
                        {% if list.deleted %} ({{ _('Deactivated') }}){% endif %}
                        {% if not loop.last %}, {% endif %}
                    {% endfor %}
                {% else %}
                    <em>{{ _('Not subscribed to any lists.') }}</em>
                {% endif %}
            </td>
            <td>{{ details.bounces }}</td>
        </tr>
        {% endfor %}
    </tbody>
</table>
{% else %}
<p><em>{{ _('There are no subscribers anywhere.') }}</em></p>
{% endif %}
{% endblock %}
