{% extends "kfet/base_col_2.html" %}

{% block title %}Groupes de comptes{% endblock %}
{% block header-title %}Groupes de comptes{% endblock %}

{% block fixed %}

<div class="buttons">
  <a class="btn btn-primary" href="{% url 'kfet.account.group.create' %}">
    <span class="glyphicon glyphicon-plus"></span><span>Créer un groupe</span>
  </a>
</div>

{% endblock %}

{% block main %}

{% for group in groups %}
<section>
  <div class="heading">
    {{ group.name }}
    <div class="buttons">
      <a class="btn btn-default" href="{% url 'kfet.account.group.update' group.pk %}">
        <span class="glyphicon glyphicon-cog"></span><span class="hidden-xs">Éditer</span>
      </a>
    </div>
  </div>
  <div>
    <h3>Comptes</h3>
    <div class="sub-block column-sm-2 column-md-3">
    <ul>
      {% for user in group.user_set.all %}
      <li>
        <a href="{% url "kfet.account.update" user.profile.account_kfet.trigramme %}">
          {{ user.profile.account_kfet }}
        </a>
      </li>
      {% endfor %}
    </ul>
    </div>
    <h3>Permissions</h3>
    <div class="column-sm-2 column-lg-3">
      {% regroup group.permissions.all by content_type as grouped_perms %}
      <ul class="list-unstyled">
        {% for perms_group in grouped_perms %}
        <li class="unbreakable">
          <b>{{ perms_group.grouper|title }}</b>
          <ul>
            {% for perm in perms_group.list %}
            <li>{{ perm.name }}</li>
            {% endfor %}
          </ul>
        </li>
        {% endfor %}
      </ul>
    </div>
  </div>
</section>
{% endfor %}

{% endblock %}
