-
-
-
-
-
- Device |
- {{ object.device|linkify }} |
-
-
- Status |
- {% badge object.get_status_display bg_color=object.get_status_color %} |
-
-
-
-
+{% block controls %}
+
+
+ {% if request.user|can_delete:object %}
+ {% delete_button object %}
+ {% endif %}
- {% if object.error %}
-
- {% endif %}
- {% if object.diff %}
-
- {% endif %}
-{% endblock content %}
-
-{% block javascript %}
-
-
-{% endblock javascript %}
+{% endblock controls %}
diff --git a/netbox_config_diff/templates/netbox_config_diff/configcompliance/base.html b/netbox_config_diff/templates/netbox_config_diff/configcompliance/base.html
deleted file mode 100644
index 8fdcc6f..0000000
--- a/netbox_config_diff/templates/netbox_config_diff/configcompliance/base.html
+++ /dev/null
@@ -1,13 +0,0 @@
-{% extends "generic/object.html" %}
-{% load buttons %}
-{% load perms %}
-
-{% block controls %}
-
-
- {% if request.user|can_delete:object %}
- {% delete_button object %}
- {% endif %}
-
-
-{% endblock controls %}
\ No newline at end of file
diff --git a/netbox_config_diff/templates/netbox_config_diff/configcompliance/config.html b/netbox_config_diff/templates/netbox_config_diff/configcompliance/config.html
index 8bc2722..ae2c864 100644
--- a/netbox_config_diff/templates/netbox_config_diff/configcompliance/config.html
+++ b/netbox_config_diff/templates/netbox_config_diff/configcompliance/config.html
@@ -1,4 +1,4 @@
-{% extends "netbox_config_diff/configcompliance/base.html" %}
+{% extends "netbox_config_diff/configcompliance.html" %}
{% block title %}{{ object }} - {{ header }}{% endblock %}
diff --git a/netbox_config_diff/templates/netbox_config_diff/configcompliance/data.html b/netbox_config_diff/templates/netbox_config_diff/configcompliance/data.html
new file mode 100644
index 0000000..5c20e42
--- /dev/null
+++ b/netbox_config_diff/templates/netbox_config_diff/configcompliance/data.html
@@ -0,0 +1,81 @@
+{% extends base_template %}
+{% load static %}
+
+{% block content %}
+
+
+
+
+
+
+
+ Device |
+ {{ instance.device|linkify }} |
+
+
+ Status |
+ {% badge instance.get_status_display bg_color=instance.get_status_color %} |
+
+
+
+
+
+ {% if instance.error %}
+
+ {% endif %}
+
+ {% if instance.diff %}
+
+ {% endif %}
+{% endblock content %}
+
+{% block javascript %}
+
+
+{% endblock javascript %}
diff --git a/netbox_config_diff/templates/netbox_config_diff/configcompliance/missing_extra.html b/netbox_config_diff/templates/netbox_config_diff/configcompliance/missing_extra.html
index c7692fd..de94dd9 100644
--- a/netbox_config_diff/templates/netbox_config_diff/configcompliance/missing_extra.html
+++ b/netbox_config_diff/templates/netbox_config_diff/configcompliance/missing_extra.html
@@ -1,4 +1,4 @@
-{% extends "netbox_config_diff/configcompliance/base.html" %}
+{% extends "netbox_config_diff/configcompliance.html" %}
{% block title %}{{ object }} - Missing/Extra{% endblock %}
diff --git a/netbox_config_diff/views/compliance.py b/netbox_config_diff/views/compliance.py
index fbe5c95..2a4d49c 100644
--- a/netbox_config_diff/views/compliance.py
+++ b/netbox_config_diff/views/compliance.py
@@ -1,5 +1,6 @@
+from dcim.models import Device
from django.http import HttpResponse
-from django.shortcuts import render
+from django.shortcuts import redirect, render
from django.utils.translation import gettext as _
from netbox.views import generic
from utilities.views import ViewTab, register_model_view
@@ -51,6 +52,14 @@ def get_extra_context(self, request, instance):
@register_model_view(ConfigCompliance)
class ConfigComplianceView(generic.ObjectView):
queryset = ConfigCompliance.objects.all()
+ base_template = "netbox_config_diff/configcompliance.html"
+ template_name = "netbox_config_diff/configcompliance/data.html"
+
+ def get_extra_context(self, request, instance):
+ return {
+ "instance": instance,
+ "base_template": self.base_template,
+ }
@register_model_view(ConfigCompliance, "rendered-config")
@@ -113,6 +122,37 @@ def get(self, request, **kwargs):
)
+@register_model_view(Device, "config_compliance", "config-compliance")
+class ConfigComplianceDeviceView(generic.ObjectView):
+ queryset = Device.objects.all()
+ base_template = "dcim/device/base.html"
+ template_name = "netbox_config_diff/configcompliance/data.html"
+ tab = ViewTab(
+ label=_("Config Compliance"),
+ weight=2110,
+ badge=lambda obj: 1 if hasattr(obj, "config_compliance") else 0,
+ hide_if_empty=True,
+ )
+
+ def get(self, request, **kwargs):
+ instance = self.get_object(**kwargs)
+
+ if not hasattr(instance, "config_compliance"):
+ return redirect("dcim:device", pk=instance.pk)
+
+ return render(
+ request,
+ self.get_template_name(),
+ {
+ "object": instance,
+ "instance": instance.config_compliance,
+ "tab": self.tab,
+ "base_template": self.base_template,
+ **self.get_extra_context(request, instance),
+ },
+ )
+
+
class ConfigComplianceListView(generic.ObjectListView):
queryset = ConfigCompliance.objects.prefetch_related("device")
filterset = ConfigComplianceFilterSet