From 4723500c5fb8a6e069a132f99f5ed34cc4e9416d Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Sat, 18 Dec 2021 14:26:32 -0500 Subject: [PATCH] Fixes #8092: Rack elevations should not include device asset tags --- docs/release-notes/version-3.1.md | 1 + netbox/dcim/svg.py | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/docs/release-notes/version-3.1.md b/docs/release-notes/version-3.1.md index 117e22cca..9f9ed3b44 100644 --- a/docs/release-notes/version-3.1.md +++ b/docs/release-notes/version-3.1.md @@ -18,6 +18,7 @@ * [#8078](https://github.com/netbox-community/netbox/issues/8078) - Add missing wireless models to `lsmodels()` in `nbshell` * [#8079](https://github.com/netbox-community/netbox/issues/8079) - Fix validation of LLDP neighbors when connected device has an asset tag * [#8088](https://github.com/netbox-community/netbox/issues/8088) - Improve legibility of text in labels with light-colored backgrounds +* [#8092](https://github.com/netbox-community/netbox/issues/8092) - Rack elevations should not include device asset tags * [#8096](https://github.com/netbox-community/netbox/issues/8096) - Fix DataError during change logging of objects with very long string representations --- diff --git a/netbox/dcim/svg.py b/netbox/dcim/svg.py index e90890eeb..e19e8fa2f 100644 --- a/netbox/dcim/svg.py +++ b/netbox/dcim/svg.py @@ -18,6 +18,10 @@ __all__ = ( ) +def get_device_name(device): + return device.name or str(device.device_type) + + class RackElevationSVG: """ Use this class to render a rack elevation as an SVG image. @@ -85,7 +89,7 @@ class RackElevationSVG: return drawing def _draw_device_front(self, drawing, device, start, end, text): - name = str(device) + name = get_device_name(device) if device.devicebay_count: name += ' ({}/{})'.format(device.get_children().count(), device.devicebay_count) @@ -120,7 +124,7 @@ class RackElevationSVG: rect = drawing.rect(start, end, class_="slot blocked") rect.set_desc(self._get_device_description(device)) drawing.add(rect) - drawing.add(drawing.text(str(device), insert=text)) + drawing.add(drawing.text(get_device_name(device), insert=text)) # Embed rear device type image if one exists if self.include_images and device.device_type.rear_image: @@ -132,9 +136,9 @@ class RackElevationSVG: ) image.fit(scale='slice') drawing.add(image) - drawing.add(drawing.text(str(device), insert=text, stroke='black', + drawing.add(drawing.text(get_device_name(device), insert=text, stroke='black', stroke_width='0.2em', stroke_linejoin='round', class_='device-image-label')) - drawing.add(drawing.text(str(device), insert=text, fill='white', class_='device-image-label')) + drawing.add(drawing.text(get_device_name(device), insert=text, fill='white', class_='device-image-label')) @staticmethod def _draw_empty(drawing, rack, start, end, text, id_, face_id, class_, reservation):