Fix device issues and document current LAN deployment

This commit is contained in:
2026-10-13 10:54:20 +02:00
parent 35f88746ff
commit 048cec333e
23 changed files with 707 additions and 36 deletions

View File

@@ -14,11 +14,18 @@ from openpyxl import Workbook, load_workbook
from openpyxl.cell import WriteOnlyCell
from .models import AuditLog, ChoiceValue, Device, Employee, NumberSequence
from .device_types import clear_inapplicable
from .device_types import TRISTATE_FIELDS, clear_inapplicable
from .services import add_audit
COLUMN_MAP = {
"kamera": "camera",
"sound": "sound",
"hdmi": "hdmi",
"vga": "vga",
"dvi": "dvi",
"dp": "displayport",
"displayport": "displayport", "seitenverhältnis": "aspect_ratio", "seitenverhaeltnis": "aspect_ratio",
"nr.": "number", "nr": "number", "nummer": "number", "regal": "shelf", "status": "status",
"datum": "date", "empfänger": "recipient", "empfaenger": "recipient", "ort": "location",
"ticket": "ticket", "typ": "device_type", "preis": "price", "akku": "battery", "wlan": "wifi",
@@ -37,6 +44,13 @@ EXPORT_COLUMNS = [
("print_technology", "Druckverfahren"), ("duplex", "Duplex"), ("color_printing", "Farbdruck"),
("model", "Modell"), ("employee", "Bearbeiter"), ("donor", "Spender"),
("comment", "Kommentar"),
("camera", "Kamera"),
("sound", "Sound"),
("hdmi", "HDMI"),
("vga", "VGA"),
("dvi", "DVI"),
("displayport", "DP"),
("aspect_ratio", "Seitenverhältnis"),
]
@@ -155,6 +169,13 @@ def import_workbook(file_obj, mapping: dict[int, str], user) -> dict[str, Any]:
ports=str(data.get("ports") or "").strip(), resolution=str(data.get("resolution") or "").strip(),
print_technology=str(data.get("print_technology") or "").strip(),
duplex=tri_state(data.get("duplex")), color_printing=tri_state(data.get("color_printing")),
camera=tri_state(data.get("camera")),
sound=tri_state(data.get("sound")),
hdmi=tri_state(data.get("hdmi")),
vga=tri_state(data.get("vga")),
dvi=tri_state(data.get("dvi")),
displayport=tri_state(data.get("displayport")),
aspect_ratio=str(data.get("aspect_ratio") or "").strip(),
model=str(data.get("model") or "").strip(),
employee=employee, donor=str(data.get("donor") or "").strip(), comment=str(data.get("comment") or "").strip(),
)
@@ -174,7 +195,7 @@ def import_workbook(file_obj, mapping: dict[int, str], user) -> dict[str, Any]:
def export_value(device: Device, field: str) -> Any:
value = getattr(device, field)
if field in {"battery", "wifi", "lan", "duplex", "color_printing"}:
if field in TRISTATE_FIELDS:
return dict(Device.TriState.choices).get(value, value)
if hasattr(value, "label"):
return value.label