{% extends 'base.html' %}

{% block top %}
  <p>
    utente che sta effettuando gli aggiornamenti {{ utenteautorizzato.mail }}@{{ utenteautorizzato.domain.nome }}
  </p>
  {% if dominio %}
    <p>
      Dominio su cui si sta' lavorando: {{ dominio.nome }}
    </p>
  {% endif %}
  {% if lista %}
    <p>
      si stanno effettuando aggiornamenti su: {{ lista.nome }}@{{ lista.domain.nome }}
    </p>
  {% endif %}
{% endblock %}

{% block body %}
  <form name='newdomain' method='post'>
    {% csrf_token %}
    {% if not 'LISTEEDIT' in securitylist %}
    <button class="btn btn-primary" type="submit" name='Nuova Lista' value="Nuova Lista">Nuova Lista</button>
    {% endif %}
  </form>
  <table class='table'>
    <thead>
      <tr>
        <th scope='col'>#</th>
        <th scope='col'>id</th>
        <th scope='col'>Nome</th>
        <th scope='col'>Abilitata</th>
      </tr>
    </thead>
    <tbody>
      <form name="listalist" method="POST">
      {% csrf_token %}
      {% for u in listelist %}
        <tr>
          <th scope='row'>{{ u.id }}</th>
          <td> {{ u.id }} </td>
          <td> {{ u.nome }}@{{ u.domain.nome }} </td>
          <td>{% if u.enabled %}*{% else %}-{% endif %}</td>

          <td><button class="btn btn-primary" type="submit" name='edit' value="{{ u.id }}"{% if not u.enabled %} disabled {% endif %}>Edit</button>
	      <button disabled class="btn btn-primary" type="submit" name="editAdmin" value="{{ u.id }}"{% if not u.enabled %} disabled {% endif %}>Edit Lista</button>
              <button class="btn {% if not u.enabled %} btn-secondary {% else %} btn-primary {% endif %}" type="submit" name='disable' value="{{ u.id }}" {% if not u.enabled %} disabled {% endif %}>Disable</button>
              <button class="btn {% if u.enabled %} btn-secondary {% else %} btn-primary {% endif %}" type="submit" name='enable' value="{{ u.id }}" {% if u.enabled %} disabled {% endif %}>Enable</button></td>
        </tr>
      {% endfor %}
      </form>
    </tbody>
{% endblock %}

