{% extends 'site/base.html' %}
{% load i18n %}

{% block content %}
<main class="account">
    {% include 'site/fragment_messages.html' %}
    <h2>{% trans 'Your API secrets' %}</h2>

    <form method="post" action="{{ request.path_info }}" style="max-width: 100%;">
    {% csrf_token %}
    {% if api_secrets %}
    <table>
        <tr>
            <th>{% trans "Name" %}</th>
            <th>{% trans "Created" %}</th>
            <th>{% trans "Permissions" %}</th>
            <th>{% trans "Valid Until" %}</th>
            <th>{% trans "Delete" %}</th>
        </tr>
        {% for secret in api_secrets %}
        <tr>
            <td>{{ secret.name }}</td>
            <td>{{ secret.created }}</td>
            <td>
                {% for scope in secret.scopes_display %}
                    {% if forloop.counter0 != 0 %}<br>{% endif %}
                    {{ scope }}
                {% endfor %}
            </td>
            <td>
                {% if secret.valid_until %}{{ secret.valid_until }}{% endif %}
            </td>
            <td>
                <button type="submit" name="delete" value="{{ secret.pk }}">{% trans 'delete' %}</button>
            </td>
        </tr>
        {% endfor %}
    </table>
    {% endif %}
    </form>

    <a class="button" href="{% url 'site.api_secret_create' %}">{% trans 'Create API secret' %}</a>
</main>
{% endblock %}
