{% load i18n %}

<div class="horizontal-scroll">
  <h2>{% translate 'Related objects' %}</h2>
  {% if not related %}
    <p>
      {% translate 'No related objects added to ' %} {{ ooi.get_ooi_type }}.
      <br>
      {% translate 'Use the button below to add a related object. ' %}
    </p>
  {% endif %}
  {% if not ooi_past_due %}
    {% if not ooi|is_finding and not ooi|is_finding_type %}
      <div class="horizontal-view {% if related %}toolbar{% endif %}">
        <a href="{% ooi_url 'ooi_add_related' ooi.primary_key %}"
           class="button ghost">Add</a>
      </div>
    {% endif %}
  {% endif %}

  {% if related %}
    <table>
      <thead>
        <tr>
          <th>{% translate 'Name' %}</th>
          <th>{% translate 'Type' %}</th>
        </tr>
      </thead>
      <tbody>
        {% for related_ooi in related %}
          <tr>
            <td>
              <a href="{% ooi_url 'ooi_detail' related_ooi.reference %}">{{ related_ooi.reference.human_readable }}</a>
            </td>
            <td>{{ related_ooi.name }}</td>
          </tr>
        {% endfor %}
      </tbody>
    </table>
  {% endif %}
</div>
