{% extends "base.html" %}
{% load teamwork_tags %}
{% block title %}{{ user.username }} | user detail{% endblock %}
{% block content %}
<article id="user">

    <h1><span>User:</span>
        <span class="name">{{ user.username }}</span>
        {% if user.is_superuser %}
            <span class="is_superuser">(Is superuser)</span>
        {% endif %}
    </h1>

    {% if roles_by_team %}
        <h2>Roles</h2>
        <ul class="teams">
            {% for team, roles in roles_by_team %}
                <li id="team-{{ team.id }}">
                    <a class="team" href="{% url "profiles.views.team_detail" team.name %}">{{ team }}</a>
                    <ul class="roles">
                        {% for r in roles %}
                        <li class="role" id="role-{{ r.role.id }}">
                            <form method="POST" action="">
                                <span class="name">{{ r.role }}</span>
                                {% csrf_token %}
                                <input type="hidden" name="role_id" value="{{ r.role.pk }}">
                                <input type="submit" value="{% if r.granted %}revoke{% else %}grant{% endif %}">
                            </form>
                        </li>
                        {% endfor %}
                    </ul>
                </li>
            {% endfor %}
        </ul>
    {% endif %}

</article>
{% endblock %}
