{% extends "base/base.html" %}
{% import "widgets/user.html" as widget_member %}

{% block title %}
<h1>Profil de {{ member.name }}</h1>
{% endblock %}

{% block content %}
<section>
  <div style="display:flex;flex-wrap:wrap;align-items:center;">
    <div>
      {{ widget_member.profile(member) }}
      {% if current_user.is_authenticated %}
        {% if current_user == member %}
          <div><a href="{{ url_for('edit_account') }}">Modifier le compte</a></div>
        {% elif current_user.priv('edit.accounts') %}
          <div><a href="{{ url_for('adm_edit_account', user_id=member.id) }}">Modifier le compte</a></div>
        {% endif %}
      {% endif %}
    </div>
    <div style="padding:30px;">
      <div style="font-size:115%;font-style:italic;margin-bottom:15px;">
        {{ member.signature|md }}
      </div>
      <div>
        Membre depuis le {{ member.register_date|date('%Y-%m-%d') }}
      </div>
    </div>
  </div>

  <h2>Présentation</h2>
  <div>
    {{ member.bio|md }}
  </div>

  <h2>Groupes</h2>
  <div>
    <ul>
    {% for g in member.groups %}
      <li><a href="{# url_for('group', group=g.name) #}">{{ g.name }}</a></li>
    {% endfor %}
    </ul>
  </div>

  <h2>Trophées</h2>
  <div class="trophies">
  {% for t in trophies if t in member.trophies or t.hidden == False %}
    <div class="trophy {{ '' if t in member.trophies else 'disabled' }}">
      <img src="{{ url_for('static', filename='images/trophies/'+slugify(t.name))+'.png' }}">
      <div>
        <em>{{ t.name }}</em>
        <span>{{ t.description }}</span>
      </div>
    </div>
  {% endfor %}
  </div>

  <h2>Programmes</h2>
  <div>
    Ici y'aura les programmes
  </div>

  <h2>Topics</h2>
  <div>
    <table style="width:100%;">
      <tr>
        <th>Titre</th>
        <th>Forum</th>
        <th>Création</th>
      </tr>
    {% for t in member.topics() %}
      <tr>
        <td><a href="{{ url_for('forum_topic', f=t.forum, page=(t, 1)) }}">{{ t.title }}</a></td>
        <td><a href="{{ url_for('forum_page', f=t.forum) }}">{{ t.forum.name }}</a></td>
        <td>Le {{ t.date_created|date }}</td>
      </tr>
    {% endfor %}
    </table>
  </div>
</section>
{% endblock %}
