{% extends "projector/project/detail.html" %}

{% load i18n %}
{% load pagination_tags %}
{% load sorting_tags %}
{% load guardian_tags %}

{% block col-single-extra %}

{% autosort team_list %}
{% autopaginate team_list %}

<div class="richtemplates-panel">
    <h5>{% trans "Projects' teams" %}</h5>
    <div class="richtemplates-panel-content">

        {% block teams-menu %}
        {% get_obj_perms request.user for project as "project_perms" %}

        <ul class="nav-inline">
            <li class="richbuttonset">
                <a class="button-link" href="{{ project.get_teams_url }}">{% trans "Teams" %}</a>
                {% if "can_add_team" in project_perms %}
                <a class="button-link" href="{{ project.get_teams_add_url }}">{% trans "Add team" %}</a>
                {% endif %}
            </li>
        </ul>
        {% endblock %}
        
        <table class="datatable">
            <thead class="datatable-thead">
                <tr class="datatable-thead-subheader">
                    <th>{% trans "Team" %}</th>
                    <th>{% anchor joined_at "Joined at" %}</th>
                    <th>{% trans "Permissions" %}</th>
                    <th>{% trans "Remove" %}</th>                    
                </tr>
            </thead>
            <tbody class="datatable-tbody">
                {% for team in team_list %}
                <tr class="{% cycle "odd" "even" %} hoverable">
                    <td>{{ team.group }}</td>
                    <td>{{ team.joined_at }}</td>
                    <td><a class="block-link" href="{{ team.get_absolute_url }}">{% trans "Manage" %}</a></td>
                    <td>
                        <a href="{{ team.get_delete_url }}"
                           class="block-link deletelink">{% trans "Delete" %}</a>
                    </td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
        
        {% paginate %}

</div>
</div>
{% endblock %}

