Compare commits

...
3 Commits
Author SHA1 Message Date
MrBlakeandClaude Opus 5.5 8cc861e6af Support NetBox up to 4.7.99
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-09-23 13:07:45 +02:00
MrBlakeandClaude Opus 5.5 1b9970b5dd fix: show rack elevation errors in the exported document
Rack SVG failures were only logged, leaving racks silently without an
image. The error is now written into the document next to the rack so
the cause (e.g. missing rack_elevation.css in STATIC_ROOT) is visible.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-09-23 13:07:45 +02:00
MrBlakeandClaude Opus 5.5 0719f42cb3 fix: render export form checkboxes as real checkboxes
The widgets lacked the form-check-input class, so NetBox's CSS showed
them as empty text inputs with no visible checked state. Also pass role
PKs as initial value so all device roles in scope are preselected.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-09-23 13:07:44 +02:00
4 changed files with 18 additions and 10 deletions

No files matched your search

+2 -2
View File
@@ -1,6 +1,6 @@
# NetBox Customer Export
NetBox-Plugin (4.6.8 – 4.6.99) zum Export einer verständlichen **Kundendokumentation als PDF oder Word**
NetBox-Plugin (4.6.8 – 4.7.99) zum Export einer verständlichen **Kundendokumentation als PDF oder Word**
für einen **Standort, eine Lokation, einen Mandanten oder eine Mandantengruppe**.
Der Techniker wählt vor dem Export aus, welche Inhalte das Dokument enthalten soll:
@@ -127,7 +127,7 @@ pip show netbox-customer-export
### NetBox-Update
Beim NetBox-Update installiert `sudo /opt/netbox/upgrade.sh` das Plugin automatisch aus `local_requirements.txt` neu.
Vorher prüfen, ob die Plugin-Version die neue NetBox-Version unterstützt (`min_version`/`max_version`, aktuell 4.6.8 – 4.6.99).
Vorher prüfen, ob die Plugin-Version die neue NetBox-Version unterstützt (`min_version`/`max_version`, aktuell 4.6.8 – 4.7.99).
Andernfalls verweigert NetBox den Start.
## Deinstallation
+5 -1
View File
@@ -67,12 +67,16 @@ class ExportForm(forms.Form):
def __init__(self, *args, scope=None, **kwargs):
super().__init__(*args, **kwargs)
# Ohne diese Klasse stellt NetBox' CSS die Checkboxen als leere Eingabefelder dar
for field in self.fields.values():
if isinstance(field.widget, (forms.CheckboxInput, forms.CheckboxSelectMultiple)):
field.widget.attrs["class"] = "form-check-input"
self.fields["branding"].choices = [(k, b["name"]) for k, b in get_brandings().items()]
if scope is not None:
role_ids = scope.devices().values("role")
roles = DeviceRole.objects.filter(pk__in=role_ids).order_by("name")
self.fields["roles"].queryset = roles
self.fields["roles"].initial = list(roles)
self.fields["roles"].initial = [r.pk for r in roles]
self.fields["title"].initial = f"Netzwerkdokumentation {scope.obj}"
self.fields["subtitle"].initial = f"{scope.label}: {scope.obj}"
if not get_plugin_config("netbox_customer_export", "allow_secrets"):
+4 -4
View File
@@ -8,7 +8,7 @@ logger = logging.getLogger("netbox_customer_export")
def render_rack_svg(rack, face, user):
"""Gibt das SVG als String zurück oder None bei Fehlern.
"""Gibt (svg, fehler) zurück – genau einer der beiden Werte ist None.
Ist ``rack_svg_renderer`` gesetzt (z.B. der Offline-Renderer aus Netbox-Utilities, der mehrere
Geräte pro HE korrekt darstellt), wird dieser aufgerufen: ``fn(rack=..., face=..., user=...)``.
@@ -22,7 +22,7 @@ def render_rack_svg(rack, face, user):
from dcim.svg import RackElevationSVG
svg = RackElevationSVG(rack, user=user, include_images=False, base_url="").render(face)
return svg.tostring() if hasattr(svg, "tostring") else str(svg)
except Exception: # noqa: BLE001 – ein defektes Rack soll nicht den ganzen Export abbrechen
return (svg.tostring() if hasattr(svg, "tostring") else str(svg)), None
except Exception as e: # noqa: BLE001 – ein defektes Rack soll nicht den ganzen Export abbrechen
logger.exception("Rack-SVG für %s (%s) fehlgeschlagen", rack, face)
return None
return None, f"{type(e).__name__}: {e}"
+7 -3
View File
@@ -172,13 +172,17 @@ def racks(scope, opts):
)
)
if opts.get("rack_svg"):
images = []
images, errors = [], []
for face in opts.get("rack_faces") or ["front"]:
svg = render_rack_svg(rack, face, scope.user)
caption = "Vorderseite" if face == "front" else "Rückseite"
svg, error = render_rack_svg(rack, face, scope.user)
if svg:
images.append((svg, "Vorderseite" if face == "front" else "Rückseite"))
images.append((svg, caption))
else:
errors.append(f"Rack-Ansicht ({caption}) konnte nicht erzeugt werden: {error}")
if images:
blocks.append(IMAGES(images))
blocks += [P(e) for e in errors]
if opts.get("rack_devices"):
devs = scope.restrict(rack.devices.all()).select_related("device_type__manufacturer").order_by("-position", "name")
if devs.exists():