{% load i18n %}
{% load markdown %}
{% load humanize %}

<div class="block columns">
    <div class="column is-flex is-flex-direction-column">
        <h4 class="title is-4">{% trans "Profile" %}</h4>
        <div class="box is-flex-grow-1">
            {% include 'user/user_preview.html' with user=user admin_mode=True %}
            {% if user.summary %}
            <div class="box content has-background-secondary is-shadowless">
                {{ user.summary|to_markdown|safe }}
            </div>
            {% endif %}

            <p class="mt-2"><a href="{{ user.local_path }}">{% trans "View user profile" %}</a></p>
            {% url 'settings-user' user.id as url %}
            {% if not request.path == url %}
            <p class="mt-2"><a href="{{ url }}">{% trans "Go to user admin" %}</a></p>
            {% endif %}
        </div>
    </div>
    <div class="column is-flex is-flex-direction-column is-4">
        <h4 class="title is-4">{% trans "Status" %}</h4>
        <div class="box is-flex-grow-1 has-text-weight-bold">
            {% if user.is_active %}
            <p class="notification is-success">
                {% trans "Active" %}
            </p>
            {% else %}
            <p class="notification is-warning">
                {% trans "Inactive" %}
                {% if user.deactivation_reason %}
                <span class="help">({% trans user.get_deactivation_reason_display %})</span>
                {% endif %}
            </p>
            {% endif %}
            <p class="notification">
                {% if user.local %}
                {% trans "Local" %}
                {% else %}
                {% trans "Remote" %}
                {% endif %}
            </p>
        </div>
    </div>
</div>

<div class="block columns">
    <div class="column is-flex is-flex-direction-column">
        <h4 class="title is-4">{% trans "User details" %}</h4>
        <div class="box content is-flex-grow-1">
            <dl>
                {% if user.local %}
                <dt class="is-pulled-left mr-5">{% trans "Email:" %}</dt>
                <dd>{{ user.email }}</dd>
                {% endif %}

                {% with report_count=user.report_set.count %}
                <dt class="is-pulled-left mr-5">{% trans "Reports:" %}</dt>
                <dd>
                    {{ report_count|intcomma }}
                    {% if report_count > 0 %}
                    <a href="{% url 'settings-reports' %}?username={{ user.username }}">
                        {% trans "(View reports)" %}
                    </a>
                    {% endif %}
                </dd>
                {% endwith %}

                <dt class="is-pulled-left mr-5">{% trans "Blocked by count:" %}</dt>
                <dd>{{ user.blocked_by.count }}</dd>

                <dt class="is-pulled-left mr-5">{% trans "Date added:" %}</dt>
                <dd>{{ user.created_date }}</dd>

                <dt class="is-pulled-left mr-5">{% trans "Last active date:" %}</dt>
                <dd>{{ user.last_active_date }}</dd>

                <dt class="is-pulled-left mr-5">{% trans "Manually approved followers:" %}</dt>
                <dd>{{ user.manually_approves_followers|yesno }}</dd>

                <dt class="is-pulled-left mr-5">{% trans "Discoverable:" %}</dt>
                <dd>{{ user.discoverable|yesno }}</dd>

                {% if not user.is_active %}
                <dt class="is-pulled-left mr-5">{% trans "Deactivation reason:" %}</dt>
                <dd>{{ user.get_deactivation_reason_display }}</dd>
                {% endif %}

                {% if not user.is_active and user.deactivation_reason == "pending" %}
                <dt class="is-pulled-left mr-5">{% trans "Confirmation code:" %}</dt>
                <dd>{{ user.confirmation_code }}</dd>
                {% endif %}
            </dl>
        </div>
    </div>

    {% if not user.local %}
    {% with server=user.federated_server %}
    <div class="column is-half is-flex is-flex-direction-column">
        <h4 class="title is-4">{% trans "Instance details" %}</h4>
        <div class="box content is-flex-grow-1">
            {% if server %}
            <h5>{{ server.server_name }}</h5>
            <dl>
                <dt class="is-pulled-left mr-5">{% trans "Software:" %}</dt>
                <dd>{{ server.application_type }}</dd>

                <dt class="is-pulled-left mr-5">{% trans "Version:" %}</dt>
                <dd>{{ server.application_version }}</dd>

                <dt class="is-pulled-left mr-5">{% trans "Status:" %}</dt>
                <dd>{{ server.get_status_display }}</dd>
            </dl>
            {% if server.notes %}
            <h5>{% trans "Notes" %}</h5>
            <div class="box content has-background-secondary is-shadowless">
                {{ server.notes }}
            </div>
            {% endif %}

            <p>
                <a href="{% url 'settings-federated-server' server.id %}">{% trans "View instance" %}</a>
            </p>
            {% else %}
            <em>{% trans "Not set" %}</em>
            {% endif %}
        </div>
    </div>
    {% endwith %}
    {% endif %}
</div>

