{% extends "layout.html" %}
{% block head%}
{{super()}}
{% endblock %}
{% block content %}
<div class="container">
    <div class="well">
        <a href="/admin/edit_user/{{ user.id }}" class="btn btn-default">{{ _('Edit this user') }}</a>
        <h2>{{ _('Membership') }}</h2>
        <div class="row">
            <div class="col-md-6">
                <p>{{ _('Member since') }} {{ user.date_created | datetime }}.</p>
                <p>{{ _('Last seen:') }} {{ user.last_seen | datetime }}.</p>
            </div>
        </div>
    </div>
    <div class="well">
        {% if user.feeds.all()|count == 0 %}
            <h1>{{ _('This user is not subscribed to any feed.') }}</h1>
        {% else %}
            <h1>{{ _('Feeds') }}</h1>
            <table class="table table-striped">
                <thead>
                    <tr>
                        <th>#</th>
                        <th>{{ _('Name') }}</th>
                        <th>{{ _('Feed link') }}</th>
                        <th>{{ _('Site link') }}</th>
                        <th>{{ _('Number of articles') }}</th>
                        <th>{{ _('Actions') }}</th>
                    </tr>
                </thead>
                <tbody>
                {% for feed in user.feeds|sort(attribute="title") %}
                    <tr>
                        <td>{{ loop.index }}</td>
                        <td><a href="/feed/{{ feed.id }}">{{ feed.title }}</a></td>
                        <td>{{ feed.link }}</td>
                        <td>{{ feed.site_link }}</td>
                        <td>{{ feed.articles.all()|count }}</td>
                        <td>
                            <a href="{{ url_for("feed.feed", feed_id=feed.id) }}"><i class="glyphicon glyphicon-th-list" title="{{ _('Feed') }}"></i></a>
                            <a href="{{ url_for("feed.form", feed_id=feed.id) }}"><i class="glyphicon glyphicon-edit" title="{{ _('Edit this feed') }}"></i></a>
                            <a href="{{ url_for("feed.delete", feed_id=feed.id) }}"><i class="glyphicon glyphicon-remove" title="{{ _('Delete this feed') }}" onclick="return confirm('{{ _('You are going to delete this feed.') }}');"></i></a>
                        </td>
                {% endfor %}
                </tbody>
            </table>
        {% endif %}
    </div>
</div>
{% endblock %}
