Compare commits
2 Commits
2b10c4c7b2
...
6c3f96a9bc
Author | SHA1 | Date | |
---|---|---|---|
6c3f96a9bc | |||
10f7f59d55 |
@ -118,10 +118,18 @@ 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 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():
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user