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

{% block page_title %}{% trans "Users" %}{% endblock page_title %}
{% block browser_title %}{% trans "Users" %}{% endblock browser_title %}

{% block content %}
    {% include "infrablue/snippets/pagination.html" %}
    <a href="{% url 'user_create' %}" class="btn waves-effect secondary-color">
        <i class="material-icons left">add</i> {% trans "Create" %}
    </a>
    <table class="striped highlight responsive-table">
        <thead>
            <th>{% trans "ID" %}</th>
            <th>{% trans "Name" %}</th>
            <th>{% trans "Username" %}</th>
            <th>{% trans "Groups" %}</th>
            <th class="actions">{% trans "Actions" %}</th>
        </thead>
        {% for obj in object_list %}
        <tr>
            <td>{{ obj.id }}</td>
            <td>{{ obj.get_full_name }}</td>
            <td>
                {{ obj.username }}
            </td>
            <td>
                <div class="collection">
                    {% for group in obj.groups.all %}
                        <a href="{% url "group_detail" group.id %}" class="collection-item">{{ group.name }}</a>
                        {% empty %}
                        <div class="collection-item">
                        {% blocktrans %}This user is currently not part of any group.{% endblocktrans %}
                        </div>
                    {% endfor %}
                </div>
            </td>
            <td>
                <div class="break-on-mobile">
                    <a class="btn-flat primary-color-text waves-effect" href="{% url "user_detail" obj.id %}">
                        <i class="material-icons left">pageview</i>{% trans "View Details" %}
                    </a>
                    <a class="btn-flat secondary-color-text waves-effect" href="{% url 'user_update' obj.id %}">
                        <i class="material-icons left">edit</i>{% trans "Edit" %}
                    </a>
                    <a class="btn-flat red-text waves-effect" href="{% url 'user_delete' obj.id %}">
                        <i class="material-icons left">delete</i>{% trans "Delete" %}
                    </a>
                    <a class="btn-flat primary-color-text waves-effect" href="{% url 'user_change_password' obj.id %}">
                        <i class="material-icons left">lock</i>{% trans "Change Password" %}
                    </a>
                </div>
            </td>
        </tr>
        {% empty %}
            <td>{% trans "No Users could be found" %}</td>
        {% endfor %}
    </table>
{% endblock %}
