From d3173f8f1474396275cdee1776a8c1089234b888 Mon Sep 17 00:00:00 2001 From: Arthur Hanson Date: Wed, 9 Oct 2024 14:38:24 -0700 Subject: [PATCH] 16546 move get_absolute_url to NetBoxFeatureSet --- netbox/circuits/models/circuits.py | 6 ------ netbox/dcim/models/sites.py | 9 --------- netbox/netbox/models/__init__.py | 9 +++------ netbox/tenancy/models/contacts.py | 3 --- netbox/tenancy/models/tenants.py | 3 --- netbox/virtualization/models/virtualmachines.py | 6 ------ netbox/wireless/models.py | 3 --- 7 files changed, 3 insertions(+), 36 deletions(-) diff --git a/netbox/circuits/models/circuits.py b/netbox/circuits/models/circuits.py index 3923b71a9..d41ace6d1 100644 --- a/netbox/circuits/models/circuits.py +++ b/netbox/circuits/models/circuits.py @@ -28,9 +28,6 @@ class CircuitType(OrganizationalModel): blank=True ) - def get_absolute_url(self): - return reverse('circuits:circuittype', args=[self.pk]) - class Meta: ordering = ('name',) verbose_name = _('circuit type') @@ -291,9 +288,6 @@ class CircuitTermination( def __str__(self): return f'{self.circuit}: Termination {self.term_side}' - def get_absolute_url(self): - return reverse('circuits:circuittermination', args=[self.pk]) - def clean(self): super().clean() diff --git a/netbox/dcim/models/sites.py b/netbox/dcim/models/sites.py index c7b8c1b6b..7884afa54 100644 --- a/netbox/dcim/models/sites.py +++ b/netbox/dcim/models/sites.py @@ -62,9 +62,6 @@ class Region(ContactsMixin, NestedGroupModel): verbose_name = _('region') verbose_name_plural = _('regions') - def get_absolute_url(self): - return reverse('dcim:region', args=[self.pk]) - def get_site_count(self): return Site.objects.filter( Q(region=self) | @@ -115,9 +112,6 @@ class SiteGroup(ContactsMixin, NestedGroupModel): verbose_name = _('site group') verbose_name_plural = _('site groups') - def get_absolute_url(self): - return reverse('dcim:sitegroup', args=[self.pk]) - def get_site_count(self): return Site.objects.filter( Q(group=self) | @@ -319,9 +313,6 @@ class Location(ContactsMixin, ImageAttachmentsMixin, NestedGroupModel): verbose_name = _('location') verbose_name_plural = _('locations') - def get_absolute_url(self): - return reverse('dcim:location', args=[self.pk]) - def get_status_color(self): return LocationStatusChoices.colors.get(self.status) diff --git a/netbox/netbox/models/__init__.py b/netbox/netbox/models/__init__.py index 1d1a71336..d99c9e719 100644 --- a/netbox/netbox/models/__init__.py +++ b/netbox/netbox/models/__init__.py @@ -41,6 +41,9 @@ class NetBoxFeatureSet( def docs_url(self): return f'{settings.STATIC_URL}docs/models/{self._meta.app_label}/{self._meta.model_name}/' + def get_absolute_url(self): + return reverse(f'{self._meta.app_label}:{self._meta.model_name}', args=[self.pk]) + # # Base model classes @@ -98,9 +101,6 @@ class NetBoxModel(NetBoxFeatureSet, models.Model): # update the GFK field value setattr(self, field.name, obj) - def get_absolute_url(self): - return reverse(f'{self._meta.app_label}:{self._meta.model_name}', args=[self.pk]) - # # NetBox internal base models # @@ -205,6 +205,3 @@ class OrganizationalModel(NetBoxFeatureSet, models.Model): def __str__(self): return self.name - - def get_absolute_url(self): - return reverse(f'{self._meta.app_label}:{self._meta.model_name}', args=[self.pk]) diff --git a/netbox/tenancy/models/contacts.py b/netbox/tenancy/models/contacts.py index 25bc97627..46ca97261 100644 --- a/netbox/tenancy/models/contacts.py +++ b/netbox/tenancy/models/contacts.py @@ -32,9 +32,6 @@ class ContactGroup(NestedGroupModel): verbose_name = _('contact group') verbose_name_plural = _('contact groups') - def get_absolute_url(self): - return reverse('tenancy:contactgroup', args=[self.pk]) - class ContactRole(OrganizationalModel): """ diff --git a/netbox/tenancy/models/tenants.py b/netbox/tenancy/models/tenants.py index 42a6da4cb..118a63d31 100644 --- a/netbox/tenancy/models/tenants.py +++ b/netbox/tenancy/models/tenants.py @@ -32,9 +32,6 @@ class TenantGroup(NestedGroupModel): verbose_name = _('tenant group') verbose_name_plural = _('tenant groups') - def get_absolute_url(self): - return reverse('tenancy:tenantgroup', args=[self.pk]) - class Tenant(ContactsMixin, PrimaryModel): """ diff --git a/netbox/virtualization/models/virtualmachines.py b/netbox/virtualization/models/virtualmachines.py index 05be0d351..d2ea34bef 100644 --- a/netbox/virtualization/models/virtualmachines.py +++ b/netbox/virtualization/models/virtualmachines.py @@ -374,9 +374,6 @@ class VMInterface(ComponentModel, BaseInterface, TrackingModelMixin): verbose_name = _('interface') verbose_name_plural = _('interfaces') - def get_absolute_url(self): - return reverse('virtualization:vminterface', kwargs={'pk': self.pk}) - def clean(self): super().clean() @@ -434,6 +431,3 @@ class VirtualDisk(ComponentModel, TrackingModelMixin): class Meta(ComponentModel.Meta): verbose_name = _('virtual disk') verbose_name_plural = _('virtual disks') - - def get_absolute_url(self): - return reverse('virtualization:virtualdisk', args=[self.pk]) diff --git a/netbox/wireless/models.py b/netbox/wireless/models.py index 85d3da19f..e48c87167 100644 --- a/netbox/wireless/models.py +++ b/netbox/wireless/models.py @@ -69,9 +69,6 @@ class WirelessLANGroup(NestedGroupModel): verbose_name = _('wireless LAN group') verbose_name_plural = _('wireless LAN groups') - def get_absolute_url(self): - return reverse('wireless:wirelesslangroup', args=[self.pk]) - class WirelessLAN(WirelessAuthenticationBase, PrimaryModel): """