Standardize related model display for nested models

This commit is contained in:
jeremystretch
2023-01-25 15:21:21 -05:00
committed by jeremystretch
parent 0c9e7aa074
commit 91b81d51da
11 changed files with 120 additions and 143 deletions

View File

@@ -56,33 +56,15 @@
{{ object.tenant|linkify|placeholder }}
</td>
</tr>
<tr>
<th scope="row">Racks</th>
<td class="position-relative">
{% if rack_count %}
<div class="position-absolute top-50 end-0 translate-middle-y noprint">
<a href="{% url 'dcim:rack_elevation_list' %}?location_id={{ object.pk }}" class="btn btn-sm btn-primary" title="View elevations">
<i class="mdi mdi-server"></i>
</a>
</div>
{% endif %}
<a href="{% url 'dcim:rack_list' %}?location_id={{ object.pk }}">{{ rack_count }}</a>
</td>
</tr>
<tr>
<th scope="row">Devices</th>
<td>
<a href="{% url 'dcim:device_list' %}?location_id={{ object.pk }}">{{ device_count }}</a>
</td>
</tr>
</table>
</div>
</div>
{% include 'inc/panels/tags.html' %}
{% include 'inc/panels/custom_fields.html' %}
{% plugin_left_page object %}
</div>
<div class="col col-md-6">
{% include 'inc/panels/custom_fields.html' %}
{% include 'inc/panels/related_objects.html' %}
{% include 'inc/panels/contacts.html' %}
{% include 'dcim/inc/nonracked_devices.html' %}
{% include 'inc/panels/image_attachments.html' %}

View File

@@ -37,21 +37,21 @@
<th scope="row">Parent</th>
<td>{{ object.parent|linkify|placeholder }}</td>
</tr>
<tr>
<th scope="row">Sites</th>
<td>
<a href="{% url 'dcim:site_list' %}?region_id={{ object.pk }}">{{ object.sites.count }}</a>
</td>
</tr>
</table>
</div>
</div>
{% include 'inc/panels/tags.html' %}
{% include 'inc/panels/custom_fields.html' %}
{% include 'inc/panels/contacts.html' %}
{% plugin_left_page object %}
</div>
<div class="col col-md-6">
{% include 'inc/panels/related_objects.html' %}
{% include 'inc/panels/contacts.html' %}
{% plugin_right_page object %}
</div>
</div>
<div class="row mb-3">
<div class="col col-md-12">
<div class="card">
<h5 class="card-header">Child Regions</h5>
<div class="card-body htmx-container table-responsive"
@@ -66,18 +66,6 @@
</div>
{% endif %}
</div>
{% plugin_right_page object %}
</div>
</div>
<div class="row mb-3">
<div class="col col-md-12">
<div class="card">
<h5 class="card-header">Sites</h5>
<div class="card-body htmx-container table-responsive"
hx-get="{% url 'dcim:site_list' %}?region_id={{ object.pk }}"
hx-trigger="load"
></div>
</div>
{% plugin_full_width_page object %}
</div>
</div>

View File

@@ -37,12 +37,6 @@
<th scope="row">Parent</th>
<td>{{ object.parent|linkify|placeholder }}</td>
</tr>
<tr>
<th scope="row">Sites</th>
<td>
<a href="{% url 'dcim:site_list' %}?group_id={{ object.pk }}">{{ object.sites.count }}</a>
</td>
</tr>
</table>
</div>
</div>
@@ -52,6 +46,12 @@
{% plugin_left_page object %}
</div>
<div class="col col-md-6">
{% include 'inc/panels/related_objects.html' %}
{% plugin_right_page object %}
</div>
</div>
<div class="row mb-3">
<div class="col col-md-12">
<div class="card">
<h5 class="card-header">Child Groups</h5>
<div class="card-body htmx-container table-responsive"
@@ -66,18 +66,6 @@
</div>
{% endif %}
</div>
{% plugin_right_page object %}
</div>
</div>
<div class="row mb-3">
<div class="col col-md-12">
<div class="card">
<h5 class="card-header">Sites</h5>
<div class="card-body htmx-container table-responsive"
hx-get="{% url 'dcim:site_list' %}?group_id={{ object.pk }}"
hx-trigger="load"
></div>
</div>
{% plugin_full_width_page object %}
</div>
</div>

View File

@@ -3,9 +3,9 @@
<div class="card">
<h5 class="card-header">Related Objects</h5>
<ul class="list-group list-group-flush">
{% for qs in related_models %}
{% for qs, filter_param in related_models %}
{% with viewname=qs.model|viewname:"list" %}
<a href="{% url viewname %}?{{ filter_name }}={{ object.pk }}" class="list-group-item list-group-item-action d-flex justify-content-between">
<a href="{% url viewname %}?{{ filter_param }}={{ object.pk }}" class="list-group-item list-group-item-action d-flex justify-content-between">
{{ qs.model|meta:"verbose_name_plural"|bettertitle }}
{% with count=qs.count %}
{% if count %}

View File

