{% extends "member/base.html" %}

{% load emarkdown %}
{% load email_obfuscator %}
{% load date %}
{% load profile %}
{% load crispy_forms_tags %}
{% load i18n %}



{% block title %}
    {{ usr.username }}
{% endblock %}



{% block body_class %}content-cols{% endblock %}



{% block breadcrumb %}
    <li>{{ usr.username }}</li>
{% endblock %}



{% block content_out %}
    <section class="content-col-2">
        <h1 id="infos-generales">
            {% trans "Profil de" %} {{ usr.username }}
        </h1>

        <div class="member-card">
            <div class="member-avatar">
                <img src="{{ profile.get_avatar_url }}" alt="" class="avatar">

                {% include 'misc/badge.part.html' with member=usr %}
            </div>

            <ul class="member-infos">
                {% if not profile.is_private %}
                    <li>
                        {% trans "Inscrit" %} {{ usr.date_joined|format_date:True }}
                    </li>
                    <li>
                        {% trans "Dernière visite sur le site" %} :
                            {% if profile.last_visit %}
                                {{ profile.last_visit|format_date:True }}
                            {% else %}
                                {% trans "ne s'est jamais connecté(e)" %}
                            {% endif %}
                    </li>
                {% else %}
                    <li>
                        {% trans "Ce membre est un compte d'administration" %}
                    </li>
                {% endif %}
                {% if perms.member.show_ip %}
                    <li>
                        {% trans "Dernière IP" %} : <a href="{% url "member.views.member_from_ip" profile.last_ip_address %}">{{ profile.last_ip_address }}</a>
                    </li>
                    <li>
                        {{ profile.get_city }}
                    </li>
                {% endif %}
            </ul>
        </div>


        <hr class="clearfix" />


        <ul class="member-social">
            {% if profile.show_email and user.is_authenticated %}
                <li>
                    {% trans "E-mail" %} : {{ usr.email|obfuscate_mailto }}
                </li>
            {% endif %}

            {% if profile.site %}
                <li>
                    {% trans "Site web" %} : <a href="{{ profile.site }}">{{ profile.site }}</a>
                </li>
            {% endif %}
        </ul>

        {% if perms.member.change_profile and not profile.is_private %}
            <div>
                {% trans "Remarques sur cet utilisateur" %} ({{ profile.karma }}) :
                <ul>
                {% if karmanotes.count > 0 %}
                    {% for note in karmanotes %}
                        <li><strong>{{ note.value }}</strong> {{ note.create_at|format_date:True }} {% trans "par" %} {{ note.staff.username }} : {{ note.comment }}</li>
                    {% endfor %}
                {% else %}
                    <li>{% trans "Cet utilisateur n'a reçu aucune remarque" %}</li>
                {% endif %}
                </ul>
                <a href="#karmatiser-modal" class="open-modal">{% trans "Ajouter une remarque" %}</a>
                <div id="karmatiser-modal" class="modal modal-big">
                    {% crispy karmaform %}
                </div>
            </div>
        {% endif %}

        {% if profile.sign %}
            <h2 id="signature">{% trans "Signature" %}</h2>
            {{ profile.sign|emarkdown_inline }}
        {% endif %}


        {% if topics %}
            <h2 id="derniers-sujets">{% trans "Derniers sujets créés" %}</h2>
            <div class="topic-list navigable-list" itemscope itemtype="http://schema.org/ItemList">
                {% for topic in topics %}
                    {% include "forum/includes/topic_row.part.html" %}
                {% endfor %}
            </div>
        {% endif %}
    </section>


    {% if profile.biography %}
        <hr class="clearfix" />
        <section class="full-content-wrapper without-margin article-content">
            <h2 id="biographie">{% trans "Biographie" %}</h2>
            {{ profile.biography|emarkdown }}
        </section>
    {% endif %}

    {% if stats_filename and perms.member.change_profile %}
        <hr class="clearfix" />
        <section class="full-content-wrapper without-margin">
            <h2 id="activity">{% trans "Activité" %}</h2>
            <figure>
                {% autoescape off %}
                    {{stats_filename}}
                {% endautoescape %}
            </figure>
        </section>
    {% endif %}


