Просмотр исходного кода

Fixes #7459: Pre-populate location data when adding a device to a rack

jeremystretch 4 лет назад
Родитель
Сommit
c0010ec100
2 измененных файлов с 12 добавлено и 7 удалено
  1. 1 0
      docs/release-notes/version-3.0.md
  2. 11 7
      netbox/dcim/svg.py

+ 1 - 0
docs/release-notes/version-3.0.md

@@ -7,6 +7,7 @@
 * [#7442](https://github.com/netbox-community/netbox/issues/7442) - Fix missing actions column on user-configured tables
 * [#7446](https://github.com/netbox-community/netbox/issues/7446) - Fix exception when viewing a large number of child IPs within a prefix
 * [#7455](https://github.com/netbox-community/netbox/issues/7455) - Fix site/provider network validation for circuit termination API serializer
+* [#7459](https://github.com/netbox-community/netbox/issues/7459) - Pre-populate location data when adding a device to a rack
 
 ---
 

+ 11 - 7
netbox/dcim/svg.py

@@ -132,14 +132,18 @@ class RackElevationSVG:
 
     @staticmethod
     def _draw_empty(drawing, rack, start, end, text, id_, face_id, class_, reservation):
+        link_url = '{}?{}'.format(
+            reverse('dcim:device_add'),
+            urlencode({
+                'site': rack.site.pk,
+                'location': rack.location.pk if rack.location else '',
+                'rack': rack.pk,
+                'face': face_id,
+                'position': id_
+            })
+        )
         link = drawing.add(
-            drawing.a(
-                href='{}?{}'.format(
-                    reverse('dcim:device_add'),
-                    urlencode({'rack': rack.pk, 'site': rack.site.pk, 'face': face_id, 'position': id_})
-                ),
-                target='_top'
-            )
+            drawing.a(href=link_url, target='_top')
         )
         if reservation:
             link.set_desc('{} — {} · {}'.format(