{% extends "users_admin/base.html" %}
{% load i18n %}

{% block title %}Accueil{% endblock %}

{% block nav %}
 <li><a href="create">Créer un utilisateur</a></li>
{% endblock %}

{% block title_content %}
<h1>Liste des utilisateurs</h1>
{% endblock %}

{% block content %}

<form action="multiple" method="post">

<br />
<table class="table table-condensed table-striped" id="usersTable">
  <thead>
    <tr>
      <th class="type-string">login</th>
      <th class="type-string">actif?</th>
      <th class="type-string">expiration</th>
      <th class="type-string">nom complet</th>
      <th></th>
    </tr>
  </thead>
  <tbody>
	  {% for user in users.values|dictsort:"name" %}
	  <tr {% if user.disabled or user.ttl == 0 %} class="disabled"{% endif %}>
		  <td data-order-by="{{ user.name }}">
			  <a href="update/{{ user.name }}" {% if user.disabled or user.ttl == 0 %} class="disabled"{% endif %}>{{ user.name }}</a>
			  {% if 'univnautes-idp-multiple' in user.priv %} &mdash; multiple{% endif %}
			  {% if user.disabled %} &mdash; désactivé{% endif %}
			  {% if user.ttl == 0 %} &mdash; expiré{% endif %}
		  </td>
		  <td data-order-by="{% if user.disabled %}DIS{% elif user.ttl == 0 %}EXP{% else %}ACT{% endif %}">
			  {% if user.disabled %}<i class="icon-pause"></i>
			  {% elif user.ttl == 0 %}<i class="icon-stop"></i>
			  {% endif %}
		  </td>
		  <td data-order-by="{{ user.expires|date:"c"|default:"2999-12-31" }}">
			  {{ user.expires|default:"jamais" }}
			  {% if user.ttl > 0 %} ({{ user.ttl }} jour{% if user.ttl > 1 %}s{% endif %})
			  {% elif user.ttl == 0 %} &mdash; expiré{% endif %}
		  </td>
		  <td>{{ user.descr }}</td>
		  <td><input type="checkbox" name="users" value="{{ user.name }}" /></td>
	  </tr>
	  {% endfor %}
  </tbody>
</table>

<div class="form-actions">
<a href="create" class="btn">Créer un utilisateur</a>
<div class=" pull-right">
	<input type="submit" value="Ok" class="btn pull-right" />
	<select name="action" class="pull-right">
	  <option value="none" selected="selected">Choisir une action ...</option>
	  <option value="desactivate">Désactiver les utilisateurs choisis</option>
	  <option value="activate">Activer les utilisateurs choisis</option>
	  <option value="delete">Supprimer les utilisateurs choisis</option>
	</select>
</div>
</div>

{% csrf_token %}
</form>

<script src="{{ MEDIA_URL }}js/stupidtable.min.js"></script>
<script>
  $(function(){ $("#usersTable").stupidtable(); });
</script>

{% endblock %}
