1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Include circuits list on cloud view

This commit is contained in:
Jeremy Stretch
2021-03-18 14:05:32 -04:00
parent 872e936924
commit 2e97bf48c5
2 changed files with 39 additions and 9 deletions

View File

@ -1,5 +1,6 @@
from django.contrib import messages
from django.db import transaction
from django.db.models import Q
from django.shortcuts import get_object_or_404, redirect, render
from django_tables2 import RequestConfig
@ -95,6 +96,28 @@ class CloudListView(generic.ObjectListView):
class CloudView(generic.ObjectView):
queryset = Cloud.objects.all()
def get_extra_context(self, request, instance):
circuits = Circuit.objects.restrict(request.user, 'view').filter(
Q(termination_a__cloud=instance.pk) |
Q(termination_z__cloud=instance.pk)
).prefetch_related(
'type', 'tenant', 'terminations__site'
)
circuits_table = tables.CircuitTable(circuits)
circuits_table.columns.hide('termination_a')
circuits_table.columns.hide('termination_z')
paginate = {
'paginator_class': EnhancedPaginator,
'per_page': get_paginate_count(request)
}
RequestConfig(request, paginate).configure(circuits_table)
return {
'circuits_table': circuits_table,
}
class CloudEditView(generic.ObjectEditView):
queryset = Cloud.objects.all()

View File

@ -33,6 +33,18 @@
</tr>
</table>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<strong>Comments</strong>
</div>
<div class="panel-body rendered-markdown">
{% if object.comments %}
{{ object.comments|render_markdown }}
{% else %}
<span class="text-muted">None</span>
{% endif %}
</div>
</div>
{% include 'inc/custom_fields_panel.html' %}
{% include 'extras/inc/tags_panel.html' with tags=object.tags.all url='circuits:cloud_list' %}
{% plugin_left_page object %}
@ -40,18 +52,13 @@
<div class="col-md-8">
<div class="panel panel-default">
<div class="panel-heading">
<strong>Comments</strong>
</div>
<div class="panel-body rendered-markdown">
{% if object.comments %}
{{ object.comments|render_markdown }}
{% else %}
<span class="text-muted">None</span>
{% endif %}
<strong>Circuits</strong>
</div>
{% include 'inc/table.html' with table=circuits_table %}
</div>
{% include 'inc/paginator.html' with paginator=circuits_table.paginator page=circuits_table.page %}
{% plugin_right_page object %}
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">