diff --git a/netbox/extras/views.py b/netbox/extras/views.py index 10bf2f6c81..b23dc02302 100644 --- a/netbox/extras/views.py +++ b/netbox/extras/views.py @@ -276,6 +276,21 @@ class ConfigContextView(generic.ObjectView): queryset = ConfigContext.objects.all() def get_extra_context(self, request, instance): + # Gather assigned objects for parsing in the template + assigned_objects = ( + ('Regions', instance.regions.all), + ('Site Groups', instance.site_groups.all), + ('Sites', instance.sites.all), + ('Device Types', instance.device_types.all), + ('Roles', instance.roles.all), + ('Platforms', instance.platforms.all), + ('Cluster Groups', instance.cluster_groups.all), + ('Clusters', instance.clusters.all), + ('Tenant Groups', instance.tenant_groups.all), + ('Tenants', instance.tenants.all), + ('Tags', instance.tags.all), + ) + # Determine user's preferred output format if request.GET.get('format') in ['json', 'yaml']: format = request.GET.get('format') @@ -287,6 +302,7 @@ class ConfigContextView(generic.ObjectView): format = 'json' return { + 'assigned_objects': assigned_objects, 'format': format, } diff --git a/netbox/templates/extras/configcontext.html b/netbox/templates/extras/configcontext.html index 0b6cc9eab1..3a9cc2e0cd 100644 --- a/netbox/templates/extras/configcontext.html +++ b/netbox/templates/extras/configcontext.html @@ -50,132 +50,20 @@
| Regions | -
- {% if object.regions.all %}
-
|
- ||
|---|---|---|---|
| Sites | -
- {% if object.sites.all %}
-
|
- ||
| Roles | -
- {% if object.roles.all %}
-
|
- ||
| Platforms | -
- {% if object.platforms.all %}
-
|
- ||
| Cluster Groups | -
- {% if object.cluster_groups.all %}
-
|
- ||
| Clusters | -
- {% if object.clusters.all %}
-
|
- ||
| Tenant Groups | -
- {% if object.tenant_groups.all %}
-
|
- ||
| Tenants | -
- {% if object.tenants.all %}
-
|
- ||
| Tags | -
- {% if object.tags.all %}
-
|
+ {{ title }} | +
+
|