Skip to content

Commit c0010ec

Browse files
committed
Fixes #7459: Pre-populate location data when adding a device to a rack
1 parent 6897c5f commit c0010ec

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

docs/release-notes/version-3.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* [#7442](https://github.com/netbox-community/netbox/issues/7442) - Fix missing actions column on user-configured tables
88
* [#7446](https://github.com/netbox-community/netbox/issues/7446) - Fix exception when viewing a large number of child IPs within a prefix
99
* [#7455](https://github.com/netbox-community/netbox/issues/7455) - Fix site/provider network validation for circuit termination API serializer
10+
* [#7459](https://github.com/netbox-community/netbox/issues/7459) - Pre-populate location data when adding a device to a rack
1011

1112
---
1213

netbox/dcim/svg.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,18 @@ def _draw_device_rear(self, drawing, device, start, end, text):
132132

133133
@staticmethod
134134
def _draw_empty(drawing, rack, start, end, text, id_, face_id, class_, reservation):
135+
link_url = '{}?{}'.format(
136+
reverse('dcim:device_add'),
137+
urlencode({
138+
'site': rack.site.pk,
139+
'location': rack.location.pk if rack.location else '',
140+
'rack': rack.pk,
141+
'face': face_id,
142+
'position': id_
143+
})
144+
)
135145
link = drawing.add(
136-
drawing.a(
137-
href='{}?{}'.format(
138-
reverse('dcim:device_add'),
139-
urlencode({'rack': rack.pk, 'site': rack.site.pk, 'face': face_id, 'position': id_})
140-
),
141-
target='_top'
142-
)
146+
drawing.a(href=link_url, target='_top')
143147
)
144148
if reservation:
145149
link.set_desc('{} — {} · {}'.format(

0 commit comments

Comments
 (0)