{% load i18n %}
<div class="margin-top20">
    <div class="info-item heading"><strong>{% trans "REVISION HISTORY" %}</strong></div>
    <select id="id_select_revisions" class="select-revision">
        {% for history in history_list %}
            {% if forloop.first %}
                <option value="{% url 'publisher:publisher_course_revision' course.id history.history_id %}">
                    {% blocktrans with history.history_date|date:'d-m-Y' as history_date and history.changed_by as changed_by trimmed %}
                        {{ history_date }}&nbsp;by&nbsp;{{ changed_by}} (Latest)
                    {% endblocktrans %}
                </option>
            {% else %}
                {% url 'publisher:api:course_revisions' history.history_id as revision_url  %}
                {% url 'publisher:publisher_course_revision' course.id history.history_id as course_revision_url %}
                {% url 'publisher:api:course_revision_revert' history.history_id as revision_revert_url %}
                {% url 'publisher:publisher_courses_edit' pk=object.id  as revision_id_url %}
                {% url 'publisher:api:accept_all_revision' history.history_id as accept_revision_url %}
                <option data-revision-url="{{ revision_url }}"
                        value="{{ course_revision_url }}"
                        data-revert-url="{{ revision_revert_url }}"
                        data-revision-id="{{ revision_id_url }}?history_id={{ history.history_id }}"
                        data-reversion-value="{{ history.history_id }}"
                        data-accept-revision="{{ accept_revision_url }}" >
                    {% blocktrans with history.history_date|date:'d-m-Y' as history_date and history.changed_by as changed_by trimmed %}
                        {{ history_date }}&nbsp;by&nbsp;{{ changed_by}}
                    {% endblocktrans %}
                </option>
            {% endif %}
        {% endfor %}
    </select>
    <br>

    {% if can_edit %}
        <span id="span_revert_revision" class="hidden">
            <a id="id_revert_revision" class="btn btn-brand btn-small btn-courserun-add btn-revision">{% trans "Restore to this version" %}</a>
        </span>
        <div id="RevertRevisionAlert" class="alert alert-error hidden" role="alert">{% trans "Unable to revert the revision, Please try again later." %}</div>
        {% if accept_all_button %}
            <a id="btn_accept_revision" type="button" data-most-recent-revision-id="{{ most_recent_revision_id }}" class="hidden btn btn-brand btn-small btn-courserun-add btn-revision">
                {% trans "Accept All" %}
            </a>
        {% endif %}
    {% endif %}
</div>

{% include 'publisher/_revert_confirmation.html' %}
