Importation des résultats officiels + séparation par circonscription
This commit is contained in:
@ -1,3 +1,7 @@
|
||||
from .base import Base
|
||||
from .geographie import Region, Departement, Commune, Circonscription, BureauVote
|
||||
from .europeennes2024 import Bloc as Bloc2024, Nuance as Nuance2024, Liste as Liste2024, Candidat as Candidat2024
|
||||
from .europeennes2024 import Bloc as Bloc2024, Nuance as Nuance2024, Liste as Liste2024, Candidat as Candidat2024, \
|
||||
ResultatsFrance as ResultatsFrance2024, ResultatsRegion as ResultatsRegion2024, ResultatsDepartement as ResultatsDepartement2024, \
|
||||
ResultatsCommune as ResultatsCommune2024, ResultatsBureauVote as ResultatsBureauVote2024, \
|
||||
VoixListeFrance as VoixListeFrance2024, VoixListeRegion as VoixListeRegion2024, VoixListeDepartement as VoixListeDepartement2024, \
|
||||
VoixListeCommune as VoixListeCommune2024, VoixListeBureauVote as VoixListeBureauVote2024
|
||||
|
@ -45,10 +45,12 @@ class Liste(Base):
|
||||
resultats_nationaux: Mapped[List["VoixListeFrance"]] = relationship("VoixListeFrance", back_populates="liste")
|
||||
resultats_par_region: Mapped[List["VoixListeRegion"]] = relationship("VoixListeRegion", back_populates="liste")
|
||||
resultats_par_departement: Mapped[List["VoixListeDepartement"]] = relationship("VoixListeDepartement",
|
||||
back_populates="liste")
|
||||
back_populates="liste")
|
||||
resultats_par_circonscription: Mapped[List["VoixListeCirconscription"]] = relationship(
|
||||
"VoixListeCirconscription", back_populates="liste")
|
||||
resultats_par_commune: Mapped[List["VoixListeCommune"]] = relationship("VoixListeCommune", back_populates="liste")
|
||||
resultats_par_bureau_vote: Mapped[List["VoixListeBureauVote"]] = relationship("VoixListeBureauVote",
|
||||
back_populates="liste")
|
||||
back_populates="liste")
|
||||
|
||||
|
||||
class Candidat(Base):
|
||||
@ -135,10 +137,33 @@ class ResultatsDepartement(Base):
|
||||
resultats_region = relationship(ResultatsRegion, back_populates="resultats_departements")
|
||||
resultats_communes: Mapped[List["ResultatsCommune"]] = relationship("ResultatsCommune",
|
||||
back_populates="resultats_departement")
|
||||
resultats_circonscriptions: Mapped[List["ResultatsCirconscription"]] = relationship(
|
||||
"ResultatsCirconscription", back_populates="resultats_departement")
|
||||
voix_listes: Mapped[List["VoixListeDepartement"]] = relationship("VoixListeDepartement",
|
||||
back_populates="resultats_departement")
|
||||
|
||||
|
||||
class ResultatsCirconscription(Base):
|
||||
__tablename__ = "resultats2024_circonscription"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
circo_id: Mapped[str] = mapped_column(ForeignKey("circonscription.id"))
|
||||
resultats_departement_id: Mapped[int] = mapped_column(ForeignKey("resultats2024_departement.id"))
|
||||
inscrits: Mapped[int] = mapped_column(Integer(), default=0)
|
||||
votants: Mapped[int] = mapped_column(Integer(), default=0)
|
||||
abstentions: Mapped[int] = mapped_column(Integer(), default=0)
|
||||
exprimes: Mapped[int] = mapped_column(Integer(), default=0)
|
||||
blancs: Mapped[int] = mapped_column(Integer(), default=0)
|
||||
nuls: Mapped[int] = mapped_column(Integer(), default=0)
|
||||
|
||||
circonscription = relationship("Circonscription", back_populates="resultats2024")
|
||||
resultats_departement = relationship(ResultatsDepartement, back_populates="resultats_circonscriptions")
|
||||
resultats_bureaux_vote: Mapped[List["ResultatsBureauVote"]] = relationship(
|
||||
"ResultatsBureauVote", back_populates="resultats_circonscription")
|
||||
voix_listes: Mapped[List["VoixListeCirconscription"]] = relationship("VoixListeCirconscription",
|
||||
back_populates="resultats_circonscription")
|
||||
|
||||
|
||||
class ResultatsCommune(Base):
|
||||
__tablename__ = "resultats2024_commune"
|
||||
|
||||
@ -165,6 +190,7 @@ class ResultatsBureauVote(Base):
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
bv_id: Mapped[str] = mapped_column(ForeignKey("bureau_vote.id"))
|
||||
resultats_commune_id: Mapped[int] = mapped_column(ForeignKey("resultats2024_commune.id"))
|
||||
resultats_circo_id: Mapped[int] = mapped_column(ForeignKey("resultats2024_circonscription.id"), nullable=True)
|
||||
inscrits: Mapped[int] = mapped_column(Integer(), default=0)
|
||||
votants: Mapped[int] = mapped_column(Integer(), default=0)
|
||||
abstentions: Mapped[int] = mapped_column(Integer(), default=0)
|
||||
@ -174,6 +200,7 @@ class ResultatsBureauVote(Base):
|
||||
|
||||
bureau_vote = relationship("BureauVote", back_populates="resultats2024")
|
||||
resultats_commune = relationship(ResultatsCommune, back_populates="resultats_bureaux_vote")
|
||||
resultats_circonscription = relationship(ResultatsCirconscription, back_populates="resultats_bureaux_vote")
|
||||
voix_listes: Mapped[List["VoixListeBureauVote"]] = relationship("VoixListeBureauVote",
|
||||
back_populates="resultats_bureau_vote")
|
||||
|
||||
@ -212,6 +239,19 @@ class VoixListeDepartement(Base):
|
||||
back_populates="voix_listes")
|
||||
|
||||
|
||||
class VoixListeCirconscription(Base):
|
||||
__tablename__ = "voix2024_circonscription"
|
||||
|
||||
liste_id: Mapped[int] = mapped_column(ForeignKey("liste2024.id"), primary_key=True)
|
||||
resultats_circonscription_id: Mapped[int] = mapped_column(ForeignKey("resultats2024_circonscription.id"),
|
||||
primary_key=True)
|
||||
voix: Mapped[int] = mapped_column(Integer(), default=0)
|
||||
|
||||
liste: Mapped[Liste] = relationship(Liste, back_populates="resultats_par_circonscription")
|
||||
resultats_circonscription: Mapped[ResultatsCirconscription] = relationship(ResultatsCirconscription,
|
||||
back_populates="voix_listes")
|
||||
|
||||
|
||||
class VoixListeCommune(Base):
|
||||
__tablename__ = "voix2024_commune"
|
||||
|
||||
|
@ -56,6 +56,8 @@ class Circonscription(Base):
|
||||
departement: Mapped[Departement] = relationship(Departement)
|
||||
bureaux_vote: Mapped[List["BureauVote"]] = relationship("BureauVote", back_populates="circonscription")
|
||||
|
||||
resultats2024 = relationship("ResultatsCirconscription", back_populates="circonscription")
|
||||
|
||||
|
||||
class BureauVote(Base):
|
||||
__tablename__ = "bureau_vote"
|
||||
|
Reference in New Issue
Block a user