Procházet zdrojové kódy

Merge pull request #4002 from hellerve/veit/fix-3982

Read reserved tooltip on rack elevations
Jeremy Stretch před 6 roky
rodič
revize
9f58c27fcf
1 změnil soubory, kde provedl 9 přidání a 4 odebrání
  1. 9 4
      netbox/dcim/models/__init__.py

+ 9 - 4
netbox/dcim/models/__init__.py

@@ -414,7 +414,7 @@ class RackElevationHelperMixin:
         drawing.add(drawing.text(str(device), insert=text))
         drawing.add(drawing.text(str(device), insert=text))
 
 
     @staticmethod
     @staticmethod
-    def _draw_empty(drawing, rack, start, end, text, id_, face_id, class_):
+    def _draw_empty(drawing, rack, start, end, text, id_, face_id, class_, reservation):
         link = drawing.add(
         link = drawing.add(
             drawing.a(
             drawing.a(
                 href='{}?{}'.format(
                 href='{}?{}'.format(
@@ -424,6 +424,10 @@ class RackElevationHelperMixin:
                 target='_top'
                 target='_top'
             )
             )
         )
         )
+        if reservation:
+            link.set_desc('{} — {} · {}'.format(
+                reservation.description, reservation.user, reservation.created
+            ))
         link.add(drawing.rect(start, end, class_=class_))
         link.add(drawing.rect(start, end, class_=class_))
         link.add(drawing.text("add device", insert=text, class_='add-device'))
         link.add(drawing.text("add device", insert=text, class_='add-device'))
 
 
@@ -453,12 +457,13 @@ class RackElevationHelperMixin:
             else:
             else:
                 # Draw shallow devices, reservations, or empty units
                 # Draw shallow devices, reservations, or empty units
                 class_ = 'slot'
                 class_ = 'slot'
+                reservation = reserved_units.get(unit["id"])
                 if device:
                 if device:
                     class_ += ' occupied'
                     class_ += ' occupied'
-                if unit["id"] in reserved_units:
+                if reservation:
                     class_ += ' reserved'
                     class_ += ' reserved'
                 self._draw_empty(
                 self._draw_empty(
-                    drawing, self, start_cordinates, end_cordinates, text_cordinates, unit["id"], face, class_
+                    drawing, self, start_cordinates, end_cordinates, text_cordinates, unit["id"], face, class_, reservation
                 )
                 )
 
 
             unit_cursor += height
             unit_cursor += height
@@ -493,7 +498,7 @@ class RackElevationHelperMixin:
             height of the elevation
             height of the elevation
         """
         """
         elevation = self.merge_elevations(face)
         elevation = self.merge_elevations(face)
-        reserved_units = self.get_reserved_units().keys()
+        reserved_units = self.get_reserved_units()
 
 
         return self._draw_elevations(elevation, reserved_units, face, unit_width, unit_height)
         return self._draw_elevations(elevation, reserved_units, face, unit_width, unit_height)