revert: defer rack images to NetBox
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from netbox.plugins import PluginConfig, get_plugin_config
|
||||
|
||||
__version__ = "0.8.7"
|
||||
__version__ = "0.8.8"
|
||||
|
||||
|
||||
class NetBoxUtilitiesConfig(PluginConfig):
|
||||
|
||||
@@ -465,7 +465,6 @@ def _install_rack_svg():
|
||||
elevation.draw_device_front(device, coords, size)
|
||||
else:
|
||||
elevation.draw_device_rear(device, coords, size)
|
||||
_fit_latest_elevation_image(elevation.drawing)
|
||||
else:
|
||||
from svgwrite.shapes import Rect
|
||||
|
||||
@@ -497,19 +496,6 @@ def _partial_width_elevation_devices(rack, face):
|
||||
)
|
||||
|
||||
|
||||
def _fit_latest_elevation_image(drawing):
|
||||
"""Fit the latest device image into a partial-width slot without cropping it."""
|
||||
from svgwrite.image import Image
|
||||
|
||||
if not getattr(drawing, "elements", None):
|
||||
return
|
||||
container = drawing.elements[-1]
|
||||
for element in reversed(getattr(container, "elements", ())):
|
||||
if isinstance(element, Image):
|
||||
element.fit(scale="meet")
|
||||
return
|
||||
|
||||
|
||||
def _validate_before_save(sender, instance, raw=False, **kwargs):
|
||||
if not raw:
|
||||
using = kwargs.get("using")
|
||||
|
||||
@@ -13,7 +13,6 @@ from django.urls import resolve, reverse
|
||||
|
||||
from netbox_utilities.rack_width import (
|
||||
_cleanup_unracked_placement,
|
||||
_fit_latest_elevation_image,
|
||||
_partial_width_elevation_devices,
|
||||
available_units_for_device,
|
||||
horizontal_interval,
|
||||
@@ -33,22 +32,6 @@ class RackWidthTest(SimpleTestCase):
|
||||
self.assertIn("positionField.disabled = width === 1", script)
|
||||
self.assertIn("positionField.tomselect.sync()", script)
|
||||
|
||||
def test_partial_width_device_image_is_fitted_without_cropping(self):
|
||||
from svgwrite import Drawing
|
||||
from svgwrite.container import Hyperlink
|
||||
from svgwrite.image import Image
|
||||
|
||||
drawing = Drawing()
|
||||
link = Hyperlink("/dcim/devices/1/")
|
||||
device_image = Image("/media/device.png", size=(100, 20))
|
||||
device_image.fit(scale="slice")
|
||||
link.add(device_image)
|
||||
drawing.add(link)
|
||||
|
||||
_fit_latest_elevation_image(drawing)
|
||||
|
||||
self.assertEqual(device_image.attribs["preserveAspectRatio"], "xMidYMid meet")
|
||||
|
||||
def test_partial_width_svg_devices_include_core_device_bay_annotation(self):
|
||||
from dcim.choices import DeviceFaceChoices
|
||||
from dcim.models import Rack
|
||||
|
||||
Reference in New Issue
Block a user