{# vim: set ts=2 et sts=2 sw=2: #}
{% extends "wiki/base.html" %}
{% set title = _('Revision History | {document}')|fe(document=document.title) %}
{% block title %}{{ page_title(title) }}{% endblock %}
{% set crumbs = [(url('wiki.category', document.category), document.get_category_display()),
                 (document.get_absolute_url(), document.title),
                 (None, _('History'))] %}

{% block content %}
<section id="content">
  <div class="wrap">
    <div id="content-main" class="full">
  <article id="revision-history" role="main">
    <h1 class="title">{{ _('History of') }} <a href="{{ url('wiki.document', document.full_path, locale=document.locale) }}">{{ _('{title}')|fe(title=document.title) }}</a></h1>
    
    <div class="choice-list">
      <label>{{ _('Revision history for:') }}</label>
      <ul>
        {% if document.parent %}
          <li>
            <a href="{{ url('wiki.document_revisions', document.parent.full_path, locale=document.parent.locale) }}">{{ document.parent.language }}</a>
          </li>
        {% endif %}
        <li>
          <span>{{ document.language }}</span>
        </li>
      </ul>
    </div>
    <div id="revision-list">
      {% if revisions %}
        <form action="{{ url('wiki.compare_revisions', document.full_path) }}" method="get">
          {% if revisions | length %}
            <div class="compare top">
              <input type="submit" class="link-btn" value="{% if document.parent %}{{ _('Compare Selected Translations') }}{% else %}{{ _('Compare Selected Revisions') }}{% endif %}" />
            </div>
          {% endif %}
          {% set reached_current = False %}
          {% for rev in revisions %}
            {% if document.current_revision == rev %}
              {% set reached_current = True %}
            {% endif %}
            {% if loop.first %}<ul>{% endif %}
            <li class="{% if document.current_revision == rev %}current{% endif %}{% if rev.reviewed and not rev.is_approved %}rejected{% endif %}">
              <div class="radio">
                {% if not loop.first %}<input type="radio" name="from" value="{{ rev.id }}" {% if loop.index == 2 %}checked="checked"{% endif %} />{% endif %}
              </div>
              <div class="radio">
                {% if not loop.last %}<input type="radio" name="to" value="{{ rev.id }}" {% if loop.first %}checked="checked"{% endif %} />{% endif %}
              </div>
              <div class="date">
                <a href="{{ url('wiki.revision', document.full_path, rev.id) }}" rel="nofollow, noindex">{{ datetimeformat(rev.created, format='date') }}</a>
              </div>
              <div class="status">
                {% if document.current_revision.id == rev.id %}
                    <span class="current">{{ _('Current') }}</span>
                {% elif not rev.is_approved and not rev.reviewed %}
                    {% if not reached_current and user.has_perm('wiki.review_revision') %}
                      <a href="{{ url('wiki.review_revision', document.full_path, rev.id) }}">{{ _('Review') }}</a>
                    {% else %}
                      <span class="unreviewed">{{ _('Unreviewed', 'revision') }}</span>
                    {% endif %}
                {% elif rev.is_approved %}
                  <span class="approved">{{ _('Approved') }}</span>
                {% else %}
                    <span class="rejected">{{ _('Rejected') }}</span>
                {% endif %}
              </div>
              <div class="significance">
                {% if rev.significance == 20 %}
                  M
                {% elif rev.significance == 30 %}
                  MT
                {% else %}
                  &nbsp;
                {% endif %}
              </div>
              <div class="creator">
                {{ rev.creator }}
              </div>
              <div class="comment">
                {{ rev.comment }}
              </div>
              {% if document.current_revision != rev and user.has_perm('wiki.delete_revision') %}
                <div class="delete">
                  <a href="{{ url('wiki.delete_revision', document.full_path, rev.id) }}">{{ _('Delete') }}</a>
                </div>
              {% endif %}
            </li>
            {% if loop.last %}</ul>{% endif %}
          {% endfor %}
          {% if revisions | length %}
            <div class="compare bottom">
              <input type="submit" class="link-btn" value="{% if document.parent %}{{ _('Compare Selected Translations') }}{% else %}{{ _('Compare Selected Revisions') }}{% endif %}" />
            </div>
          {% endif %}
        </form>
      {% else %}
        {{ _('This document has no revisions.') }}
      {% endif %}
    </div>
  </article>
    </div>
   </div>
</section>
{% endblock %}

