{% extends "revision/read_base.html" %}

{% set pkg = c.pkg %}
{% set group = c.group %}

{% block subtitle %}{{ _('Differences')}}{% endblock %}

{% block breadcrumb_content %}
  {% if c.diff_entity == 'package' %}
    {% set dataset = pkg.title or pkg.name %}
    <li>{% link_for _('Datasets'), controller='package', action='search', highlight_actions = 'new index' %}</li>
    <li>{% link_for dataset, controller='package', action='read', id=pkg.name %}</li>
    <li class="active"><a href="" title="{{ _('Revision Differences') }}">{{ _('Revision Differences') }}</a></li>
  {% elif c.diff_entity == 'group' %}
    {% set group = group.display_name or group.name %}
    <li>{% link_for _('Groups'), controller='group', action='index' %}</li>
    <li>{% link_for group, controller='group', action='read', id=group.name %}</li>
    <li class="active"><a href="" title="{{ _('Revision Differences') }}">{{ _('Revision Differences') }}</a></li>
  {% endif %}
{% endblock %}

{% block primary_content_inner %}
  <h1>{{ _('Revision Differences') }} -
    {% if c.diff_entity == 'package' %}
      {% link_for pkg.title, controller='package', action='read', id=pkg.name %}
    {% elif c.diff_entity == 'group' %}
      {% link_for group.display_name, controller='group', action='read', id=group.name %}
    {% endif %}
  </h1>

  <p>
    <strong>From:</strong> {% link_for c.revision_from.id, controller='revision', action='read', id=c.revision_from.id %} -
      {{ h.render_datetime(c.revision_from.timestamp, with_hours=True) }}
  </p>
  <p>
    <strong>To:</strong> {% link_for c.revision_to.id, controller='revision', action='read', id=c.revision_to.id %} -
      {{ h.render_datetime(c.revision_to.timestamp, with_hours=True) }}
  </p>

  {% if c.diff %}
    <table class="table table-bordered table-striped">
      <tr>
        <th>{{ _('Field') }}</th>
        <th>{{ _('Difference') }}</th>
      </tr>
      {% for field, diff in c.diff %}
        <tr>
          <td>{{ field }}</td>
          <td><pre>{{ diff }}</pre></td>
        </tr>
      {% endfor %}
    </table>
  {% else %}
    <h3>{{ _('No Differences') }}</h3>
  {% endif %}
{% endblock %}
