From b57aeeca6288d778a9d2022f5296c0452505fdf9 Mon Sep 17 00:00:00 2001 From: Peter Eckel Date: Sat, 6 Jun 2026 13:06:26 +0200 Subject: [PATCH] Provide a list of other records in the RRSET if there is more than one --- netbox_dns/models/record.py | 4 ++++ netbox_dns/templates/netbox_dns/record.html | 12 ++++++++++++ netbox_dns/views/record.py | 8 ++++++++ 3 files changed, 24 insertions(+) diff --git a/netbox_dns/models/record.py b/netbox_dns/models/record.py index 243c3ead..06b28514 100644 --- a/netbox_dns/models/record.py +++ b/netbox_dns/models/record.py @@ -316,6 +316,10 @@ def is_address_record(self): def is_ptr_record(self): return self.type == RecordTypeChoices.PTR + @property + def rrset(self): + return self.zone.records.filter(type=self.type, name=self.name) + @property def rfc2317_ptr_name(self): return self.value.split(".")[-1] diff --git a/netbox_dns/templates/netbox_dns/record.html b/netbox_dns/templates/netbox_dns/record.html index 2a95dc43..055e0765 100644 --- a/netbox_dns/templates/netbox_dns/record.html +++ b/netbox_dns/templates/netbox_dns/record.html @@ -149,6 +149,18 @@
{% trans "Record" %}
+ {% if rrset_record_table %} +
+ {% if rrset_record_table.rows|length == 1 %} +
{% trans "Other Record in the RRSET" %}
+ {% else %} +
{% trans "Other Records in the RRSET" %}
+ {% endif %} +
+ {% render_table rrset_record_table 'inc/table.html' %} +
+
+ {% endif %} {% if cname_target_table %}
{% if cname_target_table.rows|length == 1 %} diff --git a/netbox_dns/views/record.py b/netbox_dns/views/record.py index 4727567e..3260acfc 100644 --- a/netbox_dns/views/record.py +++ b/netbox_dns/views/record.py @@ -162,6 +162,14 @@ def get_extra_context(self, request, instance): if address_record is not None: context["ipam_ip_address"] = address_record.ipam_ip_address + if instance.rrset.count() > 1: + rrset_record_table = RelatedRecordTable( + data=instance.rrset.exclude(pk=instance.pk) + ) + rrset_record_table.configure(request) + + context["rrset_record_table"] = rrset_record_table + if not instance.managed: try: instance.check_zone_cut_conflict()