mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-14 09:51:22 -06:00
Fixes #2984: Fix logging of unlabeled cable ID on cable deletion
This commit is contained in:
parent
bd8b239e15
commit
ea11e70e3f
@ -21,6 +21,7 @@ v2.5.8 (FUTURE)
|
|||||||
* [#2972](https://github.com/digitalocean/netbox/issues/2972) - Improve ContentTypeField serializer to elegantly handle invalid data
|
* [#2972](https://github.com/digitalocean/netbox/issues/2972) - Improve ContentTypeField serializer to elegantly handle invalid data
|
||||||
* [#2976](https://github.com/digitalocean/netbox/issues/2976) - Add delete button to tag view
|
* [#2976](https://github.com/digitalocean/netbox/issues/2976) - Add delete button to tag view
|
||||||
* [#2980](https://github.com/digitalocean/netbox/issues/2980) - Improve rendering time for API docs
|
* [#2980](https://github.com/digitalocean/netbox/issues/2980) - Improve rendering time for API docs
|
||||||
|
* [#2984](https://github.com/digitalocean/netbox/issues/2984) - Fix logging of unlabeled cable ID on cable deletion
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -2557,16 +2557,15 @@ class Cable(ChangeLoggedModel):
|
|||||||
('termination_b_type', 'termination_b_id'),
|
('termination_b_type', 'termination_b_id'),
|
||||||
)
|
)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
|
|
||||||
super().__init__(*args, **kwargs)
|
|
||||||
|
|
||||||
# Create an ID string for use by __str__(). We have to save a copy of pk since it's nullified after .delete()
|
|
||||||
# is called.
|
|
||||||
self.id_string = '#{}'.format(self.pk)
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.label or self.id_string
|
if self.label:
|
||||||
|
return self.label
|
||||||
|
|
||||||
|
# Save a copy of the PK on the instance since it's nullified if .delete() is called
|
||||||
|
if not hasattr(self, 'id_string'):
|
||||||
|
self.id_string = '#{}'.format(self.pk)
|
||||||
|
|
||||||
|
return self.id_string
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse('dcim:cable', args=[self.pk])
|
return reverse('dcim:cable', args=[self.pk])
|
||||||
|
Loading…
Reference in New Issue
Block a user