1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Replaces device_role with role on device model (#13342)

* replaces device_role with role on device model #6391

* fixes lint issue #6391

* revert the database user

* revert test_runner comment

* changes as per review

* Update references to device_role column in UserConfigs

---------

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
This commit is contained in:
Abhimanyu Saharan
2023-08-02 19:25:52 +05:30
committed by GitHub
parent 79030ecab2
commit 0bb86f1e7d
37 changed files with 422 additions and 331 deletions

View File

@@ -167,9 +167,9 @@ class CableTraceSVG:
if hasattr(instance, 'parent_object'):
# Termination
return getattr(instance, 'color', 'f0f0f0') or 'f0f0f0'
if hasattr(instance, 'device_role'):
if hasattr(instance, 'role'):
# Device
return instance.device_role.color
return instance.role.color
else:
# Other parent object
return 'e0e0e0'

View File

@@ -46,14 +46,14 @@ def get_device_description(device):
Return a description for a device to be rendered in the rack elevation in the following format
Name: <name>
Role: <device_role>
Role: <role>
Device Type: <manufacturer> <model> (<u_height>)
Asset tag: <asset_tag> (if defined)
Serial: <serial> (if defined)
Description: <description> (if defined)
"""
description = f'Name: {device.name}'
description += f'\nRole: {device.device_role}'
description += f'\nRole: {device.role}'
u_height = f'{floatformat(device.device_type.u_height)}U'
description += f'\nDevice Type: {device.device_type.manufacturer.name} {device.device_type.model} ({u_height})'
if device.asset_tag:
@@ -205,7 +205,7 @@ class RackElevationSVG:
"""
Draw the front (mounted) face of a device.
"""
color = device.device_role.color
color = device.role.color
image = device.device_type.front_image
self._draw_device(device, coords, size, color=color, image=image)