Przeglądaj źródła

Fixes #7193 - Fixes issue with viewing child prefixes when prefix (flat) column is selected and there are available prefixes.

Daniel Sheppard 4 lat temu
rodzic
commit
2fb55374b9
2 zmienionych plików z 14 dodań i 4 usunięć
  1. 1 0
      docs/release-notes/version-3.0.md
  2. 13 4
      netbox/ipam/tables.py

+ 1 - 0
docs/release-notes/version-3.0.md

@@ -7,6 +7,7 @@
 * [#7153](https://github.com/netbox-community/netbox/issues/7153) - Allow clearing of assigned device type images
 * [#7164](https://github.com/netbox-community/netbox/issues/7164) - Fix styling of "decommissioned" label for circuits
 * [#7169](https://github.com/netbox-community/netbox/issues/7169) - Fix CSV import file upload
+* [#7169](https://github.com/netbox-community/netbox/issues/7193) - Fix prefix (flat) template issue when viewing child prefixes with prefixes available
 
 ---
 

+ 13 - 4
netbox/ipam/tables.py

@@ -25,6 +25,15 @@ PREFIX_LINK = """
 <a href="{% if record.pk %}{% url 'ipam:prefix' pk=record.pk %}{% else %}{% url 'ipam:prefix_add' %}?prefix={{ record }}{% if object.vrf %}&vrf={{ object.vrf.pk }}{% endif %}{% if object.site %}&site={{ object.site.pk }}{% endif %}{% if object.tenant %}&tenant_group={{ object.tenant.group.pk }}&tenant={{ object.tenant.pk }}{% endif %}{% endif %}">{{ record.prefix }}</a>
 """
 
+PREFIXFLAT_LINK = """
+{% load helpers %}
+{% if record.pk %}
+    <a href="{% url 'ipam:prefix' pk=record.pk %}">{{ record.prefix }}</a>
+{% else %}
+    &mdash;
+{% endif %}
+"""
+
 PREFIX_ROLE_LINK = """
 {% if record.role %}
     <a href="{% url 'ipam:prefix_list' %}?role={{ record.role.slug }}">{{ record.role }}</a>
@@ -281,10 +290,10 @@ class PrefixTable(BaseTable):
         template_code=PREFIX_LINK,
         attrs={'td': {'class': 'text-nowrap'}}
     )
-    prefix_flat = tables.Column(
-        accessor=Accessor('prefix'),
-        linkify=True,
-        verbose_name='Prefix (Flat)'
+    prefix_flat = tables.TemplateColumn(
+        template_code=PREFIXFLAT_LINK,
+        attrs={'td': {'class': 'text-nowrap'}},
+        verbose_name='Prefix (Flat)',
     )
     depth = tables.Column(
         accessor=Accessor('_depth'),