diff --git a/netbox/extras/views.py b/netbox/extras/views.py index 10bf2f6c810..b23dc02302d 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 @@ def get_extra_context(self, request, instance): format = 'json' return { + 'assigned_objects': assigned_objects, 'format': format, } diff --git a/netbox/templates/circuits/circuit.html b/netbox/templates/circuits/circuit.html index ec1369e1b25..7b22c5d65ab 100644 --- a/netbox/templates/circuits/circuit.html +++ b/netbox/templates/circuits/circuit.html @@ -66,18 +66,7 @@
{% include 'inc/custom_fields_panel.html' %} {% include 'extras/inc/tags_panel.html' with tags=object.tags.all url='circuits:circuit_list' %} -
-
- Comments -
-
- {% if object.comments %} - {{ object.comments|render_markdown }} - {% else %} - None - {% endif %} -
-
+ {% include 'inc/comments_panel.html' %} {% plugin_left_page object %}
diff --git a/netbox/templates/circuits/provider.html b/netbox/templates/circuits/provider.html index 9434d99ecda..4d35da0e66d 100644 --- a/netbox/templates/circuits/provider.html +++ b/netbox/templates/circuits/provider.html @@ -52,18 +52,7 @@
{% include 'inc/custom_fields_panel.html' %} {% include 'extras/inc/tags_panel.html' with tags=object.tags.all url='circuits:provider_list' %} -
-
- Comments -
-
- {% if object.comments %} - {{ object.comments|render_markdown }} - {% else %} - None - {% endif %} -
-
+ {% include 'inc/comments_panel.html' %} {% plugin_right_page object %}
diff --git a/netbox/templates/circuits/providernetwork.html b/netbox/templates/circuits/providernetwork.html index 49f34e9221d..a5eac1f7892 100644 --- a/netbox/templates/circuits/providernetwork.html +++ b/netbox/templates/circuits/providernetwork.html @@ -37,20 +37,9 @@
{% plugin_left_page object %}
-
-
- Comments -
-
- {% if object.comments %} - {{ object.comments|render_markdown }} - {% else %} - None - {% endif %} -
-
{% include 'inc/custom_fields_panel.html' %} {% include 'extras/inc/tags_panel.html' with tags=object.tags.all url='circuits:providernetwork_list' %} + {% include 'inc/comments_panel.html' %} {% plugin_right_page object %}
diff --git a/netbox/templates/dcim/device.html b/netbox/templates/dcim/device.html index 162e201b14b..72e42129c8a 100644 --- a/netbox/templates/dcim/device.html +++ b/netbox/templates/dcim/device.html @@ -210,18 +210,7 @@
{% include 'inc/custom_fields_panel.html' %} {% include 'extras/inc/tags_panel.html' with tags=object.tags.all url='dcim:device_list' %} -
-
- Comments -
-
- {% if object.comments %} - {{ object.comments|render_markdown }} - {% else %} - None - {% endif %} -
-
+ {% include 'inc/comments_panel.html' %} {% plugin_left_page object %}
diff --git a/netbox/templates/dcim/devicetype.html b/netbox/templates/dcim/devicetype.html index ad685387713..cd3da3efaac 100644 --- a/netbox/templates/dcim/devicetype.html +++ b/netbox/templates/dcim/devicetype.html @@ -126,18 +126,7 @@
{% include 'inc/custom_fields_panel.html' %} {% include 'extras/inc/tags_panel.html' with tags=object.tags.all url='dcim:devicetype_list' %} -
-
- Comments -
-
- {% if object.comments %} - {{ object.comments|render_markdown }} - {% else %} - None - {% endif %} -
-
+ {% include 'inc/comments_panel.html' %} {% plugin_right_page object %}
diff --git a/netbox/templates/dcim/powerfeed.html b/netbox/templates/dcim/powerfeed.html index 0632cff4c57..b4fb0608179 100644 --- a/netbox/templates/dcim/powerfeed.html +++ b/netbox/templates/dcim/powerfeed.html @@ -182,18 +182,7 @@
{% endif %} -
-
- Comments -
-
- {% if object.comments %} - {{ object.comments|render_markdown }} - {% else %} - None - {% endif %} -
-
+ {% include 'inc/comments_panel.html' %} {% plugin_right_page object %} diff --git a/netbox/templates/dcim/rack.html b/netbox/templates/dcim/rack.html index 631dbf9f3f7..0a278f2d6e8 100644 --- a/netbox/templates/dcim/rack.html +++ b/netbox/templates/dcim/rack.html @@ -168,18 +168,7 @@
{% include 'inc/custom_fields_panel.html' %} {% include 'extras/inc/tags_panel.html' with tags=object.tags.all url='dcim:rack_list' %} -
-
- Comments -
-
- {% if object.comments %} - {{ object.comments|render_markdown }} - {% else %} - None - {% endif %} -
-
+ {% include 'inc/comments_panel.html' %} {% if power_feeds %}
diff --git a/netbox/templates/dcim/site.html b/netbox/templates/dcim/site.html index 201b24b6115..1e50e7ba69e 100644 --- a/netbox/templates/dcim/site.html +++ b/netbox/templates/dcim/site.html @@ -167,18 +167,7 @@
{% include 'inc/custom_fields_panel.html' %} {% include 'extras/inc/tags_panel.html' with tags=object.tags.all url='dcim:site_list' %} -
-
- Comments -
-
- {% if object.comments %} - {{ object.comments|render_markdown }} - {% else %} - None - {% endif %} -
-
+ {% include 'inc/comments_panel.html' %} {% plugin_left_page object %}
diff --git a/netbox/templates/extras/configcontext.html b/netbox/templates/extras/configcontext.html index 0b6cc9eab16..3a9cc2e0cdf 100644 --- a/netbox/templates/extras/configcontext.html +++ b/netbox/templates/extras/configcontext.html @@ -50,132 +50,20 @@
+ {% for title, objects in assigned_objects %} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + {% endfor %}
Regions - {% if object.regions.all %} -
    - {% for region in object.regions.all %} -
  • {{ region }}
  • - {% endfor %} -
