Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Message when disconnecting a cable not showing ID #3898

Closed
hSaria opened this issue Jan 12, 2020 · 4 comments · Fixed by #3899
Closed

Message when disconnecting a cable not showing ID #3898

hSaria opened this issue Jan 12, 2020 · 4 comments · Fixed by #3899
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@hSaria
Copy link
Contributor

hSaria commented Jan 12, 2020

Environment

  • Python version: 3.6.8
  • NetBox version: 2.6.12-dev

Steps to Reproduce

  1. Go to a device (e.g. dcim/devices/1/)
  2. Disconnect a cable

Expected Behavior

The message says Deleted cable #5 where 5 is the ID of the cable.

Observed Behavior

The message says #None

This is similar to #2984

@phurrelmann
Copy link
Contributor

Maybe it would even be better to display the label if it is given. This would mimic the behaviour as shown on the device/interface view where the cable id is only displayed when the cable has no label set.

@hSaria
Copy link
Contributor Author

hSaria commented Jan 12, 2020

It already does. The issue is that self.id_string wasn't assigned prior to getting deleted. It's only the PK that gets nullified when deleted so the label is unaffected by this issue.

netbox/netbox/dcim/models.py

Lines 3030 to 3038 in b7e7802

def __str__(self):
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

@phurrelmann
Copy link
Contributor

perfect, then I misunderstood your comment. Sorry and thank you for your impressive work on old tickets over he last days 👍

@hSaria
Copy link
Contributor Author

hSaria commented Jan 12, 2020

Nothing to be sorry for. In fact, I appreciate you looking out, so thanks for that and keep it coming. And I'm just giving back some love to this project that clearly deserves it.

@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application labels Jan 13, 2020
jeremystretch added a commit that referenced this issue Jan 13, 2020
Fixes #3898: Call str of cable on delete to save PK in id_string
@lock lock bot locked as resolved and limited conversation to collaborators Apr 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants