Skip to content

Commit 4723500

Browse files
committed
Fixes #8092: Rack elevations should not include device asset tags
1 parent 2db82a7 commit 4723500

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

docs/release-notes/version-3.1.md

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* [#8078](https://github.com/netbox-community/netbox/issues/8078) - Add missing wireless models to `lsmodels()` in `nbshell`
1919
* [#8079](https://github.com/netbox-community/netbox/issues/8079) - Fix validation of LLDP neighbors when connected device has an asset tag
2020
* [#8088](https://github.com/netbox-community/netbox/issues/8088) - Improve legibility of text in labels with light-colored backgrounds
21+
* [#8092](https://github.com/netbox-community/netbox/issues/8092) - Rack elevations should not include device asset tags
2122
* [#8096](https://github.com/netbox-community/netbox/issues/8096) - Fix DataError during change logging of objects with very long string representations
2223

2324
---

netbox/dcim/svg.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
)
1919

2020

21+
def get_device_name(device):
22+
return device.name or str(device.device_type)
23+
24+
2125
class RackElevationSVG:
2226
"""
2327
Use this class to render a rack elevation as an SVG image.
@@ -85,7 +89,7 @@ def _setup_drawing(width, height):
8589
return drawing
8690

8791
def _draw_device_front(self, drawing, device, start, end, text):
88-
name = str(device)
92+
name = get_device_name(device)
8993
if device.devicebay_count:
9094
name += ' ({}/{})'.format(device.get_children().count(), device.devicebay_count)
9195

@@ -120,7 +124,7 @@ def _draw_device_rear(self, drawing, device, start, end, text):
120124
rect = drawing.rect(start, end, class_="slot blocked")
121125
rect.set_desc(self._get_device_description(device))
122126
drawing.add(rect)
123-
drawing.add(drawing.text(str(device), insert=text))
127+
drawing.add(drawing.text(get_device_name(device), insert=text))
124128

125129
# Embed rear device type image if one exists
126130
if self.include_images and device.device_type.rear_image:
@@ -132,9 +136,9 @@ def _draw_device_rear(self, drawing, device, start, end, text):
132136
)
133137
image.fit(scale='slice')
134138
drawing.add(image)
135-
drawing.add(drawing.text(str(device), insert=text, stroke='black',
139+
drawing.add(drawing.text(get_device_name(device), insert=text, stroke='black',
136140
stroke_width='0.2em', stroke_linejoin='round', class_='device-image-label'))
137-
drawing.add(drawing.text(str(device), insert=text, fill='white', class_='device-image-label'))
141+
drawing.add(drawing.text(get_device_name(device), insert=text, fill='white', class_='device-image-label'))
138142

139143
@staticmethod
140144
def _draw_empty(drawing, rack, start, end, text, id_, face_id, class_, reservation):

0 commit comments

Comments
 (0)