backoffice first commit

This commit is contained in:
2026-07-17 11:34:15 +02:00
parent 761db06329
commit 1c40ef6601
159 changed files with 25830 additions and 7875 deletions
+16 -57
View File
@@ -19,58 +19,23 @@ ROOT = Path(__file__).resolve().parent.parent
XLS_PATH = ROOT / "PVC_LISTINO.xls"
PVC_DIR = ROOT / "src" / "assets" / "data" / "modelli" / "pvc"
# Titoli del listino che corrispondono a una o più cartelle pvc/ già esistenti
# (catalogo allineato a GAMMA PVC). "FINSETRA 2 ANTE" è il typo presente nel
# file excel stesso, non un errore di battitura qui. Un titolo può essere
# associato a più cartelle quando non esiste un listino dedicato per ciascun
# prodotto (es. "CASSONETTO PVC" riusato per cassonetti/scuretti/scorrevoli).
KNOWN_FOLDERS = {
"FINESTRA 1 ANTA": "finestra_1_anta",
"FINSETRA 2 ANTE": "finestra_2_ante",
"FINESTRA 3 ANTE": "finestra_3_ante",
"PORTA-FINESTRA 1 ANTA": "portafinestra_1_anta",
"PORTA-FINESTRA 2 ANTE": "portafinestra_2_ante",
"PORTA-FINESTRA 3 ANTE": "portafinestra_3_ante",
"WASISTAS CON MARTELLINA": "finestra_vasistas",
"TELAIO FISSO": "finestra_anta_fissa",
"BILICO ORIZZONTALE": "bilico",
"PORTA 1 ANTA, CON SERRATURA": "porta_1_anta",
"PORTA 1 ANTA, ANTIPANICO (APERTURA ESTERNA)": "porta_1_anta_antipanico",
"PORTA 2 ANTE, CON SERRATURA": "porta_2_ante",
"PORTA 2 ANTE, ANTIPANICO (APERTURA ESTERNA)": "porta_2_ante_antipanico",
"CASSONETTO PVC": [
"cassonetto_80",
"cassonetto_139",
"cassonetto_150",
"scuretto_base",
"scuretto_pannello_malachite",
"scuretto_pannello_alessandrite",
"scorrevole_hst_1_anta",
"scorrevole_hst_2_ante",
"scorrevole_parallelo_1_anta",
"scorrevole_sf_1_anta",
"scorrevole_sf_2_ante",
"traslante_scorrevole_1_anta",
],
# I titoli del listino ora coincidono direttamente con i nomi delle cartelle
# pvc/ (uno-a-uno). TYPO_FIXES corregge i titoli il cui slug non combacia
# esattamente col nome cartella per un refuso nel file excel stesso.
TYPO_FIXES = {
"finestra_wasistas": "finestra_vasistas",
}
# Titoli duplicati nel file (varianti mano dx/sx con lo stesso identico
# listino prezzi) sono gestiti naturalmente: la stessa chiave di titolo
# riscrive due volte lo stesso file con dati identici.
# Titoli del listino senza una cartella attiva corrispondente nel catalogo
# (prodotti archiviati o senza un modello 3D GAMMA univoco): non vengono
# processati, per non ricreare cartelle orfane.
SKIP_TITLES = {
"PORTA 1 ANTA, CON SERRATURA_(APERTURA ESTERNA)",
"PORTA 2 ANTE, CON SERRATURA_(APERTURA ESTERNA)",
"SCORREVOLE IN LINEA_2 ANTE",
"SCORREVOLE IN LINEA_3 ANTE",
"SCORREVOLE IN LINEA_4 ANTE_2 FISSE + 2 APRIBILI",
"TRASLANTE_ANTA DX+ANTA FISSA SX",
"TRASLANTE_ANTA DX+FISSO SX",
"TRASLANTE_ANTA SX+ANTA FISSA DX",
"TRASLANTE_ANTA SX+FISSO DX",
"ALZANTE 2ANTE_MANO DX",
"ALZANTE 2ANTE_MANO SX",
"ALZANTE_1ANTA APRIBILE DX+ANTA FISSA SX",
"ALZANTE_1ANTA APRIBILE SX+ANTA FISSA DX",
"ALZANTE_4ANTE(2 APRIBILI+2 FISSE)",
}
@@ -175,23 +140,17 @@ def main():
if title in SKIP_TITLES:
print(f"{title!r:55s} -> (saltato, nessuna cartella attiva corrispondente)")
continue
if title not in KNOWN_FOLDERS:
print(f"{title!r:55s} -> (saltato, titolo non mappato)")
folder_name = TYPO_FIXES.get(title, title)
folder = PVC_DIR / folder_name
if not folder.is_dir():
print(f"{title!r:55s} -> cartella {folder_name!r} non trovata, saltato")
continue
folder_names = KNOWN_FOLDERS[title]
if isinstance(folder_names, str):
folder_names = [folder_names]
listino = block_to_listino(larghezze, rows)
for folder_name in folder_names:
folder = PVC_DIR / folder_name
if not folder.is_dir():
print(f"{title!r:55s} -> cartella {folder_name!r} non trovata, saltato")
continue
out_path = folder / "listino.json"
out_path.write_text(json.dumps(listino, indent=3, ensure_ascii=False) + "\n", encoding="utf-8")
print(f"{title!r:55s} -> {out_path.relative_to(ROOT)} ({len(listino)} righe)")
out_path = folder / "listino.json"
out_path.write_text(json.dumps(listino, indent=3, ensure_ascii=False) + "\n", encoding="utf-8")
print(f"{title!r:55s} -> {out_path.relative_to(ROOT)} ({len(listino)} righe)")
if __name__ == "__main__":