{% extends "base.html" %}

{% block title %}API token{% if token.description %}: {{ token.description }}{% endif %}{% endblock %}

{% block extra_head %}
<style type="text/css">
dt {
    font-weight: bold;
}
dd {
    margin-left: 2em;
}
</style>
{% endblock %}

{% block content %}

<h1>API token: {{ token.id }}</h1>
<p><a href=".">List all tokens</a></p>
<dl>
    {% if token.description %}
        <dt>Description</dt>
        <dd>{{ token.description }}</dd>
    {% endif %}
    <dt>Token status</dt>
    <dd>{{ token_status }}</dd>
    <dt>Actor</dt>
    <dd>{% if actor_display %}{{ actor_display }} ({{ token.actor_id }}){% else %}{{ token.actor_id }}{% endif %}</dd>
    <dt>Created</dt>
    <dd>{{ timestamp(token.created_timestamp) or "None" }}</dd>
    <dt>Last used</dt>
    <dd>{{ timestamp(token.last_used_timestamp) or "None" }}</dd>
    {% if token.expires_after_seconds %}<dt>Expires at</dt>
    <dd>{{ timestamp(token.created_timestamp + token.expires_after_seconds) }}</dd>{% endif %}
    <dt>Restrictions</dt>
    <dd><pre>{{ restrictions }}</pre></dd>
</dl>

{% if token_status == "Active" and can_revoke %}
<br>
<form action="" method="POST">
    <p>
        <input type="hidden" name="csrftoken" value="{{ csrftoken() }}">
        <input type="submit" name="revoke" value="Revoke this token">
    </p>
</form>
{% endif %}

{% endblock %}
