{% extends base_template %}
{% load debusine %}
{% block content %}
    <h2>Account</h2>
    <div class="row">
        <div class="col-md-6">
            <table class="table table-hover table-striped">
                <tbody>
                    <tr>
                        <th scope="row">Full name</th>
                        <td id="full-name">{{ person.get_full_name|default:"&nbsp;" }}</td>
                    </tr>
                    <tr>
                        <th scope="row">Username</th>
                        <td id="username">{{ person.username }}</td>
                    </tr>
                    {% if person|has_perm:"can_manage" %}
                        <tr>
                            <th scope="row">Number of tokens</th>
                            <td id="token-count">
                                <a href="{% url "user:token-list" username=person.username %}">{{ person.token_set.count }}</a>
                            </td>
                        </tr>
                    {% endif %}
                </tbody>
            </table>
        </div>
    </div>
    {% if groups_by_scope %}
        <h2>Groups</h2>
        <table class="table table-hover table-striped" id="person-groups">
            <thead>
                <tr>
                    <th>Scope</th>
                    <th>Groups</th>
                </tr>
            </thead>
            <tbody>
                {% for scope, groups in groups_by_scope %}
                    <tr>
                        <td>{{ scope }}</td>
                        <td>
                            <ul class="list-unstyled">
                                {% for group in groups %}<li>{{ group.name }}</li>{% endfor %}
                            </ul>
                        </td>
                    </tr>
                {% endfor %}
            </tbody>
        </table>
    {% endif %}
    {% if identities and person|has_perm:"can_manage" %}
        <h2>Remote identities</h2>
        <table class="table table-hover table-striped" id="person-identities">
            <thead>
                <tr>
                    <th>Provider</th>
                    <th>Subject</th>
                    <th>Last used</th>
                </tr>
            </thead>
            <tbody>
                {% for provider, identity in identities %}
                    <tr>
                        <td>
                            {% include "account/_signon_provider_icon.html" with provider=provider only %}
                            {{ provider.label }}
                        </td>
                        <td>{{ identity.subject }}</td>
                        <td>{{ identity.last_used|date:"Y-m-d H:i" }}</td>
                    </tr>
                {% endfor %}
            </tbody>
        </table>
    {% endif %}
{% endblock %}
