Correction circonscription outre-mer

This commit is contained in:
Emmy D'Anello 2024-06-13 11:50:18 +02:00
parent 2b10c4c7b2
commit 10f7f59d55
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
1 changed files with 3 additions and 2 deletions

View File

@ -118,10 +118,11 @@ def importer_bureaux_vote(engine: Engine, debug: bool = False) -> None:
code_circo = bv_dict['circonscription_code']
bv_id = f"{code_commune}_{code_bv}"
bv_libelle = bv_dict['libelle'] or "Bureau unique"
dpt_code, numero_circo = code_circo.split('-')
numero_circo = int(numero_circo)
if not session.execute(select(Circonscription).filter_by(id=code_circo)).scalar_one_or_none():
session.add(Circonscription(id=code_circo, departement_code=code_commune[:2],
numero=int(code_circo[3:])))
session.add(Circonscription(id=code_circo, departement_code=dpt_code, numero=numero_circo))
if bv := session.execute(select(BureauVote).filter_by(id=bv_id)).scalar_one_or_none():
bv.commune_code = code_commune