{% extends 'base.html' %}

{% block title %}{{ site_name }}: {{ gettext('Permissions') }}{% endblock title %}

{% block content %}
<div class="row">
  <div class="col-md-10 col-md-offset-1">
    {# TRANS: The header for a table listing the permissions you have in divisions. #}
    <h3>{% trans %}Your Permissions{% endtrans %}</h3>
    <table class="table">
      <tr>
        {# TRANS: A column header in a table with the name of a division. #}
        <th>{% trans %}Division{% endtrans %}</th>
        {# TRANS: A column header in a table that lists the permissions you have in a division (there can be multiple permissions in a row, separated by commas). #}
        <th>{% trans %}Permissions{% endtrans %}</th>
      </tr>
      {% for grouper, grouped in current_user.permissions|groupby('division.name') %}
      <tr>
        <td>{{ grouper }}</td>
        {% with grouped_permissions = grouped|map(attribute='permission')|groupby('value') %}
        <td>{{ grouped_permissions|map('last')|map('first')|map(attribute='description')|join(', ') }}</td>
        {% endwith %}
      </tr>
      {% endfor %}
    </table>
  </div>
</div>
{% endblock content %}
