Enhance import preview functionality with editable fields and overlay logic for payload updates

This commit is contained in:
Ross
2025-10-20 22:35:01 +01:00
parent 8dac99b6d3
commit 45e50e9e93
2 changed files with 181 additions and 136 deletions
+14
View File
@@ -950,6 +950,20 @@ def import_llm_confirm(request):
except Exception:
errors.append({"index": idx, "errors": ["Missing candidate"]})
continue
# Overlay any edited fields posted from the preview form (names like payload_<idx>_stem)
overlay = {}
prefix = f"payload_{idx}_"
for k, v in request.POST.items():
if k.startswith(prefix):
field = k[len(prefix):]
overlay[field] = v
if overlay:
# apply overlay onto a shallow copy
new_payload = dict(payload)
for fk, fv in overlay.items():
# convert list-like fields and numeric conversions are not performed here; keep simple strings/lists
new_payload[fk] = fv
payload = new_payload
# Strip numeric bracket references here as well, before confirm import
payload, stripped = _strip_numeric_refs_in_payload(payload)
if stripped: