{% extends 'atlas/base.html' %}

{% block content %}

    <div class="floating-header">
        <a href="{% url 'atlas:finding_update' pk=finding.pk %}" title="Edit the Finding">Edit</a>
        <a href="{% url 'atlas:finding_delete' pk=finding.pk %}" title="Delete the Finding">Delete</a>
        {% if request.user.is_superuser %}
            <a href="{% url 'admin:atlas_finding_change' finding.id %}"
               title="Edit the Finding using the admin interface">Admin Edit</a>
        {% endif %}
    </div>
    <div>
        <h3>Name: {{finding.name}}</h3>
        Primary name: {% if finding.canonical %}No (alias of <a href="{{ finding.canonical.get_absolute_url }}">{{ finding.canonical.name }}</a>){% else %}Yes{% endif %}<br />
        Synonyms: {{ finding.get_synonym_link|safe }}<br />
    </div>
    {% if finding.seriesfinding_set.all %}
        <h4>Associated Cases</h4>
        <ul>
            {% for finding_set in finding.seriesfinding_set.all %}
                {% for case in finding_set.series.case.all %}
                    <li> Case: {{case.get_link}} / Series: {{finding_set.series.get_thumbnail_link}}</li>
                {% endfor %}
            {% endfor %}

        </ul>
    {% endif %}

    {# Also include cases referenced via CaseDisplaySet that list this finding #}
    {% if finding.casedisplayset_set.all %}
        <h4>Cases via Display Sets</h4>
        <ul>
            {% for ds in finding.casedisplayset_set.all %}
                <li>Case: {{ ds.case.get_link }} (Display set: {{ ds.name }})</li>
            {% endfor %}
        </ul>
    {% endif %}

    {% if finding.sbas_questions.all %}
        <h4>Related SBA Questions</h4>
        <ul>
            {% for q in finding.sbas_questions.all %}
                <li><a href="{{ q.get_absolute_url }}">{% if q.title %}{{ q.title }}{% else %}{{ q.get_stem_stripped|truncatechars:140 }}{% endif %}</a></li>
            {% endfor %}
        </ul>
    {% endif %}

{% endblock %}

{% block js %}

{% endblock %}
