{% extends 'admin/master.html' %}
{% block body %}
  <h1>Access tokens</h1>

  <h3>Search</h3>
  <form method="GET" class="form-horizontal" role="form">
    <input id="input-value" name="value" class="form-control" autofocus
           placeholder="Value" {{ 'value='+value if value }}>
    <button type="submit" class="btn btn-default">Search</button>
  </form>

  {% if value %}
    <hr />
    {% if results %}
      <table class="table table-hover">
        <thead>
        <tr>
          <th>{# is_active #}</th>
          <th>Value</th>
          <th>Owner</th>
          <th>Created on</th>
        </tr>
        </thead>
        <tbody>
        {% for token in results %}
          <tr>
            <td>
              {% if token.is_active %}
                <span class="label label-success">active</span>
              {% else %}
                <span class="label label-danger">revoked</span>
              {% endif %}
            </td>
            <td>{{ token.value }}</td>
            <td>
              {% if token.owner_id %}
                <a href="{{ url_for('supportersview.details', supporter_id=token.owner_id) }}">{{ token.owner }}</a>
              {% endif %}
            </td>
            <td>{{ token.created }}</td>
          </tr>
        {% endfor %}
        </tbody>
      </table>
    {% else %}
      No tokens found.
    {% endif %}
  {% endif %}

{% endblock %}
