{% load i18n sizeformat parse_date %}

<div class="detail">
  <dl class="dl-horizontal">
    <dt>{% trans "Name" %}</dt>
    <dd data-display="{{ backup.name|default:backup.id }}">{{ backup.name }}</dd>
    <dt>{% trans "ID" %}</dt>
    <dd>{{ backup.id }}</dd>
    {% if backup.description %}
    <dt>{% trans "Description" %}</dt>
    <dd>{{ backup.description }}</dd>
    {% endif %}
    <dt>{% trans "Status" %}</dt>
    <dd>{{ backup.status|capfirst }}</dd>
    {% if backup.status == 'error' %}
    <dt>{%trans "Fail reason"%}</dt>
    <dd>{{ backup.fail_reason }} <dd>
    {% endif %}
    <dt>{% trans "Availability Zone" %}</dt>
    <dd>{{ backup.availability_zone }}</dd>
    {% if volume %}
    <dt>{% trans "Volume" %}</dt>
    <dd>
      <a href="{% url 'horizon:project:volumes:detail' backup.volume_id %}">
        {{ volume.name }}
      </a>
    </dd>
    {% endif %}
    {% if backup.snapshot_id %}
    <dt>{% trans "Snapshot" %}</dt>
    {% if snapshot %}
    <dd>
     <a href="{% url 'horizon:project:snapshots:detail' backup.snapshot_id %}">
        {{ snapshot.name }}
     </a>
    </dd>
    {% elif backup.snapshot_id %}
    <dd>
    {{ backup.snapshot_id }}
    {% endif %}
    </dd>
    {% endif %}
  </dl>

  <h4>{% trans "Specs" %}</h4>
  <hr class="header_rule">
  <dl class="dl-horizontal">
    <dt>{% trans "Size" %}</dt>
    <dd>{{ backup.size }} {% trans "GB" %}</dd>
    <dt>{% trans "Created" %}</dt>
    <dd>{{ backup.created_at|parse_date }}</dd>
  </dl>

  <h4>{% trans "Metadata" %}</h4>
  <hr class="header_rule">
  <dl class="dl-horizontal">
  {% for key, value in backup.metadata.items %}
    <dt>{{ key }}</dt>
    <dd>{{ value }}</dd>
  {% endfor %}
  </dl>
</div>
