{% load i18n %}
{% load bootstrap3 %}

{% include 'editor/fragment_modal_close.html' %}
<h3>
    <i class="glyphicon glyphicon-user"></i> {{ user.username }}
</h3>
{% bootstrap_messages %}
{% if request.user == user %}
    <h4 class="text-success">{% trans "That's you!" %}</h4>
    {% if request.changeset.pk %}
        {% with changeset_title=changeset.title changeset_id=request.changeset.pk changeset_url=request.changeset.get_absolute_url %}
            <p>
                {% if changeset_title %}
                    {% blocktrans %}Your active change set is <a href="{{ changeset_url }}">{{ changeset_title }}</a>.{% endblocktrans %}
                {% else %}
                    {% blocktrans %}Your active change set is <a href="{{ changeset_url }}">#{{ changeset_id }} (untitled)</a>.{% endblocktrans %}
                {% endif %}
                <br>{% blocktrans %}Deactivate it if you want to create a new one.{% endblocktrans %}
            </p>
            <form method="post" action="{{ request.path }}">
                {% csrf_token %}
                <button type="submit" class="btn btn-xs btn-default" name="deactivate_changeset" value="1">{% trans 'Deactivate change set' %}</button>
            </form>
        {% endwith %}
    {% elif request.changeset.direct_editing %}
        <p>
            {% trans 'Direct editing is activated.' %}<br>
            {% trans 'Everything you do will be applied immediately.' %}
        </p>
        <form method="post" action="{{ request.path }}">
            {% csrf_token %}
            <p>
                <button type="submit" class="btn btn-xs btn-warning" name="direct_editing" value="0">{% trans 'Deactivate direct editing' %}</button>
            </p>
        </form>
    {% else %}
        <p>
            {% trans 'You have currently no active change set.' %}<br>
            {% trans 'Just edit something to create one.' %}
        </p>
        {% if can_direct_edit %}
            <form method="post" action="{{ request.path }}">
                {% csrf_token %}
                <p>
                    <button type="submit" class="btn btn-xs btn-warning" name="direct_editing" value="1">{% trans 'Activate direct editing' %}</button>
                </p>
            </form>
        {% endif %}
    {% endif %}
    {% if request.user == user %}
        <p>
            {% csrf_token %}
            <a class="btn btn-xs btn-default" href="{% url 'editor.change_password' %}">{% trans 'Change password' %}</a>
        </p>
    {% endif %}
{% endif %}

<h4>{% trans 'Recent change sets' %}</h4>
{% include 'editor/fragment_changesets.html' with changesets=recent_changesets %}

{% if can_review %}
    <h4>{% trans 'Change sets you are reviewing' %}</h4>
    {% include 'editor/fragment_changesets.html' with changesets=reviewing_changesets %}

    <h4>{% trans 'Change sets awaiting review' %}</h4>
    {% include 'editor/fragment_changesets.html' with changesets=to_review_changesets %}

    <h4>{% trans 'All recent change sets' %}</h4>
    {% include 'editor/fragment_changesets.html' with changesets=all_recent_changesets %}
{% endif %}


