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

{% block content %}
    <h2>Users</h2>
    <details class="filter">
        <summary>
            Filter users list
        </summary>
        <form method="get">
            {{ filter.form.as_p }}
            <input type="submit" />
        </form>
    </details>
    {{object_list|length}} Users shown.
    <ul id="user-list">
        {% for list_user in object_list %}
            <li><span class="username">Username: <a href="{% url 'account_profile' list_user.username %}">{{ list_user.username }}</a></span>
                <span class="name">Name: {{list_user.first_name}} {{list_user.last_name}}</span>
                {% if list_user.userprofile.grade %}<span class="grade">Grade: {{list_user.userprofile.grade}}</span>{% endif %} Supervisor: {{list_user.userprofile.supervisor}}
                <br/> Registration number: {{list_user.userprofile.registration_number}}
            <button class="small-url-button"><a href="{% url 'account_update' list_user.username %}">Edit user</a></button>
            <button class="small-url-button"><a href="{% url 'account_profile_update' list_user.username %}">Edit profile</a></button>

            {% if user.is_superuser %}
                <button class="small-url-button"><a href="{% url 'admin:auth_user_change' list_user.id %}">Admin edit</a></button>
                <button class="small-url-button"><a href="{% url 'admin:auth_user_delete' list_user.id %}">Delete</a></button>
            {% endif %}
            </li>
        {% endfor %}
    </ul>

    <a href="{% url 'accounts_bulk_create' %}">Bulk create users</a>
    <a href="{% url 'create_user' %}">Create single user</a>

{% endblock %}


{% block css %}
    
<style>
    #user-list .name, #user-list .grade {
        padding-left: 50px;
    }
</style>

{% endblock css %}
    