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

{% block content %}



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

        {% endfor %}
    </ul>

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

    {% if structure.sbas_questions.all %}
        <h4>Related SBA Questions</h4>
        <ul>
            {% for q in structure.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 %}
