Compare commits
No commits in common. "6c3f96a9bca92ddcfd0c75a970fee168a74705e9" and "2b10c4c7b2f26331d3facc5912f8b091fed32090" have entirely different histories.
6c3f96a9bc
...
2b10c4c7b2
@ -118,18 +118,10 @@ def importer_bureaux_vote(engine: Engine, debug: bool = False) -> None:
|
|||||||
code_circo = bv_dict['circonscription_code']
|
code_circo = bv_dict['circonscription_code']
|
||||||
bv_id = f"{code_commune}_{code_bv}"
|
bv_id = f"{code_commune}_{code_bv}"
|
||||||
bv_libelle = bv_dict['libelle'] or "Bureau unique"
|
bv_libelle = bv_dict['libelle'] or "Bureau unique"
|
||||||
dpt_code, numero_circo = code_circo.split('-')
|
|
||||||
numero_circo = int(numero_circo)
|
|
||||||
|
|
||||||
if dpt_code == "987" or dpt_code == "988":
|
|
||||||
# Les communes de la Polynésie française et de Nouvelle-Calédonie ne sont pas disponibles,
|
|
||||||
# on les crée à la volée
|
|
||||||
if not session.execute(select(Commune).filter_by(code_insee=code_commune)).scalar_one_or_none():
|
|
||||||
session.add(Commune(code_insee=code_commune, libelle=bv_dict['com_name'], departement_code=dpt_code,
|
|
||||||
geometry={}))
|
|
||||||
|
|
||||||
if not session.execute(select(Circonscription).filter_by(id=code_circo)).scalar_one_or_none():
|
if not session.execute(select(Circonscription).filter_by(id=code_circo)).scalar_one_or_none():
|
||||||
session.add(Circonscription(id=code_circo, departement_code=dpt_code, numero=numero_circo))
|
session.add(Circonscription(id=code_circo, departement_code=code_commune[:2],
|
||||||
|
numero=int(code_circo[3:])))
|
||||||
|
|
||||||
if bv := session.execute(select(BureauVote).filter_by(id=bv_id)).scalar_one_or_none():
|
if bv := session.execute(select(BureauVote).filter_by(id=bv_id)).scalar_one_or_none():
|
||||||
bv.commune_code = code_commune
|
bv.commune_code = code_commune
|
||||||
|
Loading…
Reference in New Issue
Block a user