{% load i18n sizeformat %}

<div class="detail">
  <div class="info detail">
    <h4>{% trans "Lease" %}</h4>
    <hr class="header_rule">
    <dl class="dl-horizontal">
      <dt>{% trans "Name" %}</dt>
      <dd>{{ lease.name|default:_("None") }}</dd>
      <dt>{% trans "Id" %}</dt>
      <dd>{{ lease.id|default:_("None") }}</dd>
      <dt>{% trans "Project Id" %}</dt>
      <dd>{{ lease.project_id|default:_("None") }}</dd>
      <dt>{% trans "Start date" %}</dt>
      <dd>{{ lease.start_date|parse_isotime|date:"Y-m-d H:i T"|default:"-" }}</dd>
      <dt>{% trans "End date" %}</dt>
      <dd>{{ lease.end_date|parse_isotime|date:"Y-m-d H:i T"|default:"-" }}</dd>
      <dt>{% trans "Action" %}</dt>
      <dd>{{ lease.action|default:"-" }}</dd>
      <dt>{% trans "Status" %}</dt>
      <dd>{{ lease.status|default:"-" }}</dd>
      <dt>{% trans "Status Reason" %}</dt>
      <dd>{{ lease.status_reason|default:"-" }}</dd>
    </dl>
  </div>

  <div class="info detail">
    <h4>{% trans "Events" %}</h4>
    <hr class="header_rule">
    <dl class="dl-horizontal">
    {% for event in lease.events %}
      <dt>{{ event.event_type }}</dt>
      <dd>
        <ul>
          <li><em>{% trans "Status:" %}</em>&nbsp;{{ event.status|replace_underscores|lower|capfirst }}</li>
          <li><em>{% trans "Time:" %}</em>&nbsp;{{ event.time|parse_isotime|date:"Y-m-d H:i T"|default:"-" }}</li>
        </ul>
      </dd>
      {% empty %}
      <dt>{% trans "No events defined." %}</dt>
    {% endfor %}
    </dl>
  </div>

  <div class="info detail">
    <h4>{% trans "Reservations" %}</h4>
    {% for reservation in lease.reservations %}
      <hr class="header_rule">
      <dl class="dl-horizontal">
        {% for key, value in reservation.items %}
          {% if 'ted_at' in key %}
            <dt>{{ key }}</dt>
            <dd>{{ value|parse_isotime|date:"Y-m-d H:i T"|default:"-" }}</dd>
          {% else %}
            <dt>{{ key }}</dt>
            <dd>{{ value }}</dd>
          {% endif %}
        {% endfor %}
      </dl>
    {% endfor %}
  </div>
</div>
