mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Suggested changes
* Updating asdot computation to use an fstring * Cleaning code. Custom property now returns either the ASN with ASDOT notation or just the ASN. asn_with_asdot can now be referenced in ASNTable & objet template.
This commit is contained in:
@@ -125,21 +125,18 @@ class ASN(PrimaryModel):
|
||||
verbose_name_plural = 'ASNs'
|
||||
|
||||
def __str__(self):
|
||||
if self.asn > 65535:
|
||||
return 'AS{} ({}.{})'.format(self.asn, self.asn // 65536, self.asn % 65536)
|
||||
else:
|
||||
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 asdot_notation(self):
|
||||
# Return asdot notation for an ASN larger than 65535
|
||||
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 '{}.{}'.format(self.asn // 65536, self.asn % 65536)
|
||||
return f'{self.asn} ({self.asn // 65536}.{self.asn % 65536})'
|
||||
else:
|
||||
return None
|
||||
return self.asn
|
||||
|
||||
|
||||
@extras_features('custom_fields', 'custom_links', 'export_templates', 'tags', 'webhooks')
|
||||
|
Reference in New Issue
Block a user