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

{% load i18n admin_tags %}

{% block title %}{% trans "Users" %}{% endblock %}

{% block breadcrumb %}
    <div class="col-sm-12 pl-0">
      <a href="{% url 'admin:users' %}">{% trans "Users" %}</a>
    </div><!-- /.col -->
{% endblock %}

{% block content %}
    <form id="changelist_form" action="{% url 'admin:users' %}" method="post">
      {% csrf_token %}
        <div class="col-12 p-3">
            <a href="{% url 'admin:user-add' %}" class="btn btn-success btn-flat" role="button">
              <i class='fa fa-plus'></i>
              {% trans "New" %}
            </a>
        </div>
        
        {% include "admin/_pagination.html" %}

        <div class="col-12 p-3">
          {% if object_list|length > 0 %}
            <table class="table table-striped">
              <thead>
                <tr class="text-uppercase">
                  <th class="border-top-0">
                    <div id="checkbox_view">
                      <span class="mr-2"><input type="checkbox" id="action_toggle"></span>{% trans "Username" %}
                    </div>
                  </th>
                  <th class="border-top-0">{% trans "Email Address" %}</th>
                  <th class="border-top-0">{% trans "Superuser Status" %}</th>
                  <th class="border-top-0">{% trans "Role" %}</th>
                  <th class="border-top-0">{% trans "Active Status" %}</th>
                  <th class="border-top-0">{% trans "Last Login" %}</th>
                </tr>
              </thead>
              <tbody>
                {% for obj in object_list %}
                  <tr>
                    <td><span class="mr-2"><input type="checkbox" name="_selected_action" value="{{ obj.pk }}" /></span><a href="{% url 'admin:user-update' obj.pk %}">{{ obj.username}}</a></td>
                    <td>{{ obj.email | default:'-' }}</td>
                    <td>
                      {% boolean_icon obj.is_superuser %}
                    </td>
                    <td>
                      {{ obj.role | default:'-'}}
                    </td>
                    <td>
                      {% boolean_icon obj.is_active %}
                    </td>
                    <td>
                      {% localized_datetime user.last_login %}
                    </td>
                  </tr>
                {% endfor %}
              </tbody>
            </table>
          {% else %}
            {% trans "No users defined so far" %}
          {% endif %}
      </div>
    </form>
{% endblock %}


{% block widgetsbar %}
  <div class="card">
    <div class="card-body">
      <ul class="collection">
        <li class="collection-item">
            <select form="changelist_form" name="action" class="custom-select" required="">
              <option value="" selected="">---------</option>
              <option value="delete_selected">{% trans "Delete selected users" %}</option>
            </select>
          
        </li>
        <li class="collection-item d-flex flex-row-reverse mt-3">
            <button form="changelist_form" class="btn btn-primary btn-flat mx-1" type="submit">
              <i class="fa fa-check"></i>
              {% trans "Apply" %}
            </button>
        </li>
      </ul>
    </div>
  </div>
{% endblock %}