{% extends "base.html" %}

{% load i18n %}
{% load staticfiles %}
{% load tags %}

{% block title %}{% trans "Groups" %} – {{ block.super }}{% endblock %}

{% block header %}
    <link href="{% static 'styles/dataTables/dataTables.bootstrap.css' %}" type="text/css" rel="stylesheet">
{% endblock %}

{% block javascript %}
    <script src="{% static 'javascript/jquery.dataTables.min.js' %}" type="text/javascript"></script>
    <script src="{% static 'javascript/dataTables.bootstrap.js' %}" type="text/javascript"></script>
{% endblock %}

{% block content %}
    <h1>
        {% trans "Groups" %}
        <small class="pull-right">
        <a href="{% url 'user_group_new' %}" class="btn btn-mini btn-primary" rel="tooltip" data-original-title="{% trans 'New group' %}"><i class="icon-plus icon-white"></i> {% trans "New" %}</a>
        <a href="{% url 'user_overview' %}" class="btn btn-mini"><i class="icon-chevron-left"></i> {% trans "Back to participants overview" %}</a>
        </small>
    </h1>

    <table id="dataTable" class="table table-striped table-bordered">
    <thead>
        <tr>
            <th class="mini_width">{% trans "ID" %}</th>
            <th>{% trans "Group" %}</th>
            <th>{% trans "Members" %}</th>
            <th class="mini_width">{% trans "Actions" %}</th>
        </tr>
    </thead>
    {% for group in groups %}
        <tr class="{% if group.is_active_slide %}activeline{% endif %}">
            <td class="nobr">{{ group.pk }}
            {% if group.pk == 1 or group.pk == 2 %}
                <a title="{% blocktrans %}The groups 1 ('Anonymous') and 2 ('Registered') are fixed default groups which can not be deleted. Each created or imported participant is a member of group 2. Use custom groups to set additional permissions for a subset of participants.{% endblocktrans %}"><i class="icon-info-sign"></i></a>
            {% endif %}
            </td>
            <td>
                <a href="{{ group|absolute_url }}">{% trans group.name %}</a>
            </td>
            <td>
                <span class="badge badge-info">{{ group.user_set.all.count }}</span>
            </td>
            <td>
                <span style="width: 1px; white-space: nowrap;">
                    {% if perms.projector.can_manage_projector %}
                        <a href="{{ group|absolute_url:'projector' }}"
                            class="activate_link btn {% if group.is_active_slide %}btn-primary{% endif %} btn-mini"
                            rel="tooltip" data-original-title="{% trans 'Show group' %}">
                            <i class="icon-facetime-video {% if group.is_active_slide %}icon-white{% endif %}"></i>
                        </a>
                    {% endif %}
                    <a href="{% url 'user_group_edit' group.id %}" title="{% trans 'Edit' %}" class="btn btn-mini">
                        <i class="icon-pencil"></i>
                    </a>
                    {% if group.pk != 1 and group.pk != 2 %}
                    <a href="{% url 'user_group_delete' group.id %}" title="{% trans 'Delete' %}" class="btn btn-mini">
                        <i class="icon-remove"></i>
                    </a>
                    {% endif %}
                </span>
            </td>
        </tr>
    {% endfor %}
    </table>
{% endblock %}
