feat: rack photo appendix and virtualization cluster section

Rack image attachments can be picked with thumbnails in the export form and
are placed in an appendix, linked from below each rack elevation (Word:
internal hyperlinks to bookmarks). New section lists clusters with hosts and
summed VM resources, counting only VMs inside the export scope.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
MrBlakeandClaude Opus 5.5 committed 2026-10-28 15:17:17 +01:00
1 parent 74dfa0ec61
commit c888a65180
12 files changed
+314 -16

No files matched your search

+18 -1
View File
@@ -28,7 +28,7 @@ Before exporting, the technician selects which content the document contains:
| Group | Content |
|---|---|
| General | Overview & site data (address, location tree, key figures), contacts |
| Infrastructure | Racks by site → location with rack elevation (front/rear, optionally with device images as in NetBox) and occupancy list, devices by **selectable device roles** (servers, switches, APs, routers …) with **selectable columns**, power, VMs, **disks & RAID** from [Netbox-Utilities](https://git.mrblake.cc/MrBlake/Netbox-Utilities) (if installed) |
| Infrastructure | Racks by site → location with rack elevation (front/rear, optionally with device images as in NetBox) occupancy list and optional **rack photos** in an appendix, devices by **selectable device roles** (servers, switches, APs, routers …) with **selectable columns**, power, **virtualization clusters** with resources, VMs, **disks & RAID** from [Netbox-Utilities](https://git.mrblake.cc/MrBlake/Netbox-Utilities) (if installed) |
| Network | VRFs (incl. RTs), prefixes by VRF, VLANs, IP addresses (detailed), WLANs/SSIDs, circuits, **network topology** |
| Contracts & licenses | Licenses from [NetBox-SLM](https://git.mrblake.cc/MrBlake/NetBox-SLM) (detected automatically) or another license plugin (e.g. `netbox-lifecycle`) |
@@ -304,6 +304,23 @@ slot, status, type, model, size, serial number, firmware, RAID group, optionally
expired/expiring soon, too old – thresholds from the Utilities configuration). Removed disks (history) are not shown.
Without the plugin the section stays empty.
### Rack photos
Images attached to racks in NetBox (*Attach an image*) show up as thumbnails in the
**Rack photos** card of the export form, grouped by rack. Selected photos are
placed in an appendix at the end of the document. Below each rack elevation a link
points to that rack's photos, and each appendix entry links back to the rack. Photos
are rotated according to EXIF and scaled down to 1600 px. In Word the links are internal
hyperlinks to bookmarks.
### Virtualization clusters
The **Virtualization clusters** section (off by default) lists every cluster with hosts
or VMs in scope: an overview table, then per cluster type, group, status, tenant and the
summed vCPU, RAM and disk of its VMs, plus a host table with VMs, vCPU and RAM per host.
Only VMs inside the export scope are counted, so a tenant export does not reveal other
tenants' VMs on a shared cluster.
### Rack elevations
By default the plugin uses NetBox's own `dcim.svg.RackElevationSVG` in-process
+1 -1
View File
@@ -5,7 +5,7 @@ class CustomerExportConfig(PluginConfig):
name = "netbox_customer_export"
verbose_name = "Kunden-Export"
description = "Kundendokumentation als PDF oder Word exportieren"
version = "0.11.1"
version = "0.12.0"
author = "Claude"
base_url = "customer-export"
min_version = "4.6.8"
+12 -5
View File
@@ -9,7 +9,7 @@ EMPTY = "—"
@dataclass
class Block:
kind: str # heading | paragraph | table | kv | images | pagebreak
kind: str # heading | paragraph | ref | table | kv | images | pagebreak | landscape
level: int = 0
text: str = ""
headers: list = field(default_factory=list)
@@ -47,6 +47,11 @@ def P(text):
return Block("paragraph", text=str(text))
def REF(text, target, prefix=""):
"""Interner Verweis auf eine Überschrift (target = deren anchor); prefix bleibt unverlinkt."""
return Block("ref", text=str(text), anchor=target, rows=[prefix])
def T(headers, rows):
return Block("table", headers=list(headers), rows=[[fmt(c) for c in r] for r in rows])
@@ -56,18 +61,20 @@ def KV(pairs, skip_empty=True):
return Block("kv", rows=rows)
def IMAGES(images, wide=False):
"""images: Liste von (svg_string oder None, caption, png_bytes_oder_None)."""
def IMAGES(images, wide=False, photos=False):
"""images: Liste von (svg_string oder None, caption, png_bytes_oder_None). Statt PNG geht auch JPEG."""
out = []
for svg, caption, png in images:
if svg:
data_uri = "data:image/svg+xml;base64," + base64.b64encode(svg.encode("utf-8")).decode("ascii")
elif png:
data_uri = "data:image/png;base64," + base64.b64encode(png).decode("ascii")
mime = "image/jpeg" if png[:2] == bytes((0xFF, 0xD8)) else "image/png"
data_uri = f"data:{mime};base64," + base64.b64encode(png).decode("ascii")
else:
continue
out.append({"svg": svg, "png": png, "caption": caption, "data_uri": data_uri})
return Block("images", images=out, level=1 if wide else 0) # level=1: volle Seitenbreite
# level=1: volle Seitenbreite, level=2: Fotos (zwei je Zeile)
return Block("images", images=out, level=2 if photos else 1 if wide else 0)
def LANDSCAPE(headings, png):
+7
View File
@@ -66,6 +66,7 @@ class ExportForm(forms.Form):
)
rack_devices = forms.BooleanField(required=False, initial=True, label="Geräteliste je Rack")
rack_pagebreak = forms.BooleanField(required=False, initial=True, label="Seitenumbruch nach jedem Rack")
rack_photos = forms.MultipleChoiceField(choices=(), required=False, widget=forms.CheckboxSelectMultiple, label="Rack-Fotos")
topo_details = forms.MultipleChoiceField(
choices=(("model", "Modell"), ("primary_ip", "Management-IP"), ("ports", "Ports an Verbindungen")),
@@ -108,6 +109,12 @@ class ExportForm(forms.Form):
elif isinstance(field.widget, forms.TextInput):
field.widget.attrs["class"] = "form-control"
self.fields["branding"].choices = [(k, b["name"]) for k, b in get_brandings().items()]
self.photo_groups = []
if scope is not None:
from .rack_photos import grouped
self.photo_groups = grouped(scope)
self.fields["rack_photos"].choices = [(str(a.pk), a.name) for _r, atts in self.photo_groups for a in atts]
if scope is not None:
role_ids = scope.devices().values("role")
roles = DeviceRole.objects.filter(pk__in=role_ids).order_by("name")
+58
View File
@@ -0,0 +1,58 @@
"""Bildanhänge (extras.ImageAttachment) von Racks: Auswahl im Formular und Anhang am Dokumentende."""
from io import BytesIO
from dcim.models import Rack
from django.contrib.contenttypes.models import ContentType
from extras.models import ImageAttachment
MAX_EDGE = 1600 # px – Handyfotos verkleinern, damit PDF/Word handlich bleiben
def attachments(scope):
"""Bildanhänge aller Racks im Scope, die der Benutzer sehen darf – sortiert nach Rack."""
racks = {r.pk: r for r in scope.racks().select_related("site", "location")}
if not racks:
return []
qs = (
ImageAttachment.objects.restrict(scope.user, "view")
.filter(object_type=ContentType.objects.get_for_model(Rack), object_id__in=racks)
.order_by("name", "pk")
)
items = [(racks[a.object_id], a) for a in qs]
items.sort(key=lambda x: (str(x[0].site), str(x[0].location or ""), x[0].name))
return items
def grouped(scope):
"""[(rack, [attachment, …]), …] für die Vorschau im Formular."""
out = []
for rack, att in attachments(scope):
if out and out[-1][0] == rack:
out[-1][1].append(att)
else:
out.append((rack, [att]))
return out
def caption(att):
name = att.name or att.image.name.rsplit("/", 1)[-1]
desc = getattr(att, "description", "")
return f"{name} – {desc}" if desc else name
def load_jpeg(att):
"""Bild drehen (EXIF), verkleinern und als JPEG zurückgeben. None, wenn nicht lesbar."""
from PIL import Image, ImageOps
try:
with att.image.open("rb") as f:
img = Image.open(BytesIO(f.read()))
img = ImageOps.exif_transpose(img)
img.thumbnail((MAX_EDGE, MAX_EDGE))
if img.mode != "RGB":
img = img.convert("RGB")
out = BytesIO()
img.save(out, "JPEG", quality=85)
return out.getvalue()
except Exception: # noqa: BLE001 – fehlende/defekte Datei überspringen
return None
+56 -3
View File
@@ -1,3 +1,4 @@
import re
import zipfile
from io import BytesIO
@@ -18,6 +19,11 @@ def _svg_to_png(svg):
return None
def _bookmark_name(anchor):
"""Word-Textmarken: max. 40 Zeichen, Buchstabe vorne, nur Buchstaben/Ziffern/_."""
return ("_ce_" + re.sub(r"\W", "_", anchor))[:40]
def _load_template(path):
"""Öffnet eine .docx/.dotx-Vorlage und leert deren Textkörper (Formatvorlagen, Kopf-/Fußzeile bleiben)."""
from docx import Document as Docx
@@ -138,6 +144,38 @@ def render_docx(doc):
s.header_distance, s.footer_distance) = portrait_margins
return s
targets = {blk.anchor for blk in doc.blocks if blk.kind == "ref"}
bookmark_id = [0]
def add_bookmark(paragraph, anchor):
bookmark_id[0] += 1
start = OxmlElement("w:bookmarkStart")
start.set(qn("w:id"), str(bookmark_id[0]))
start.set(qn("w:name"), _bookmark_name(anchor))
end = OxmlElement("w:bookmarkEnd")
end.set(qn("w:id"), str(bookmark_id[0]))
paragraph._p.insert(1 if paragraph._p.pPr is not None else 0, start)
paragraph._p.append(end)
def add_link(paragraph, text, anchor):
link = OxmlElement("w:hyperlink")
link.set(qn("w:anchor"), _bookmark_name(anchor))
run = OxmlElement("w:r")
rpr = OxmlElement("w:rPr")
color = OxmlElement("w:color")
color.set(qn("w:val"), b["primary_color"])
underline = OxmlElement("w:u")
underline.set(qn("w:val"), "single")
rpr.append(color)
rpr.append(underline)
run.append(rpr)
t = OxmlElement("w:t")
t.text = text
t.set(qn("xml:space"), "preserve")
run.append(t)
link.append(run)
paragraph._p.append(link)
for blk in doc.blocks:
if landscape_open and blk.kind != "landscape":
# erst beim nächsten Inhalt zurück ins Hochformat – vermeidet leere Seiten
@@ -167,9 +205,18 @@ def render_docx(doc):
else:
para.add_run().add_picture(BytesIO(png), height=avail_h)
elif blk.kind == "heading":
d.add_heading(blk.text, level=min(blk.level, 4))
heading = d.add_heading(blk.text, level=min(blk.level, 4))
if blk.anchor in targets:
add_bookmark(heading, blk.anchor)
elif blk.kind == "paragraph":
d.add_paragraph(blk.text)
elif blk.kind == "ref":
para = d.add_paragraph()
if blk.rows and blk.rows[0]:
para.add_run(blk.rows[0])
add_link(para, blk.text, blk.anchor)
for r in para.runs:
r.font.size = Pt(max(b["font_size"] - 1, 7))
elif blk.kind == "pagebreak":
d.add_page_break()
elif blk.kind in ("table", "kv"):
@@ -209,8 +256,14 @@ def render_docx(doc):
cell = t.cell(0, i).paragraphs[0]
cell.alignment = WD_ALIGN_PARAGRAPH.CENTER
if png:
# Topologie: volle Breite; Racks: 7 cm (Höhe skaliert mit der Rackgröße)
cell.add_run().add_picture(BytesIO(png), width=Cm(16.5 if blk.level == 1 else 7))
# Topologie: volle Breite; Fotos: halbe Breite; Racks: 7 cm (Höhe skaliert mit der Rackgröße)
width = {1: 16.5, 2: 8}.get(blk.level, 7)
if blk.level == 2:
from PIL import Image
px_w, px_h = Image.open(BytesIO(png)).size
width = min(width, 9 * px_w / px_h) # Hochformat-Fotos auf max. 9 cm Höhe begrenzen
cell.add_run().add_picture(BytesIO(png), width=Cm(width))
else:
cell.add_run("(Rack-Grafik nicht verfügbar)")
cap = t.cell(1, i).paragraphs[0]
+7 -1
View File
@@ -5,7 +5,7 @@ from circuits.models import Circuit
from dcim.models import Device, Location, PowerFeed, Rack, Site
from ipam.models import VLAN, VRF, IPAddress, Prefix
from tenancy.models import Tenant, TenantGroup
from virtualization.models import VirtualMachine
from virtualization.models import Cluster, VirtualMachine
from wireless.models import WirelessLAN
SCOPE_MODELS = {
@@ -81,6 +81,12 @@ class Scope:
def devices(self):
return self._qs(Device, site=("site",), location=("location",))
def clusters(self):
"""Cluster am Scope selbst oder mit Hosts/VMs im Scope."""
own = Cluster.objects.filter(self._q(site=("_site",), location=("_location",), tenant=("tenant",)))
q = Q(pk__in=own.values("pk")) | Q(pk__in=self.devices().values("cluster")) | Q(pk__in=self.virtual_machines().values("cluster"))
return self.restrict(Cluster.objects.filter(q).distinct())
def virtual_machines(self):
return self._qs(
VirtualMachine,
+111 -2
View File
@@ -7,7 +7,7 @@ from django.apps import apps
from django.contrib.contenttypes.models import ContentType
from netbox.plugins import get_plugin_config
from .blocks import EMPTY, H, IMAGES, KV, LANDSCAPE, P, PAGEBREAK, T, get
from .blocks import EMPTY, H, IMAGES, KV, LANDSCAPE, P, PAGEBREAK, REF, T, get
from .rack_png import render_rack_png
from .rack_svg import render_rack_svg
@@ -171,12 +171,14 @@ def racks(scope, opts):
blocks = [H(1, "Racks")]
if not qs.exists():
return _empty(opts, blocks)
photos = _rack_photos(scope, opts)
for site, site_racks in groupby(qs, key=lambda r: r.site):
blocks.append(H(2, f"Standort {site}"))
for location, loc_racks in groupby(site_racks, key=lambda r: r.location):
blocks.append(H(3, f"Lokation {location}" if location else "Ohne Lokation"))
for rack in loc_racks:
blocks.append(H(4, f"Rack {rack.name}"))
rack_heading = H(4, f"Rack {rack.name}")
blocks.append(rack_heading)
blocks.append(
KV(
[
@@ -225,11 +227,47 @@ def racks(scope, opts):
],
)
)
if rack.pk in photos:
blocks += _photo_appendix(opts, rack, rack_heading, photos[rack.pk])
if opts.get("rack_pagebreak"):
blocks.append(PAGEBREAK())
return blocks
def _rack_photos(scope, opts):
"""Ausgewählte Bildanhänge je Rack-ID."""
selected = set(opts.get("rack_photos") or [])
if not selected:
return {}
from . import rack_photos
out = {}
for rack, att in rack_photos.attachments(scope):
if str(att.pk) in selected:
out.setdefault(rack.pk, []).append(att)
return out
def _photo_appendix(opts, rack, rack_heading, atts):
"""Legt die Fotos im Anhang ab (opts["_appendix"]) und liefert den Verweis unter der Rack-Ansicht."""
from . import rack_photos
images = [(None, rack_photos.caption(a), data) for a in atts if (data := rack_photos.load_jpeg(a))]
if not images:
return []
appendix = opts.setdefault("_appendix", [])
if not appendix:
appendix.append(H(1, "Anhang: Rack-Fotos"))
where = " / ".join(str(x) for x in (rack.site, rack.location) if x)
heading = H(2, f"Rack {rack.name}" + (f" ({where})" if where else ""))
appendix.append(heading)
for i in range(0, len(images), 2): # zwei Fotos je Zeile
appendix.append(IMAGES(images[i:i + 2], photos=True))
appendix.append(REF("Zurück zur Rack-Ansicht", rack_heading.anchor, prefix="↑ "))
n = len(images)
return [REF(f"Anhang Rack-Fotos – Rack {rack.name}", heading.anchor, prefix=f"{n} Foto{'s' if n != 1 else ''}, siehe ")]
@section("devices", "Geräte", "Infrastruktur", hint="Tabellen je Geräterolle")
def devices(scope, opts):
blocks = [H(1, "Geräte")]
@@ -279,6 +317,77 @@ def power(scope, opts):
return blocks
def _mb(value):
"""MB als lesbare Größe (VM-RAM/-Disk sind in NetBox in MB gespeichert)."""
if not value:
return EMPTY
for unit, size in (("TB", 1000 ** 2), ("GB", 1000)):
if value >= size:
return f"{value / size:.1f} {unit}".replace(".0 ", " ").replace(".", ",")
return f"{value} MB"
def _vm_totals(vms):
return (
sum(vm.vcpus or 0 for vm in vms),
sum(vm.memory or 0 for vm in vms),
sum(vm.disk or 0 for vm in vms),
)
@section("clusters", "Virtualisierungs-Cluster", "Infrastruktur", default=False, hint="Hosts und Ressourcen je Cluster")
def clusters(scope, opts):
qs = scope.clusters().select_related("type", "group", "tenant").order_by("group__name", "name")
blocks = [H(1, "Virtualisierungs-Cluster")]
if not qs.exists():
return _empty(opts, blocks)
vms_by_cluster = {}
for vm in scope.virtual_machines().select_related("device"):
vms_by_cluster.setdefault(vm.cluster_id, []).append(vm)
summary, details = [], []
for cluster in qs:
vms = vms_by_cluster.get(cluster.pk, [])
hosts = list(scope.restrict(cluster.devices.all()).select_related("device_type__manufacturer").order_by("name"))
vcpu, ram, disk = _vm_totals(vms)
active = sum(1 for vm in vms if vm.status == "active")
summary.append([cluster.name, cluster.type, len(hosts), f"{active} / {len(vms)}", f"{vcpu:g}" if vcpu else EMPTY, _mb(ram), _mb(disk)])
details.append(H(2, f"Cluster {cluster.name}"))
details.append(KV([
("Typ", cluster.type),
("Gruppe", cluster.group),
("Status", get(cluster, "status")),
("Zuordnung", getattr(cluster, "scope", None)),
("Mandant", cluster.tenant),
("Hosts", len(hosts)),
("VMs aktiv / gesamt", f"{active} / {len(vms)}"),
("vCPU (Summe)", f"{vcpu:g}" if vcpu else None),
("RAM (Summe)", _mb(ram) if ram else None),
("Speicher (Summe)", _mb(disk) if disk else None),
("Beschreibung", cluster.description),
]))
if hosts:
rows = []
for host in hosts:
host_vms = [vm for vm in vms if vm.device_id == host.pk]
h_vcpu, h_ram, _h_disk = _vm_totals(host_vms)
rows.append([
host.name,
f"{host.device_type.manufacturer} {host.device_type.model}",
get(host, "status"),
len(host_vms) if host_vms else EMPTY,
f"{h_vcpu:g}" if h_vcpu else EMPTY,
_mb(h_ram),
])
details.append(T(["Host", "Hersteller / Modell", "Status", "VMs", "vCPU", "RAM"], rows))
if any(vm.device_id is None for vm in vms):
details.append(P("VMs ohne festen Host sind nur in den Cluster-Summen enthalten."))
blocks.append(T(["Cluster", "Typ", "Hosts", "VMs aktiv / gesamt", "vCPU", "RAM", "Speicher"], summary))
return blocks + details
@section("vms", "Virtuelle Maschinen", "Infrastruktur", default=False, hint="Cluster, Ressourcen, IP")
def vms(scope, opts):
qs = scope.virtual_machines().select_related("cluster", "role", "platform", "primary_ip4", "primary_ip6").order_by("cluster__name", "name")
@@ -40,6 +40,11 @@
.images img { max-height: 190mm; max-width: 80mm; }
.images.wide figure { width: 100%; min-width: 0; }
.images.wide img { width: 100%; height: auto; max-height: 240mm; object-fit: contain; }
.images.photos { display: flex; gap: 6mm; justify-content: flex-start; page-break-inside: avoid; }
.images.photos figure { width: calc(50% - 3mm); margin: 0 0 6mm; }
.images.photos img { width: 100%; height: auto; max-width: none; max-height: 95mm; object-fit: contain; border: 1px solid #ddd; }
.ref { font-size: 8.5pt; color: #555; margin: 2pt 0 8pt; }
.ref a { color: var(--primary); text-decoration: none; border-bottom: 1px solid currentColor; }
figcaption { font-style: italic; color: #555; }
.footer { position: running(footer); font-size: 7pt; color: #777; }
@media screen { .footer { display: none; } }
@@ -74,13 +79,14 @@
{% if b.kind == 'heading' %}
{% if b.level == 1 %}<h1 id="{{ b.anchor }}">{{ b.text }}</h1>{% elif b.level == 2 %}<h2 id="{{ b.anchor }}">{{ b.text }}</h2>{% elif b.level == 3 %}<h3 id="{{ b.anchor }}">{{ b.text }}</h3>{% else %}<h4 id="{{ b.anchor }}">{{ b.text }}</h4>{% endif %}
{% elif b.kind == 'paragraph' %}<p>{{ b.text|linebreaksbr }}</p>
{% elif b.kind == 'ref' %}<p class="ref">{{ b.rows.0 }}<a href="#{{ b.anchor }}">{{ b.text }}</a></p>
{% elif b.kind == 'table' %}
<table><thead><tr>{% for h in b.headers %}<th>{{ h }}</th>{% endfor %}</tr></thead>
<tbody>{% for row in b.rows %}<tr>{% for c in row %}<td>{{ c|linebreaksbr }}</td>{% endfor %}</tr>{% endfor %}</tbody></table>
{% elif b.kind == 'kv' %}
<table class="kv"><tbody>{% for row in b.rows %}<tr><td>{{ row.0 }}</td><td>{{ row.1|linebreaksbr }}</td></tr>{% endfor %}</tbody></table>
{% elif b.kind == 'images' %}
<div class="images{% if b.level == 1 %} wide{% endif %}">{% for img in b.images %}<figure><img src="{{ img.data_uri }}" alt="{{ img.caption }}">{% if img.caption %}<figcaption>{{ img.caption }}</figcaption>{% endif %}</figure>{% endfor %}</div>
<div class="images{% if b.level == 1 %} wide{% elif b.level == 2 %} photos{% endif %}">{% for img in b.images %}<figure><img src="{{ img.data_uri }}" alt="{{ img.caption }}">{% if img.caption %}<figcaption>{{ img.caption }}</figcaption>{% endif %}</figure>{% endfor %}</div>
{% elif b.kind == 'pagebreak' %}<div class="pagebreak"></div>
{% elif b.kind == 'landscape' %}
<section class="landscape">
@@ -25,6 +25,13 @@
.ce-card { transition: opacity .15s; }
.ce-actions { position: sticky; bottom: 0; z-index: 10; background: var(--tblr-bg-surface); border-top: 1px solid var(--tblr-border-color); padding: .75rem 1rem; display: flex; justify-content: flex-end; gap: .5rem; }
.ce-format .btn { flex: 1; padding-left: .25rem; padding-right: .25rem; }
.ce-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .5rem; }
.ce-photo { position: relative; margin: 0; border: 1px solid var(--tblr-border-color); border-radius: .375rem; overflow: hidden; cursor: pointer; background: var(--tblr-bg-surface-secondary); }
.ce-photo:has(input:checked) { border-color: var(--tblr-primary); box-shadow: 0 0 0 1px var(--tblr-primary); }
.ce-photo img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.ce-photo .form-check-input { position: absolute; top: .4rem; left: .4rem; margin: 0; }
.ce-photo span { display: block; padding: .25rem .4rem; font-size: .75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ce-photo-rack + .ce-photo-rack { margin-top: .9rem; }
</style>
<form method="post" class="mt-3" id="ce-export-form">
@@ -131,6 +138,31 @@
</div>
</div>
</div>
{% if rack_photos %}
<div class="card ce-card mt-3" data-ce-depends="racks">
<h2 class="card-header"><i class="mdi mdi-image-multiple-outline"></i> Rack-Fotos</h2>
<div class="card-body">
<div class="form-text mt-0 mb-3">Ausgewählte Fotos erscheinen im Anhang am Dokumentende, unter der jeweiligen Rack-Ansicht steht ein Verweis darauf.</div>
{% for rack, atts in rack_photos %}
<div class="ce-photo-rack" data-ce-group>
<div class="ce-group-head">
<h5>{{ rack.name }} <span class="fw-normal" style="text-transform: none">· {{ rack.site }}{% if rack.location %} / {{ rack.location }}{% endif %}</span></h5>
<span><a data-ce-all>Alle</a> · <a data-ce-none>Keine</a></span>
</div>
<div class="ce-photos">
{% for a in atts %}
<label class="ce-photo" title="{{ a.name|default:a.image.name }}">
<input type="checkbox" class="form-check-input" name="rack_photos" value="{{ a.pk }}"{% if a.pk|stringformat:"s" in form.rack_photos.value %} checked{% endif %}>
<img src="{{ a.image.url }}" alt="" loading="lazy">
<span>{{ a.name|default:a.image.name }}</span>
</label>
{% endfor %}
</div>
</div>
{% endfor %}
</div>
</div>
{% endif %}
<div class="card ce-card mt-3" data-ce-depends="topology">
<h2 class="card-header d-flex justify-content-between align-items-center">
<span><i class="mdi mdi-sitemap"></i> Topologie</span>
+4 -1
View File
@@ -41,7 +41,9 @@ class ExportView(LoginRequiredMixin, View):
grouped = {}
for s in SECTIONS.values():
grouped.setdefault(s.group, []).append(s)
return render(request, self.template_name, {"object": scope.obj, "scope": scope, "form": form, "section_groups": grouped})
return render(request, self.template_name, {
"object": scope.obj, "scope": scope, "form": form, "section_groups": grouped, "rack_photos": form.photo_groups,
})
def get(self, request, kind, pk):
scope = self._scope(request, kind, pk)
@@ -57,6 +59,7 @@ class ExportView(LoginRequiredMixin, View):
blocks = []
for key in opts["sections"]:
blocks += SECTIONS[key].func(scope, opts)
blocks += opts.pop("_appendix", []) # z.B. Rack-Fotos, immer am Dokumentende
doc = Document(
title=opts["title"],
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "netbox-customer-export"
version = "0.11.1"
version = "0.12.0"
description = "NetBox-Plugin: Kundendokumentation (PDF/Word) für Standorte, Lokationen, Mandanten und Mandantengruppen"
readme = "README.md"
requires-python = ">=3.10"