
{% extends 'generic/object.html' %}
{% load render_table from django_tables2 %}


{% block content %}
  <div class="row mb-3">
    <div class="col col-md-6">
      <div class="card">
        <h5 class="card-header">NetBox Sitemap Plugin</h5>
          <table class="table table-hover attr-table">
            <tr>
              <th scope="row">Name</th>
              <td>{{ object.name }}</td>
            </tr>
            <tr>
              <th scope="row">Regions</th>
              <td>
                {% if object.regions.all|length > 1 %}
                  {% for region in object.regions.all %}
                    {% if forloop.last %}
                      <a href="{{ region.get_absolute_url }}">{{ region.name }}</a>
                    {% else %}
                      <a href="{{ region.get_absolute_url }}">{{ region.name }}</a>, 
                    {% endif %}
                  {% endfor %}
                {% else %}
                  {{ object.regions.get|linkify|placeholder }}
                {% endif %}
              </td>
            </tr>
            <tr>
              <th scope="row">Site Groups</th>
              <td>
                {% if object.site_groups.all|length > 1 %}
                  {% for site_group in object.site_groups.all %}
                    {% if forloop.last %}
                      <a href="{{ site_group.get_absolute_url }}">{{ site_group.name }}</a>
                    {% else %}
                      <a href="{{ site_group.get_absolute_url }}">{{ site_group.name }}</a>, 
                    {% endif %}
                  {% endfor %}
                {% else %}
                  {{ object.site_groups.get|linkify|placeholder }}
                {% endif %}
              </td>
            </tr>
            <tr>
              <th scope="row">Sites</th>
              <td>
                {% if object.sites.all|length > 1 %}
                  {% for site in object.sites.all %}
                    {% if forloop.last %}
                      <a href="{{ site.get_absolute_url }}">{{ site.name }}</a>
                    {% else %}
                      <a href="{{ site.get_absolute_url }}">{{ site.name }}</a>, 
                    {% endif %}
                  {% endfor %}
                {% else %}
                  {{ object.sites.get|linkify|placeholder }}
                {% endif %}
              </td>
            </tr>
          </table>
        </div>
      {% include 'inc/panels/custom_fields.html' %}
    </div>
    <div class="col col-md-6">
      {% include 'inc/panels/tags.html' %}
      {% include 'inc/panels/comments.html' %}
    </div>
  </div>
{% endblock content %}