{% extends 'users/_user.html' %}

{% block title %}User Key{% endblock %}

{% block usercontent %}
    {% if userkey %}
        <div class="pull-right">
            <a href="{% url 'user:userkey_edit' %}" class="btn btn-warning">
                <span class="fa fa-pencil" aria-hidden="true"></span>
                Edit user key
            </a>
        </div>
        <h4>
            Your user key is:
            {% if userkey.is_active %}
                <span class="label label-success">Active</span>
            {% else %}
                <span class="label label-danger">Inactive</span>
            {% endif %}
        </h4>
        {% include 'inc/created_updated.html' with obj=userkey %}
        {% if not userkey.is_active %}
            <div class="alert alert-warning" role="alert">
                <i class="fa fa-warning"></i>
                Your user key is inactive. Ask an administrator to enable it for you.
            </div>
        {% endif %}
        <pre>{{ userkey.public_key }}</pre>
        <hr />
        {% if userkey.session_key %}
            <div class="pull-right">
                <a href="{% url 'user:sessionkey_delete' %}" class="btn btn-danger">
                    <span class="fa fa-trash" aria-hidden="true"></span>
                    Delete session key
                </a>
            </div>
            <h4>Session key: <span class="label label-success">Active</span></h4>
            <small class="text-muted">Created {{ userkey.session_key.created }}</small>
        {% else %}
            <h4>No active session key</h4>
        {% endif %}
    {% else %}
        <p>You don't have a user key on file.</p>
        <p>
            <a href="{% url 'user:userkey_edit' %}" class="btn btn-primary">
                <span class="fa fa-plus" aria-hidden="true"></span>
                Create a User Key
            </a>
        </p>
    {% endif %}
{% endblock %}
