fix: technician topology for all sites, per location and combined

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
MrBlakeandClaude Opus 5.5 committed 2026-11-27 09:58:58 +01:00
1 parent 677590f52c
commit daf8bc671b
9 files changed
+51 -7

No files matched your search

+1 -1
View File
@@ -6,7 +6,7 @@ class CustomerExportConfig(PluginConfig):
name = "netbox_customer_export"
verbose_name = _("Customer Export")
description = _("Export customer documentation as PDF or Word")
version = "0.20.0"
version = "0.20.1"
author = "Claude"
base_url = "customer-export"
min_version = "4.6.8"
+11
View File
@@ -89,6 +89,17 @@ class ExportForm(forms.Form):
widget=forms.CheckboxSelectMultiple,
label=_("Scope"),
)
topo_tech_per = forms.MultipleChoiceField(
choices=(
("all", _("All in one diagram")),
("site", _("Per site")),
("location", _("Per location")),
),
initial=["all", "site"],
required=False,
widget=forms.CheckboxSelectMultiple,
label=_("Technician version"),
)
topo_external = forms.BooleanField(
required=False, initial=True, label=_("Show provider circuits and devices outside the scope")
)
@@ -1584,3 +1584,18 @@ msgstr "Über (Patchpanel)"
msgid "Circuit"
msgstr "Leitung"
msgid "All in one diagram"
msgstr "Alles in einem Diagramm"
msgid "Per site"
msgstr "Je Standort"
msgid "Per location"
msgstr "Je Lokation"
msgid "Location %(name)s (%(site)s)"
msgstr "Lokation %(name)s (%(site)s)"
msgid "Only used if “Technician version” is selected above. Each connection is numbered and listed with exact ports in a table."
msgstr "Nur wirksam, wenn oben „Techniker-Version“ gewählt ist. Jede Verbindung wird nummeriert und mit genauen Ports in einer Tabelle aufgeführt."
+5 -1
View File
@@ -628,7 +628,11 @@ def topology(scope, opts):
if "technician" in scopes:
from .topology import number_connections
for i, g in enumerate(build_graphs(scope, opts, per="site")):
graphs = []
for per in ("all", "site", "location"):
if per in (opts.get("topo_tech_per") or ["all", "site"]):
graphs += build_graphs(scope, opts, per=per)
for i, g in enumerate(graphs):
rows = number_connections(g)
head = ([H(2, _("Technician version"))] if i == 0 else []) + [H(3, g.title)]
tech.append((head, g, rows))
@@ -177,6 +177,9 @@
<div class="ce-label mt-0">{{ form.topo_scope.label }}</div>
{% include 'netbox_customer_export/_pills.html' with field=form.topo_scope %}
<div class="form-text mb-2">{% trans "“Location overview” shows all locations of a site and the cables between them, from the server room to the last sub-distribution. “Cross-site” combines all sites in one diagram to show how buildings and their locations are connected. “Per rack” shows each rack separately. Connected devices outside appear dashed." %}</div>
<div class="ce-label">{{ form.topo_tech_per.label }}</div>
{% include 'netbox_customer_export/_pills.html' with field=form.topo_tech_per %}
<div class="form-text mb-2">{% trans "Only used if “Technician version” is selected above. Each connection is numbered and listed with exact ports in a table." %}</div>
<div class="ce-label">{{ form.topo_details.label }}</div>
{% include 'netbox_customer_export/_pills.html' with field=form.topo_details %}
<div class="ce-label">{% trans "More" %}</div>
+14 -3
View File
@@ -85,7 +85,7 @@ def _device_sub(device, opts):
def build_graphs(scope, opts, per="site"):
"""Ein Graph je Standort (per="site") oder je Rack (per="rack").
"""Ein Graph je Standort (per="site"), Lokation (per="location"), Rack (per="rack") oder einer für alles (per="all").
Verbundene Geräte außerhalb der Gruppe (anderer Standort/anderes Rack) und Provider-Leitungen erscheinen
als externe, gestrichelte Knoten – so sieht man auch in der Rack-Ansicht, wohin die Uplinks gehen.
@@ -98,7 +98,12 @@ def build_graphs(scope, opts, per="site"):
groups = OrderedDict()
for pk in drawn:
d = by_pk[pk]
key = d.site if per == "site" else d.rack
if per == "all":
key = "all"
elif per == "location":
key = d.location or d.site
else:
key = d.site if per == "site" else d.rack
if key is not None:
groups.setdefault(key, []).append(pk)
if per == "rack":
@@ -110,6 +115,8 @@ def build_graphs(scope, opts, per="site"):
"""Untertitel eines externen Geräts: wo es steht."""
if per == "rack":
return [_("Rack %(name)s") % {"name": d.rack} if d.rack else str(d.site)]
if per == "location" and d.location:
return [f"{d.site} / {d.location}"]
return [str(d.site)]
graphs = []
@@ -139,8 +146,12 @@ def build_graphs(scope, opts, per="site"):
nodes = OrderedDict((k, v) for k, v in nodes.items() if k in linked)
if nodes:
_layout(nodes, edges)
if per == "site":
if per == "all":
title = _("All sites")
elif per == "site" or (per == "location" and not hasattr(group, "site")):
title = _("Site %(name)s") % {"name": group}
elif per == "location":
title = _("Location %(name)s (%(site)s)") % {"name": group, "site": group.site}
else:
where = " / ".join(str(x) for x in (group.site, group.location) if x)
title = _("Rack %(name)s (%(where)s)") % {"name": group.name, "where": where}