Fixes #8092: Rack elevations should not include device asset tags

This commit is contained in:
jeremystretch 2021-12-18 14:26:32 -05:00
parent 2db82a73a5
commit 4723500c5f
2 changed files with 9 additions and 4 deletions

View File

@ -18,6 +18,7 @@
* [#8078](https://github.com/netbox-community/netbox/issues/8078) - Add missing wireless models to `lsmodels()` in `nbshell` * [#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 * [#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 * [#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 * [#8096](https://github.com/netbox-community/netbox/issues/8096) - Fix DataError during change logging of objects with very long string representations
--- ---

View File

@ -18,6 +18,10 @@ __all__ = (
) )
def get_device_name(device):
return device.name or str(device.device_type)
class RackElevationSVG: class RackElevationSVG:
""" """
Use this class to render a rack elevation as an SVG image. Use this class to render a rack elevation as an SVG image.
@ -85,7 +89,7 @@ class RackElevationSVG:
return drawing return drawing
def _draw_device_front(self, drawing, device, start, end, text): def _draw_device_front(self, drawing, device, start, end, text):
name = str(device) name = get_device_name(device)
if device.devicebay_count: if device.devicebay_count:
name += ' ({}/{})'.format(device.get_children().count(), 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 = drawing.rect(start, end, class_="slot blocked")
rect.set_desc(self._get_device_description(device)) rect.set_desc(self._get_device_description(device))
drawing.add(rect) 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 # Embed rear device type image if one exists
if self.include_images and device.device_type.rear_image: if self.include_images and device.device_type.rear_image:
@ -132,9 +136,9 @@ class RackElevationSVG:
) )
image.fit(scale='slice') image.fit(scale='slice')
drawing.add(image) 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')) 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 @staticmethod
def _draw_empty(drawing, rack, start, end, text, id_, face_id, class_, reservation): def _draw_empty(drawing, rack, start, end, text, id_, face_id, class_, reservation):