@@ -31,12 +31,6 @@
<th scope="row">Parent</th>
<td>{{ object.parent|linkify|placeholder }}</td>
</tr>
<tr>
<th scope="row">Contacts</th>
<td>
<a href="{% url 'tenancy:contact_list' %}?group_id={{ object.pk }}">{{ object.contacts.count }}</a>
</td>
</tr>
</table>
</div>
</div>
@@ -44,31 +38,25 @@
{% plugin_left_page object %}
</div>
<div class="col col-md-6">
{% include 'inc/panels/related_objects.html' %}
{% include 'inc/panels/custom_fields.html' %}
<div class="card">
<h5 class="card-header">Child Groups</h5>
<div class="card-body htmx-container table-responsive"
hx-get="{% url 'tenancy:contactgroup_list' %}?parent_id={{ object.pk }}"
hx-trigger="load"
></div>
{% if perms.tenancy.add_contactgroup %}
<div class="card-footer text-end noprint">
<a href="{% url 'tenancy:contactgroup_add' %}?parent={{ object.pk }}" class="btn btn-sm btn-primary">
<span class="mdi mdi-plus-thick" aria-hidden="true"></span> Add Contact Group
</a>
</div>
{% endif %}
</div>
{% plugin_right_page object %}
</div>
</div>
<div class="col col-md-12">
<div class="card">
<h5 class="card-header">Contacts</h5>
<h5 class="card-header">Child Groups</h5>
<div class="card-body htmx-container table-responsive"
hx-get="{% url 'tenancy:contact_list' %}?group_id={{ object.pk }}"
hx-get="{% url 'tenancy:contactgroup_list' %}?parent_id={{ object.pk }}"
hx-trigger="load"
></div>
{% if perms.tenancy.add_contactgroup %}
<div class="card-footer text-end noprint">
<a href="{% url 'tenancy:contactgroup_add' %}?parent={{ object.pk }}" class="btn btn-sm btn-primary">
<span class="mdi mdi-plus-thick" aria-hidden="true"></span> Add Contact Group
</a>
</div>
{% endif %}
</div>
{% plugin_full_width_page object %}
</div>

View File

@@ -34,7 +34,7 @@
{% plugin_left_page object %}
</div>
<div class="col col-md-5">
{% include 'inc/panels/related_objects.html' with filter_name='tenant_id' %}
{% include 'inc/panels/related_objects.html' %}
{% plugin_right_page object %}
</div>
</div>

View File

@@ -39,12 +39,6 @@
<th scope="row">Parent</th>
<td>{{ object.parent|linkify|placeholder }}</td>
</tr>
<tr>
<th scope="row">Tenants</th>
<td>
<a href="{% url 'tenancy:tenant_list' %}?group_id={{ object.pk }}">{{ object.tenants.count }}</a>
</td>
</tr>
</table>
</div>
</div>
@@ -52,7 +46,13 @@
{% plugin_left_page object %}
</div>
<div class="col col-md-6">
{% include 'inc/panels/related_objects.html' %}
{% include 'inc/panels/custom_fields.html' %}
{% plugin_right_page object %}
</div>
</div>
<div class="row mb-3">
<div class="col col-md-12">
<div class="card">
<h5 class="card-header">Child Groups</h5>
<div class="card-body htmx-container table-responsive"
@@ -67,18 +67,6 @@
</div>
{% endif %}
</div>
{% plugin_right_page object %}
</div>
</div>
<div class="row mb-3">
<div class="col col-md-12">
<div class="card">
<h5 class="card-header">Tenants</h5>
<div class="card-body htmx-container table-responsive"
hx-get="{% url 'tenancy:tenant_list' %}?group_id={{ object.pk }}"
hx-trigger="load"
></div>
</div>
{% plugin_full_width_page object %}
</div>
</div>

View File

@@ -37,12 +37,6 @@
<th scope="row">Parent</th>
<td>{{ object.parent|linkify|placeholder }}</td>
</tr>
<tr>
<th scope="row">Wireless LANs</th>
<td>
<a href="{% url 'wireless:wirelesslan_list' %}?group_id={{ object.pk }}">{{ object.wirelesslans.count }}</a>
</td>
</tr>
</table>
</div>
</div>
@@ -50,7 +44,13 @@
{% plugin_left_page object %}
</div>
<div class="col col-md-6">
{% include 'inc/panels/related_objects.html' %}
{% include 'inc/panels/custom_fields.html' %}
{% plugin_right_page object %}
</div>
</div>
<div class="row mb-3">
<div class="col col-md-12">
<div class="card">
<h5 class="card-header">Child Groups</h5>
<div class="card-body htmx-container table-responsive"
@@ -65,18 +65,6 @@
</div>
{% endif %}
</div>
{% plugin_right_page object %}
</div>
</div>
<div class="row mb-3">
<div class="col col-md-12">
<div class="card">
<h5 class="card-header">Wireless LANs</h5>
<div class="card-body htmx-container table-responsive"
hx-get="{% url 'wireless:wirelesslan_list' %}?group_id={{ object.pk }}"
hx-trigger="load"
></div>
</div>
{% plugin_full_width_page object %}
</div>
</div>