{% load i18n pretty_money perms %}

<dl class="row">
    <dt class="col-xl-6">{% trans 'name'|capfirst %}, {% trans 'first name' %}</dt>
    <dd class="col-xl-6">{{ user_object.last_name }} {{ user_object.first_name }}</dd>

    <dt class="col-xl-6">{% trans 'username'|capfirst %}</dt>
    <dd class="col-xl-6">{{ user_object.username }}</dd>

    {% if family_app_installed %}
    <dt class="col-xl-6">{% trans 'family'|capfirst %}</dt>
    <dd class="col-xl-6">
        {% if families %}
            {% for fam in families %}
            <a href="{% url 'family:family_detail' fam.pk %}">{{ fam.name }}</a>{% if not forloop.last %}, {% endif %}
            {% endfor %}
        {% else %}
            <span class="text-muted">Aucune</span>
        {% endif %}
    </dd>
    {% endif %}

    {% if user_object.pk == user.pk %}
    <dt class="col-xl-6">{% trans 'password'|capfirst %}</dt>
    <dd class="col-xl-6">
        <a class="badge badge-secondary" href="{% url 'password_change' %}">
            <i class="fa fa-lock"></i>
            {% trans 'Change password' %}
        </a>
    </dd>
    {% endif %}

    <dt class="col-xl-6">{% trans 'aliases'|capfirst %}</dt>
    <dd class="col-xl-6">
        <a class="badge badge-secondary" href="{% url 'member:user_alias' user_object.pk %}">
            <i class="fa fa-edit"></i>
            {% trans 'Manage aliases' %} ({{ user_object.note.alias.all|length }})
        </a>
    </dd>

    <dt class="col-xl-6">{% trans 'friendships'|capfirst %}</dt>
    <dd class="col-xl-6">
        <a class="badge badge-secondary" href="{% url 'member:user_trust' user_object.pk %}">
            <i class="fa fa-edit"></i>
            {% trans 'Manage friendships' %} ({{ user_object.note.trusting.all|length }})
        </a>
    </dd>

    {% if "member.view_profile"|has_perm:user_object.profile %}
        <dt class="col-xl-6">{% trans 'section'|capfirst %}</dt>
        <dd class="col-xl-6">{{ user_object.profile.section }}</dd>

        <dt class="col-xl-6">{% trans 'email'|capfirst %}</dt>
        <dd class="col-xl-6"><a href="mailto:{{ user_object.email }}">{{ user_object.email }}</a></dd>

        <dt class="col-xl-6">{% trans 'phone number'|capfirst %}</dt>
        <dd class="col-xl-6"><a href="tel:{{ user_object.profile.phone_number }}">{{ user_object.profile.phone_number }}</a>
        </dd>

        <dt class="col-xl-6">{% trans 'address'|capfirst %}</dt>
        <dd class="col-xl-6">{{ user_object.profile.address }}</dd>

        <dt class="col-xl-6">{% trans 'paid'|capfirst %}</dt>
        <dd class="col-xl-6">{{ user_object.profile.paid|yesno }}</dd>
    {% endif %}

    {% if user_object.note and "note.view_note"|has_perm:user_object.note %}
        <dt class="col-xl-6">{% trans 'balance'|capfirst %}</dt>
        <dd class="col-xl-6">{{ user_object.note.balance | pretty_money }}</dd>
    {% endif %}
</dl>

{% if user_object.pk == user.pk %}
    <div class="text-center">
        <a class="small badge badge-secondary" href="{% url 'member:auth_token' %}">
            <i class="fa fa-cogs"></i>{% trans 'API token' %}
        </a>
    </div>
{% endif %}
