Version 0.5.5.93: custom fields in lists, MeshCentral sync flag for statuses

- Show custom field values in asset list, dashboard and list Excel export
- New status flag to exclude assets (e.g. scrapped) from MeshCentral sync
- Require a secure SESSION_SECRET with a readable startup message
- Add SESSION_COOKIE_SECURE and refresh session permissions per request
- Translate HTTP errors and remaining fixed UI texts

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
RolandandClaude Opus 5.5 committed 2026-11-17 22:06:56 +01:00
1 parent c3f1ef43db
commit 261b4f2029
35 files changed
+768 -308

No files matched your search

+26 -1
View File
@@ -11,7 +11,7 @@ from sqlalchemy import func
from sqlalchemy.orm import Session
from .config import load_config
from .models import Asset, AssetHistory, Category, SyncRun, FieldDefinition, AssetFieldValue, MeshFieldMapping
from .models import Asset, AssetHistory, Category, SyncRun, FieldDefinition, AssetFieldValue, MeshFieldMapping, StatusOption
from .fields import ASSET_FIELDS
@@ -1074,6 +1074,16 @@ def synchronize(db: Session, log: Callable[[str, str], None] | None = None, *, d
definition.field_name: definition
for definition in db.query(FieldDefinition).filter(FieldDefinition.is_active.is_(True)).all()
}
# Assets whose status has the MeshCentral sync disabled (e.g. scrapped
# devices) are neither updated nor reported as missing.
excluded_statuses = {
name for (name,) in db.query(StatusOption.name).filter(StatusOption.meshcentral_sync.is_(False)).all()
}
excluded_count = 0
def mark_excluded(asset: Asset) -> None:
asset.mesh_sync_status = "excluded"
asset.mesh_sync_message = f"Status '{asset.status}' ist vom MeshCentral-Abgleich ausgenommen"
try:
log("info", f"{len(mapping_rows)} aktive Feld-Mapping(s) geladen.")
@@ -1091,6 +1101,8 @@ def synchronize(db: Session, log: Callable[[str, str], None] | None = None, *, d
log("error", f"Systemfeld '{target}' besitzt keine Asset-Datenbankspalte und wird übersprungen.")
run.error_count += 1
log("info", "Dry-Run gestartet; es werden keine Datenbankänderungen gespeichert." if dry_run else "Synchronisierung gestartet.")
if excluded_statuses:
log("info", "Vom Abgleich ausgenommene Status: " + ", ".join(sorted(excluded_statuses)))
log("info", "Asset-Zuordnung: " + " → ".join(cfg.get("match_order", ["node_id", "mac_address", "serial_number"])))
if cfg.get("serial_match_manufacturer", False):
log("info", "Seriennummern-Abgleich erfordert zusätzlich einen normalisierten Herstellervergleich.")
@@ -1162,6 +1174,13 @@ def synchronize(db: Session, log: Callable[[str, str], None] | None = None, *, d
run.conflict_count += 1
log("warning", f"{mapped.get('name', node_id)}: {match_error}")
continue
if asset is not None and asset.status in excluded_statuses:
# Matched an excluded asset: do not update it and do not
# create a duplicate asset for this device either.
excluded_count += 1
mark_excluded(asset)
log("info", f"{asset.name}: Status '{asset.status}' ist vom Abgleich ausgenommen; Gerät '{mapped.get('name', node_id)}' wird übersprungen.")
continue
is_new = asset is None
if asset is None:
if not cfg.get("create_missing_assets", True):
@@ -1288,10 +1307,16 @@ def synchronize(db: Session, log: Callable[[str, str], None] | None = None, *, d
linked = db.query(Asset).filter(Asset.mesh_node_id.isnot(None)).all()
for asset in linked:
if asset.mesh_node_id not in seen_node_ids:
if asset.status in excluded_statuses:
excluded_count += 1
mark_excluded(asset)
continue
asset.mesh_sync_status = "missing"
asset.mesh_sync_message = "Beim letzten MeshCentral-Import nicht gefunden"
log("warning", f"{asset.name}: in MeshCentral nicht mehr gefunden.")
if excluded_count:
log("info", f"{excluded_count} Asset(s) wegen ihres Status vom Abgleich ausgenommen.")
run.status = "success" if run.error_count == 0 else "partial"
run.finished_at = datetime.utcnow()
if dry_run: