Update web/core/views.py
This commit is contained in:
@@ -401,7 +401,22 @@ def import_wizard(request):
|
|||||||
core_utils.EXPECTED_HEADERS = EXPECTED
|
core_utils.EXPECTED_HEADERS = EXPECTED
|
||||||
|
|
||||||
# Run your robust importer
|
# Run your robust importer
|
||||||
|
# ... inside import_wizard, after:
|
||||||
report = import_csv_bytes(fixed_raw, dry_run=form.cleaned_data["dry_run"]) or {}
|
report = import_csv_bytes(fixed_raw, dry_run=form.cleaned_data["dry_run"]) or {}
|
||||||
|
|
||||||
|
# Ensure we have a canonical column list (matching your CSV order)
|
||||||
|
expected = [
|
||||||
|
"Subject", "Illustration", "Application", "Scripture", "Source",
|
||||||
|
"Talk Title", "Talk Number", "Code", "Date", "Date Edited",
|
||||||
|
]
|
||||||
|
report.setdefault("columns", expected)
|
||||||
|
|
||||||
|
# If the importer returned preview rows as dicts, convert them to list-of-lists
|
||||||
|
preview = report.get("preview") or []
|
||||||
|
if preview and isinstance(preview[0], dict):
|
||||||
|
cols = report["columns"]
|
||||||
|
report["preview"] = [[(row.get(c) or "") for c in cols] for row in preview]
|
||||||
|
|
||||||
report["header_ok"] = header_ok
|
report["header_ok"] = header_ok
|
||||||
|
|
||||||
# Normalize preview for the template: list of rows + columns list
|
# Normalize preview for the template: list of rows + columns list
|
||||||
|
|||||||
Reference in New Issue
Block a user