{% endblock %}



{% block sidebar_actions %}
    {% if user.is_authenticated %}
        {% if profile.user == user or perms.member.change_profile %}
            <div>
                {% if profile.user == user %}
                    <a href="{% url "update-member" %}" class="new-btn ico-after gear blue">
                        {% trans "Paramètres" %} <span class="wide">{% trans "de mon compte" %}</span>
                    </a>
                {% else %}
                    <a href="{% url "member.views.settings_mini_profile" profile.user.username %}" class="new-btn ico-after edit blue">
                        {% trans "Modifier le profil" %}
                    </a>
                {% endif %}
                {% if perms.member.super_user %}
                    <a href="{% url "member.views.settings_promote" profile.user.pk %}" class="new-btn ico-after edit gear blue">
                        {% trans "Promouvoir" %}
                    </a>
                {% endif %}
            </div>
        {% endif %}
        {% if perms.member.change_profile or usr != user %}
            <div class="mobile-menu-bloc mobile-all-links" data-title='{% trans "Actions" %}'>
                <h3>{% trans "Actions" %}</h3>
                <ul>
                    {% if usr != user and not profile.is_private %}
                        <li>
                            <a href="{% url 'mp-new' %}?username={{ usr.username }}" class="ico-after cite blue">
                                {% trans "Envoyer un message privé" %}
                            </a>
                        </li>
                    {% endif %}
                    {% if profile.is_private and not perms.member.change_profile %}
                        <li class="inactive mobile-menu-link">
                            <span>{% trans "Aucune action possible" %}</span>
                        </li>
                    {% endif %}
                </ul>
            </div>
        {% endif %}
    {% endif %}

    <div class="mobile-menu-bloc mobile-all-links" data-title='{% trans "Accès rapide" %}'>
        <h3>{% trans "Accès rapide" %}</h3>
        <ul>
            <li>
                <a href="#infos-generales">
                    {% trans "Informations générales" %}
                </a>
            </li>
            {% if profile.sign %}
                <li>
                    <a href="#signature">
                        {% trans "Signature" %}
                    </a>
                </li>
            {% endif %}
            {% if profile.biography %}
                <li>
                    <a href="#biographie">
                        {% trans "Biographie" %}
                    </a>
                </li>
            {% endif %}
        </ul>
    </div>


    {% if perms.member.change_profile and profile.user.is_active %}
        <div class="mobile-menu-bloc mobile-all-links" data-title='{% trans "Modération" %}'>
            <h3>{% trans "Modération" %}</h3>
            {% if not profile.is_private and usr != user %}
            <h4>{% trans "Sanctions" %}</h4>
            <ul>
                {% if profile.can_write_now %}
                    <li>
                        <a href="#ls-temp-{{ profile.pk }}" class="open-modal">
                            {% trans "Lecture seule temporaire" %}
                        </a>
                        <form action="{% url "member.views.modify_profile" profile.user.pk %}" method="post" id="ls-temp-{{ profile.pk }}" class="modal modal-big">
                            <p>
                                {% blocktrans %}
                                    Pour quelle raison souhaitez-vous mettre ce membre en lecture seule <em>temporairement</em> ?
                                {% endblocktrans %}
                            </p>
                            <input type="text" name="ls-text" class="expand" placeholder="Spam, Troll, etc.">
                            <input type="number" name="ls-jrs" class="expand" placeholder="Durée de la lecture seule, en jours" min="1">
                            {% csrf_token %}
                            <button type="submit" name="ls-temp">
                                {% trans "Confirmer" %}
                            </button>
                        </form>
                    </li>
                    <li>
                        <a href="#ls-{{ profile.pk }}" class="open-modal">
                            {% trans "Lecture seule" %}
                        </a>
                        <form action="{% url "member.views.modify_profile" profile.user.pk %}" method="post" id="ls-{{ profile.pk }}" class="modal modal-medium">
                            <p>
                                {% trans "Pour quelle raison souhaitez-vous mettre ce membre en lecture seule" %} ?
                            </p>
                            <input type="text" name="ls-text" class="expand" placeholder="Spam, Troll, etc.">
                            {% csrf_token %}
                            <button type="submit" name="ls">
                                {% trans "Confirmer" %}
                            </button>
                        </form>
                    </li>
                {% else %}
                    <li>
                        <a href="#ls-temp-{{ profile.pk }}" class="open-modal">
                            {% trans "Ôter la lecture seule" %}
                        </a>
                        <form action="{% url "member.views.modify_profile" profile.user.pk %}" method="post" id="ls-temp-{{ profile.pk }}" class="modal modal-medium">
                            <p>
                                {% blocktrans %}
                                Pour quelle raison souhaitez-vous <strong>lever la sanction</strong> de ce membre ?
                                {% endblocktrans %}
                            </p>
                            <input type="text" name="unls-text" class="expand" placeholder="Bonne actions ?">
                            {% csrf_token %}
                            <button type="submit" name="un-ls">
                                {% trans "Confirmer" %}
                            </button>
                        </form>
                    </li>
                {% endif %}

                {% if profile.can_read_now %}
                    <li>
                        <a href="#ban-temp-{{ profile.pk }}" class="open-modal">
                            {% trans "Bannir temporairement" %}
                        </a>
                        <form action="{% url "member.views.modify_profile" profile.user.pk %}" method="post" id="ban-temp-{{ profile.pk }}" class="modal modal-big">
                            <p>
                                {% blocktrans %}
                                    Pour quelle raison souhaitez-vous bannir ce membre <em>temporairement</em> ?
                                {% endblocktrans %}
                            </p>
                            <input type="text" name="ban-text" class="expand" placeholder="Spam, Troll, etc.">
                            <input type="number" name="ban-jrs" class="expand" placeholder="Durée du bannissement, en jours" min="1">
                            {% csrf_token %}
                            <button type="submit" name="ban-temp">
                                {% trans "Confirmer" %}
                            </button>
                        </form>
                    </li>
                    <li>
                        <a href="#ban-{{ profile.pk }}" class="open-modal">
                            {% trans "Bannir définitivement" %}
                        </a>
                        <form action="{% url "member.views.modify_profile" profile.user.pk %}" method="post" id="ban-{{ profile.pk }}" class="modal modal-small">
                            <p>
                                {% trans "Pour quelle raison souhaitez-vous bannir ce membre" %} ?
                            </p>
                            <input type="text" name="ban-text" class="expand" placeholder="Spam, Troll, etc.">
                            {% csrf_token %}
                            <button type="submit" name="ban">
                                {% trans "Confirmer" %}
                            </button>
                        </form>
                    </li>
                {% else %}
                    <li>
                        <a href="#unban-{{ profile.pk }}" class="open-modal">
                            {% trans "Ôter le bannissement" %}
                        </a>
                        <form action="{% url "member.views.modify_profile" profile.user.pk %}" method="post" id="unban-{{ profile.pk }}" class="modal modal-small">
                            <p>
                                {% trans "Pour quelle raison souhaitez vous lever la sanction de ce membre" %} ?
                            </p>
                            <input type="text" name="unban-text" class="expand" placeholder="Bonne action ?">
                            {% csrf_token %}
                            <button type="submit" name="un-ban">
                                {% trans "Confirmer" %}
                            </button>
                        </form>
                    </li>
                {% endif %}
            </ul>
            {% endif %}
        </div>
    {% endif %}
{% endblock %}
