{% extends "permissions.html" %}
{% block content %}
{{ super() }}
<div class="row">
  <div class="col-md-10 col-md-offset-1">
    <h3>Administer Divisions</h3>
    <table class="table table-condensed">
      <tr>
        <th>Division Name</th>
        <th>Submitters</th>
        <th>Reviewers</th>
        <th>Payers</th>
        <th>Auditors</th>
        <th>Admins</th>
      </tr>
      {% if divisions %}
      {% for division in divisions %}
      <tr>
        <td><a href="{{ url_for('divisions.get_division_details', division_id=division.id) }}">{{ division.name }}</a></td>
        {% for perm in (PermissionType.submit, PermissionType.review, PermissionType.pay,  PermissionType.audit, PermissionType.admin) %}
        <td><a href="{{ url_for('divisions.get_division_details', division_id=division.id) }}#{{ perm.value }}">{{ division.permissions[perm]|length }}</a></td>
        {% endfor %}
      </tr>
      {% endfor %}
      {% endif %}
    </table>
    {% if current_user.admin %}
    <a class="btn btn-primary" href="{{ url_for('divisions.add_division') }}">Add Division</a>
    {% endif %}
  </div>
</div>
{% endblock content %}
