{% extends "layout_bs4.html" %}

{% block title %}
  {{ super() }} - Users
{% endblock %}

{% block top_nav %}
  {{ super() }}
  <li class="nav-item active">
    <span class="navbar-text">Users</span>
  </li>
{% endblock %}

{% block content_main %}
<div class="container-float">
  <div class="card panel-default">
    <div class="card-body">
      <table class="table table-bordered table-hover mt-3">
        <thead>
          <tr>
            <th>Name</th>
            <th>Email</th>
            <th>Institutes</th>
            <th>Rank</th>
          </tr>
        </thead>
        <tbody>
          {% for user in users %}
            <tr>
              <td>
                {{ user.name }}
                {% if 'admin' in user.roles %}
                  <span class="badge badge-info float-right">ADMIN</span>
                {% endif %}
              </td>
              <td>
                <a href="mailto:{{ user.email }}">{{ user.email }}</a>
              </td>
              <td>
                {% for institute in user.institutes %}
                  {{ institute.display_name }} <small>({{ institute._id }})</small><br>
                {% endfor %}
              </td>
              <td>
                <div class="float-left">
                  <strong>{{ user.events_rank|capitalize }}</strong><br>
                  <span class="text-muted">{{ user.events }} events</span>
                </div>
                <img class="rank-shield float-right" src="{{ url_for('login.static', filename=(user.events_rank + '.svg')) }}" alt="{{ user.events_rank }}">
              </td>
            </tr>
          {% endfor %}
        </tbody>
      </table>
    </div>
  </div>
</div>
{% endblock %}
