{% extends 'layouts/base.html' %}
{% load i18n %}
{% load static %}

{% block content %}
  {% include 'header.html' %}
  <main id="main-content">
    {% include 'partials/notifications/notifications_block.html' %}
    <section>
      <div>
        {% include 'partials/ooi_head.html' with ooi=ooi view='scan_profile_detail' %}
        <h1 rf-selector="clearance-header">{% translate 'Clearance level' %}: {{ ooi.scan_profile.human_readable }}, {{ ooi.scan_profile.scan_profile_type }}</h1>
        {% if ooi.scan_profile.scan_profile_type == 'declared' %}
          <h2>{% translate 'Declared' %}</h2>
          <p>
            {% blocktranslate with scan_level=ooi.scan_profile.human_readable %}
              This means that this object will be scanned by Boefjes with scan level
              {{ scan_level }} and lower. Setting the clearance level from “declared”
              to “inherit” means that this object will inherit its level from neighbouring
              objects. This means that the clearance level might stay the same, increase,
              or decrease depending on other declared clearance levels. Clearance levels
              of objects that inherit from this clearance level will also be recalculated.
            {% endblocktranslate %}
          </p>
          <div class="horizontal-view">
            <a href="{% ooi_url 'scan_profile_reset' ooi.reference %}&{% include 'partials/elements/href_querystring_from_list.html' with list=mandatory_fields %}"
               class="button">{% translate 'Set clearance level to inherit' %}</a>
          </div>
        {% elif ooi.scan_profile.scan_profile_type == 'empty' %}
          <h2>{% translate 'Empty' %}</h2>
          <p>
            {% blocktranslate %}
                Objects with a clearance level higher than "L0" will be scanned automatically by Boefjes with
                corresponding scan levels. This object has a clearance level of "L0".
                This means that this object will not be scanned by any Boefje until that
                Boefje is run manually for this object again.
            {% endblocktranslate %}
          </p>
        {% elif ooi.scan_profile.scan_profile_type == 'inherited' %}
          <h2>{% translate 'Inherited' %}</h2>
          <div class="horizontal-scroll">
            <table>
              <thead>
                <tr>
                  <th>{% translate 'Scan level' %}</th>
                  <th>{% translate 'Inherited from' %}</th>
                  <th>{% translate 'Inheritance source' %}</th>
                  <th>{% translate 'Inheritance depth' %}</th>
                </tr>
              </thead>
              <tbody>
                {% for inheritance in ooi.scan_profile.inheritances %}
                  <tr>
                    <td>{{ inheritance.human_readable }}</td>
                    <td>
                      <a href="{% ooi_url 'scan_profile_detail' inheritance.parent %}"> {{ inheritance.parent.class_ }}: {{ inheritance.parent.human_readable }} </a>
                    </td>
                    <td>
                      <a href="{% ooi_url 'scan_profile_detail' inheritance.source %}">{{ inheritance.source.class_ }}: {{ inheritance.source.human_readable }}</a>
                    </td>
                    <td>{{ inheritance.depth }}</td>
                  {% endfor %}
                </tr>
              </tbody>
            </table>
          </div>
        {% endif %}
        <form novalidate
              action="{% ooi_url 'scan_profile_detail' ooi.primary_key %}"
              method="post"
              class="horizontal-view help">
          {% csrf_token %}
          {% translate 'Set clearance level' as fieldset_legend %}
          {% include 'partials/form/fieldset.html' with legend=fieldset_legend fields=form %}
          <button type="submit">{% translate 'Set clearance level' %}</button>
        </form>
      </div>
    </section>
  </main>
{% endblock content %}
