[PR #3899] [MERGED] Fixes #3898: Call str of cable on delete to save PK in id_string #12687

Closed
opened 2025-12-29 22:23:03 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/3899
Author: @hSaria
Created: 1/12/2020
Status: Merged
Merged: 1/13/2020
Merged by: @jeremystretch

Base: developHead: 3898-cable-str-pk


📝 Commits (5)

  • a2308b9 Fixes #3898: Call str of cable on delete to save PK in id_string
  • 49fa243 Added post-delete cable ID test
  • 3d78a67 Store a private copy of the pk during init and use that with str
  • 608006e Set the private pk after super save
  • 736cd70 Merge branch 'develop' into 3898-cable-str-pk

📊 Changes

3 files changed (+14 additions, -8 deletions)

View changed files

📝 docs/release-notes/version-2.6.md (+1 -0)
📝 netbox/dcim/models.py (+9 -7)
📝 netbox/dcim/tests/test_models.py (+4 -1)

📄 Description

Fixes: #3898

Called the __str__ method of the cable to create the self.id_string attribute if not there. An alternative solution would've been to move the msg line before delete() is called, but I checked all models' __str__ method and it's only Cable that uses the PK as part of the string.
b7e78028ce/netbox/utilities/views.py (L289-L295)


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/3899 **Author:** [@hSaria](https://github.com/hSaria) **Created:** 1/12/2020 **Status:** ✅ Merged **Merged:** 1/13/2020 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `develop` ← **Head:** `3898-cable-str-pk` --- ### 📝 Commits (5) - [`a2308b9`](https://github.com/netbox-community/netbox/commit/a2308b9c9949de742142f3a40600b5178b7216a9) Fixes #3898: Call str of cable on delete to save PK in id_string - [`49fa243`](https://github.com/netbox-community/netbox/commit/49fa243b4f9779d05e2e6e697b685b46484a265c) Added post-delete cable ID test - [`3d78a67`](https://github.com/netbox-community/netbox/commit/3d78a673431bfe370e95a4f82a90a11e0041932d) Store a private copy of the pk during init and use that with __str__ - [`608006e`](https://github.com/netbox-community/netbox/commit/608006ee776a2f6fe8e7174f196e9eb51757f19e) Set the private pk after super save - [`736cd70`](https://github.com/netbox-community/netbox/commit/736cd709d9382c9ed71b52e4ed98c859adfb4dcd) Merge branch 'develop' into 3898-cable-str-pk ### 📊 Changes **3 files changed** (+14 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `docs/release-notes/version-2.6.md` (+1 -0) 📝 `netbox/dcim/models.py` (+9 -7) 📝 `netbox/dcim/tests/test_models.py` (+4 -1) </details> ### 📄 Description ### Fixes: #3898 Called the `__str__` method of the cable to create the `self.id_string` attribute if not there. An alternative solution would've been to move the `msg` line before `delete()` is called, but I checked all models' `__str__` method and it's only `Cable` that uses the PK as part of the string. https://github.com/netbox-community/netbox/blob/b7e78028ce6e998dc9172bd41bc602045daeb1ea/netbox/utilities/views.py#L289-L295 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 22:23:03 +01:00
adam closed this issue 2025-12-29 22:23:03 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#12687