{% load i18n %}
{% load ooi_extra %}

{% spaceless %}
  <div class="horizontal-scroll">
    <h2>{% translate 'Findings' %}</h2>
    <div class="horizontal-view toolbar">
      {% if not ooi|is_finding and not ooi|is_finding_type %}
        <a href="{% ooi_url 'finding_add' ooi.primary_key %}" class="button">{% translate 'Add finding' %}</a>
      {% endif %}
    </div>
    <table>
      <caption>
        {% translate 'Overview of findings for ' %} {{ ooi.get_ooi_type }} "{{ ooi.name }}".
      </caption>
      <thead>
        <th>{% translate 'Severity' %}</th>
        <th>{% translate 'Score' %}</th>
        <th>{% translate 'Description' %}</th>
        <th>{% translate 'Finding details' %}</th>
      </thead>
      <tbody>
        {% for finding in findings %}
          <tr {% if not finding.risk_level_source %} class="warning"{% endif %}>
            {% if not ooi|is_finding_type %}
              <td>
                <span class="{{ finding.risk_level_severity }}">{{ finding.risk_level_severity }}</span>
              </td>
              <td>
                {{ finding.risk_level_score }}
                {% if not finding.risk_level_source %}
                  <span>({% translate 'marked "critical" because of unknown score' %})</span>
                {% endif %}
              </td>
              <td>{{ finding.description }}</td>
            {% endif %}
            <td>
              <a href="{% ooi_url 'ooi_detail' finding.id query=mandatory_fields %}">{{ finding.human_readable }}</a>
            </td>
          </tr>
        {% endfor %}
      </tbody>
    </table>
  </div>
{% endspaceless %}
