feat(csv-templates): Introduce CSV template analysis and validation features
- Added a new endpoint for analyzing uploaded CSV files, providing suggestions for field mappings and type conversions. - Implemented validation for required field targets to ensure all mandatory fields are mapped correctly. - Enhanced the admin CSV templates interface with new routes and navigation options in the frontend. - Updated API utility functions to support the new CSV analysis functionality. - Improved error handling for CSV uploads, including file size and row count checks.
This commit is contained in:
1 parent
338163ac0b
commit
c10da55ec6
9 files changed
+1017
-4
No files matched your search
@@ -82,7 +82,19 @@ def validate_field_mappings(module: str, field_mappings: dict) -> None:
|
||||
fields = cast(dict, mod["fields"])
|
||||
allowed = set(fields.keys())
|
||||
for _csv_col, db_field in field_mappings.items():
|
||||
if db_field in ("", None, "-"):
|
||||
if db_field in ("", None, "-", "_skip"):
|
||||
continue
|
||||
if db_field not in allowed:
|
||||
raise ValueError(f"Ungültiges Zielfeld '{db_field}' für Modul '{module}'")
|
||||
|
||||
|
||||
def validate_required_field_targets(module: str, field_mappings: dict) -> None:
|
||||
"""Stellt sicher, dass jedes als required markierte Zielfeld mindestens einer Spalte zugeordnet ist."""
|
||||
mod = get_module_definition(module)
|
||||
if not mod:
|
||||
raise ValueError(f"Unbekanntes Modul: {module}")
|
||||
field_defs = cast(dict, mod["fields"])
|
||||
targets = {v for v in field_mappings.values() if v and v not in ("-", "_skip")}
|
||||
for fname, finfo in field_defs.items():
|
||||
if finfo.get("required") and fname not in targets:
|
||||
raise ValueError(f"Pflicht-Zielfeld nicht zugeordnet: {fname}")
|
||||
Reference in new issue
Block a user