{% extends "core/base.jinja" %}
{% from "core/macros.jinja" import select_all_checkbox %}

{% block title %}
  {% trans %}Group detail{% endtrans %}
{% endblock title %}

{% block content %}
  <h1>{{ object }}</h1>
  <p><a href="{{ url('core:group_list') }}">{% trans %}Back to list{% endtrans %}</a></p>
  {% if form.users_removed | length <= 0 %}
    <p>{% trans %}No user in this group{% endtrans %}</p>
  {% else %}
    <form action="{{ url('core:group_detail', object.id) }}" method="post" id="add_users">
      {{ select_all_checkbox("add_users") }}
      <hr>
      {% csrf_token %}
      {{ form.non_field_errors() }}
      <label for="{{ form.users_removed.id_for_label }}">{{ form.users_removed.label }} :</label>
      {{ form.users_removed.errors }}
      {% for user in form.users_removed %}
        <label for="{{ user.id_for_label }}">
          {{ user.tag() }}
          <a href="{{ url('core:user_profile', user.data.value) }}">{{ user.choice_label }}</a>
        </label>
      {% endfor %}
      <input type="submit" name="submit" value="{% trans %}Delete{% endtrans %}">
    </form>
  {% endif %}
  <form action="{{ url('core:group_detail', object.id) }}" method="post" id="add_users">
    {% csrf_token %}
    <p>
      {{ form.users_added.errors }}
      <label for="{{ form.users_added.id_for_label }}">{{ form.users_added.label }} :</label>
      {{ form.users_added }}
      <span class="helptext">{{ form.users_added.help_text }}</span>
    </p>
    <input type="submit" name="submit">
  </form>
{% endblock content %}