Skip to content

Commit abdcfde

Browse files
Adds description to elevation device tooltip (#12488)
* adds description to elevation device tooltip #11801 * changes as per review * changes as per review * Rearrange attrs, add headings, and update docstring --------- Co-authored-by: jeremystretch <[email protected]>
1 parent 9d62174 commit abdcfde

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

netbox/dcim/svg/racks.py

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,28 @@ def get_device_name(device):
3737

3838

3939
def get_device_description(device):
40-
return '{} ({}) — {} {} ({}U) {} {}'.format(
41-
device.name,
42-
device.device_role,
43-
device.device_type.manufacturer.name,
44-
device.device_type.model,
45-
floatformat(device.device_type.u_height),
46-
device.asset_tag or '',
47-
device.serial or ''
48-
)
40+
"""
41+
Return a description for a device to be rendered in the rack elevation in the following format
42+
43+
Name: <name>
44+
Role: <device_role>
45+
Device Type: <manufacturer> <model> (<u_height>)
46+
Asset tag: <asset_tag> (if defined)
47+
Serial: <serial> (if defined)
48+
Description: <description> (if defined)
49+
"""
50+
description = f'Name: {device.name}'
51+
description += f'\nRole: {device.device_role}'
52+
u_height = f'{floatformat(device.device_type.u_height)}U'
53+
description += f'\nDevice Type: {device.device_type.manufacturer.name} {device.device_type.model} ({u_height})'
54+
if device.asset_tag:
55+
description += f'\nAsset tag: {device.asset_tag}'
56+
if device.serial:
57+
description += f'\nSerial: {device.serial}'
58+
if device.description:
59+
description += f'\nDescription: {device.description}'
60+
61+
return description
4962

5063

5164
class RackElevationSVG:

0 commit comments

Comments
 (0)