1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Merge pull request #8329 from jasonyates/8293-asdot

Adding asdot notation to ASN views
This commit is contained in:
Jeremy Stretch
2022-01-13 15:02:21 -05:00
committed by GitHub
3 changed files with 14 additions and 2 deletions

View File

@ -125,11 +125,19 @@ class ASN(PrimaryModel):
verbose_name_plural = 'ASNs'
def __str__(self):
return f'AS{self.asn}'
return f'AS{self.asn_with_asdot}'
def get_absolute_url(self):
return reverse('ipam:asn', args=[self.pk])
@property
def asn_with_asdot(self):
# Return asn with asdot notation for an ASN larger than 65535 otherwise return the plain ASN
if self.asn > 65535:
return f'{self.asn} ({self.asn // 65536}.{self.asn % 65536})'
else:
return self.asn
@extras_features('custom_fields', 'custom_links', 'export_templates', 'tags', 'webhooks')
class Aggregate(GetAvailablePrefixesMixin, PrimaryModel):

View File

@ -106,6 +106,10 @@ class ASNTable(BaseTable):
asn = tables.Column(
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'},

View File

@ -18,7 +18,7 @@
<table class="table table-hover attr-table">
<tr>
<td>AS Number</td>
<td>{{ object.asn }}</td>
<td>{{ object.asn_with_asdot }}</td>
</tr>
<tr>
<td>RIR</td>