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

{% block content %}
<main class="account">
    {% include 'site/fragment_messages.html' %}
    <h2>{% trans 'Position:' %} {{ position.name }}</h2>
    <p><a href="{% url 'site.position_list' %}">&laquo; {% trans 'back to overview' %}</a></p>

    {% if position.coordinates %}
        {% include 'site/fragment_location.html' with location=position.coordinates %}
    {% else %}
        <p><em>{% trans 'currently no coordinates' %}</em></p>
    {% endif %}
    <p><em>{% trans 'last coordinates update:' %} {{ position.last_coordinates_update }}</em></p>

    <p>
        <strong>{% trans 'Secret' %}:</strong>
        <code>{{ position.secret }}</code>
    </p>

    <hr>
    <h4>{% trans 'How to manage' %}</h4>
    <p>
        {% trans 'To set this position, click on any point in the c3nav UI and click "set my position".' %}
        {% trans 'To unset your position, just come here or set the timeout appropriately.' %}
    </p>
    <p>
        {% trans 'We only keep your last position, we do not save any position history.' %}
    </p>
    <p>
        {% trans 'To access this position on the map, visit:' %}<br>
        <code><a href="/l/p:{{ position.secret }}/">/l/p:{{ position.secret }}/</a></code>
    </p>
    <p>
        {% trans 'To get and set it via the API, use this API endpoint:' %}<br>
        <code>{% url 'api-v2:position-update' position_id=position.slug %}</code>
        <a href="{% url 'api-v2:openapi-view' %}">({% trans 'View OpenAPI documentation' %})</a><br>
    </p>

    <hr>

    <form method="post" action="{{ request.path_info }}">
        {% csrf_token %}
        {{ form.as_p }}
        <label><input type="checkbox" name="set_null" value="1"> {% trans 'unset coordinates' %}</label>
        <label><input type="checkbox" name="reset_secret" value="1"> {% trans 'reset secret' %}</label>
        <label><input type="checkbox" name="delete" value="1"> {% trans 'delete this position' %}</label>
        <button type="submit">{% trans 'Update position' %}</button>
    </form>
</main>
{% endblock %}