- {% else %} - None - {% endif %} -
Sites - {% if object.sites.all %} -
    - {% for site in object.sites.all %} -
  • {{ site }}
  • - {% endfor %} -
- {% else %} - None - {% endif %} -
Roles - {% if object.roles.all %} -
    - {% for role in object.roles.all %} -
  • {{ role }}
  • - {% endfor %} -
- {% else %} - None - {% endif %} -
Platforms - {% if object.platforms.all %} -
    - {% for platform in object.platforms.all %} -
  • {{ platform }}
  • - {% endfor %} -
- {% else %} - None - {% endif %} -
Cluster Groups - {% if object.cluster_groups.all %} -
    - {% for cluster_group in object.cluster_groups.all %} -
  • {{ cluster_group }}
  • - {% endfor %} -
- {% else %} - None - {% endif %} -
Clusters - {% if object.clusters.all %} -
    - {% for cluster in object.clusters.all %} -
  • {{ cluster }}
  • - {% endfor %} -
- {% else %} - None - {% endif %} -
Tenant Groups - {% if object.tenant_groups.all %} -
    - {% for tenant_group in object.tenant_groups.all %} -
  • {{ tenant_group }}
  • - {% endfor %} -
- {% else %} - None - {% endif %} -
Tenants - {% if object.tenants.all %} -
    - {% for tenant in object.tenants.all %} -
  • {{ tenant }}
  • - {% endfor %} -
- {% else %} - None - {% endif %} -
Tags - {% if object.tags.all %} -
    - {% for tag in object.tags.all %} -
  • {{ tag }}
  • - {% endfor %} -
- {% else %} - None - {% endif %} -
{{ title }} +
    + {% for object in objects %} +
  • {{ object }}
  • + {% empty %} +
  • None
  • + {% endfor %} +
+
diff --git a/netbox/templates/extras/journalentry.html b/netbox/templates/extras/journalentry.html index 2862fb8bcfe..925d98b41d5 100644 --- a/netbox/templates/extras/journalentry.html +++ b/netbox/templates/extras/journalentry.html @@ -45,14 +45,7 @@
-
-
- Comments -
-
- {{ object.comments|render_markdown }} -
-
+ {% include 'inc/comments_panel.html' %}
{% endblock %} diff --git a/netbox/templates/inc/comments_panel.html b/netbox/templates/inc/comments_panel.html new file mode 100644 index 00000000000..bfacb25bf31 --- /dev/null +++ b/netbox/templates/inc/comments_panel.html @@ -0,0 +1,14 @@ +{% load helpers %} + +
+
+ Comments +
+
+ {% if object.comments %} + {{ object.comments|render_markdown }} + {% else %} + None + {% endif %} +
+
diff --git a/netbox/templates/tenancy/tenant.html b/netbox/templates/tenancy/tenant.html index 7d251739bad..dee7f7ce736 100644 --- a/netbox/templates/tenancy/tenant.html +++ b/netbox/templates/tenancy/tenant.html @@ -37,18 +37,7 @@
{% include 'inc/custom_fields_panel.html' %} {% include 'extras/inc/tags_panel.html' with tags=object.tags.all url='tenancy:tenant_list' %} -
-
- Comments -
-
- {% if object.comments %} - {{ object.comments|render_markdown }} - {% else %} - None - {% endif %} -
-
+ {% include 'inc/comments_panel.html' %} {% plugin_left_page object %}
diff --git a/netbox/templates/virtualization/cluster.html b/netbox/templates/virtualization/cluster.html index 402ec71bc8d..769ae431f11 100644 --- a/netbox/templates/virtualization/cluster.html +++ b/netbox/templates/virtualization/cluster.html @@ -56,18 +56,7 @@
-
-
- Comments -
-
- {% if object.comments %} - {{ object.comments|render_markdown }} - {% else %} - None - {% endif %} -
-
+ {% include 'inc/comments_panel.html' %} {% plugin_left_page object %}
diff --git a/netbox/templates/virtualization/virtualmachine.html b/netbox/templates/virtualization/virtualmachine.html index 339a82e6520..6ea4e8d7ce2 100644 --- a/netbox/templates/virtualization/virtualmachine.html +++ b/netbox/templates/virtualization/virtualmachine.html @@ -91,18 +91,7 @@
{% include 'inc/custom_fields_panel.html' %} {% include 'extras/inc/tags_panel.html' with tags=object.tags.all url='virtualization:virtualmachine_list' %} -
-
- Comments -
-
- {% if object.comments %} - {{ object.comments|render_markdown }} - {% else %} - None - {% endif %} -
-
+ {% include 'inc/comments_panel.html' %} {% plugin_left_page object %}