Przeglądaj źródła

#8293: Tweak table column output & add changelog

jeremystretch 4 lat temu
rodzic
commit
0ca6d73614

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

@@ -7,6 +7,7 @@
 * [#8246](https://github.com/netbox-community/netbox/issues/8246) - Show human-friendly values for commit rates in circuits table
 * [#8262](https://github.com/netbox-community/netbox/issues/8262) - Add cable count to tenant stats
 * [#8265](https://github.com/netbox-community/netbox/issues/8265) - Add Stackwise-n interface types
+* [#8293](https://github.com/netbox-community/netbox/issues/8293) - Show 4-byte ASNs in ASDOT notation
 * [#8302](https://github.com/netbox-community/netbox/issues/8302) - Linkify role column in device & VM tables
 
 ### Bug Fixes

+ 12 - 1
netbox/ipam/models/ip.py

@@ -130,9 +130,20 @@ class ASN(PrimaryModel):
     def get_absolute_url(self):
         return reverse('ipam:asn', args=[self.pk])
 
+    @property
+    def asn_asdot(self):
+        """
+        Return ASDOT notation for AS numbers greater than 16 bits.
+        """
+        if self.asn > 65535:
+            return f'{self.asn // 65536}.{self.asn % 65536}'
+        return self.asn
+
     @property
     def asn_with_asdot(self):
-        # Return asn with asdot notation for an ASN larger than 65535 otherwise return the plain ASN
+        """
+        Return both plain and ASDOT notation, where applicable.
+        """
         if self.asn > 65535:
             return f'{self.asn} ({self.asn // 65536}.{self.asn % 65536})'
         else:

+ 1 - 3
netbox/ipam/tables/ip.py

@@ -104,12 +104,10 @@ class RIRTable(BaseTable):
 class ASNTable(BaseTable):
     pk = ToggleColumn()
     asn = tables.Column(
+        accessor=tables.A('asn_asdot'),
         linkify=True
     )
 
-    def render_asn(self, value, record):
-        return record.asn_with_asdot
-
     site_count = LinkedCountColumn(
         viewname='dcim:site_list',
         url_params={'asn_id': 'pk'},