fix: handle plain HttpResponse from elevation SVG endpoint, unracked devices

- RackElevationOfflineSVGView called .render() unconditionally on the
  RackViewSet elevation action's response, but that action returns a
  plain HttpResponse (not a DRF Response) when render=svg is
  requested, causing AttributeError on every click.
- effective_width_positions() crashed with decimal.InvalidOperation
  when a device had no rack position set (e.g. surfaced via NetBox
  Topology Views, which includes unracked devices). Such devices now
  get the default full-width result instead of entering the Decimal
  conversion.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-17 15:16:09 +02:00
co-authored by Claude Sonnet 5
parent c722abe497
commit 23acebcf17
5 changed files with 35 additions and 3 deletions
+2 -1
View File
@@ -391,7 +391,8 @@ class RackElevationOfflineSVGView(LoginRequiredMixin, View):
api_request.user = request.user
drf_view = RackViewSet.as_view({"get": "elevation"})
response = drf_view(api_request, pk=rack.pk)
response.render()
if hasattr(response, "render"):
response.render()
offline_svg = strip_svg_hyperlinks(response.content)
filename = f"{rack.name}-{face}-offline.svg".replace(" ", "_")