Renommage des modèles pour les européennes
This commit is contained in:
@ -1,7 +1,3 @@
|
||||
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, \
|
||||
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
|
||||
from .geographie import *
|
||||
from .europeennes2024 import *
|
||||
|
@ -8,52 +8,57 @@ from sqlalchemy.orm import mapped_column, Mapped, relationship
|
||||
from nupes.models import Base, Region, Departement, Commune
|
||||
|
||||
|
||||
class Bloc(Base):
|
||||
__tablename__ = "bloc2024"
|
||||
class BlocEuropeennes2024(Base):
|
||||
__tablename__ = "europeennes_2024_bloc"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
nom: Mapped[str] = mapped_column(String(32), unique=True)
|
||||
couleur: Mapped[str] = mapped_column(String(7))
|
||||
|
||||
listes: Mapped[List["Liste"]] = relationship("Liste", back_populates="bloc")
|
||||
listes: Mapped[List["ListeEuropeennes2024"]] = relationship("ListeEuropeennes2024", back_populates="bloc")
|
||||
|
||||
|
||||
class Nuance(Base):
|
||||
__tablename__ = "nuance2024"
|
||||
class NuanceEuropeennes2024(Base):
|
||||
__tablename__ = "europeennes_2024_nuance"
|
||||
|
||||
code: Mapped[str] = mapped_column(String(8), primary_key=True)
|
||||
nom: Mapped[str] = mapped_column(String(64), unique=True)
|
||||
couleur: Mapped[str] = mapped_column(String(7))
|
||||
|
||||
listes: Mapped[List["Liste"]] = relationship("Liste", back_populates="nuance")
|
||||
listes: Mapped[List["ListeEuropeennes2024"]] = relationship("ListeEuropeennes2024", back_populates="nuance")
|
||||
|
||||
|
||||
class Liste(Base):
|
||||
__tablename__ = "liste2024"
|
||||
class ListeEuropeennes2024(Base):
|
||||
__tablename__ = "europeennes_2024_liste"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
nom: Mapped[str] = mapped_column(String(256), unique=True)
|
||||
nom_majuscules: Mapped[str] = mapped_column(String(256), unique=True, nullable=True)
|
||||
numero: Mapped[int] = mapped_column(Integer(), unique=True)
|
||||
nuance_id: Mapped[str] = mapped_column(ForeignKey("nuance2024.code"))
|
||||
bloc_id: Mapped[int] = mapped_column(ForeignKey("bloc2024.id"))
|
||||
nuance_id: Mapped[str] = mapped_column(ForeignKey("europeennes_2024_nuance.code"))
|
||||
bloc_id: Mapped[int] = mapped_column(ForeignKey("europeennes_2024_bloc.id"))
|
||||
|
||||
nuance: Mapped[Nuance] = relationship(Nuance, back_populates="listes")
|
||||
bloc: Mapped[Bloc] = relationship(Bloc, back_populates="listes")
|
||||
candidats: Mapped[List["Candidat"]] = relationship("Candidat", back_populates="liste")
|
||||
nuance: Mapped[NuanceEuropeennes2024] = relationship(NuanceEuropeennes2024, back_populates="listes")
|
||||
bloc: Mapped[BlocEuropeennes2024] = relationship(BlocEuropeennes2024, back_populates="listes")
|
||||
candidats: Mapped[List["CandidatEuropeennes2024"]] = relationship("CandidatEuropeennes2024",
|
||||
back_populates="liste")
|
||||
|
||||
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")
|
||||
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")
|
||||
resultats_nationaux: Mapped[List["VoixListeFranceEuropeennes2024"]] = relationship(
|
||||
"VoixListeFranceEuropeennes2024", back_populates="liste")
|
||||
resultats_par_region: Mapped[List["VoixListeRegionEuropeennes2024"]] = relationship(
|
||||
"VoixListeRegionEuropeennes2024", back_populates="liste")
|
||||
resultats_par_departement: Mapped[List[
|
||||
"VoixListeDepartementEuropeennes2024"]] = relationship(
|
||||
"VoixListeDepartementEuropeennes2024", back_populates="liste")
|
||||
resultats_par_circonscription: Mapped[List["VoixListeCirconscriptionEuropeennes2024"]] = relationship(
|
||||
"VoixListeCirconscriptionEuropeennes2024", back_populates="liste")
|
||||
resultats_par_commune: Mapped[List["VoixListeCommuneEuropeennes2024"]] = relationship(
|
||||
"VoixListeCommuneEuropeennes2024", back_populates="liste")
|
||||
resultats_par_bureau_vote: Mapped[List["VoixListeBureauVoteEuropeennes2024"]] = relationship(
|
||||
"VoixListeBureauVoteEuropeennes2024", back_populates="liste")
|
||||
|
||||
|
||||
class Candidat(Base):
|
||||
class CandidatEuropeennes2024(Base):
|
||||
class Genre(enum.Enum):
|
||||
MASCULIN = "M"
|
||||
FEMININ = "F"
|
||||
@ -68,10 +73,10 @@ class Candidat(Base):
|
||||
PRESIDENT_CONSEIL_DEPARTEMENTAL = "PCD"
|
||||
MAIRE = "MAI"
|
||||
|
||||
__tablename__ = "candidat2024"
|
||||
__tablename__ = "europeennes_2024_candidat"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
liste_id: Mapped[int] = mapped_column(ForeignKey("liste2024.id"))
|
||||
liste_id: Mapped[int] = mapped_column(ForeignKey("europeennes_2024_liste.id"))
|
||||
ordre: Mapped[int] = mapped_column(Integer())
|
||||
nom: Mapped[str] = mapped_column(String(256))
|
||||
prenom: Mapped[str] = mapped_column(String(256))
|
||||
@ -81,11 +86,11 @@ class Candidat(Base):
|
||||
code_personnalite: Mapped[str] = mapped_column(Enum(Personnalite))
|
||||
sortant: Mapped[bool] = mapped_column(Boolean())
|
||||
|
||||
liste: Mapped[Liste] = relationship(Liste, back_populates="candidats")
|
||||
liste: Mapped[ListeEuropeennes2024] = relationship(ListeEuropeennes2024, back_populates="candidats")
|
||||
|
||||
|
||||
class ResultatsFrance(Base):
|
||||
__tablename__ = "resultats2024_france"
|
||||
class ResultatsFranceEuropeennes2024(Base):
|
||||
__tablename__ = "europeennes_2024_resultats_france"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
inscrits: Mapped[int] = mapped_column(Integer(), default=0)
|
||||
@ -95,17 +100,18 @@ class ResultatsFrance(Base):
|
||||
blancs: Mapped[int] = mapped_column(Integer(), default=0)
|
||||
nuls: Mapped[int] = mapped_column(Integer(), default=0)
|
||||
|
||||
resultats_regions: Mapped[List["ResultatsRegion"]] = relationship("ResultatsRegion",
|
||||
back_populates="resultats_france")
|
||||
voix_listes: Mapped[List["VoixListeFrance"]] = relationship("VoixListeFrance", back_populates="resultats_france")
|
||||
resultats_regions: Mapped[List["ResultatsRegionEuropeennes2024"]] = relationship(
|
||||
"ResultatsRegionEuropeennes2024", back_populates="resultats_france")
|
||||
voix_listes: Mapped[List["VoixListeFranceEuropeennes2024"]] = relationship(
|
||||
"VoixListeFranceEuropeennes2024", back_populates="resultats_france")
|
||||
|
||||
|
||||
class ResultatsRegion(Base):
|
||||
__tablename__ = "resultats2024_region"
|
||||
class ResultatsRegionEuropeennes2024(Base):
|
||||
__tablename__ = "europeennes_2024_resultats_region"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
region_id: Mapped[str] = mapped_column(ForeignKey("region.code_insee"))
|
||||
resultats_france_id: Mapped[int] = mapped_column(ForeignKey("resultats2024_france.id"))
|
||||
resultats_france_id: Mapped[int] = mapped_column(ForeignKey("europeennes_2024_resultats_france.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)
|
||||
@ -113,19 +119,20 @@ class ResultatsRegion(Base):
|
||||
blancs: Mapped[int] = mapped_column(Integer(), default=0)
|
||||
nuls: Mapped[int] = mapped_column(Integer(), default=0)
|
||||
|
||||
region = relationship(Region, back_populates="resultats2024")
|
||||
resultats_france = relationship(ResultatsFrance, back_populates="resultats_regions")
|
||||
resultats_departements: Mapped[List["ResultatsDepartement"]] = relationship("ResultatsDepartement",
|
||||
back_populates="resultats_region")
|
||||
voix_listes: Mapped[List["VoixListeRegion"]] = relationship("VoixListeRegion", back_populates="resultats_region")
|
||||
region = relationship(Region, back_populates="resultats_europeennes_2024")
|
||||
resultats_france = relationship(ResultatsFranceEuropeennes2024, back_populates="resultats_regions")
|
||||
resultats_departements: Mapped[List["ResultatsDepartementEuropeennes2024"]] = relationship(
|
||||
"ResultatsDepartementEuropeennes2024", back_populates="resultats_region")
|
||||
voix_listes: Mapped[List["VoixListeRegionEuropeennes2024"]] = relationship(
|
||||
"VoixListeRegionEuropeennes2024", back_populates="resultats_region")
|
||||
|
||||
|
||||
class ResultatsDepartement(Base):
|
||||
__tablename__ = "resultats2024_departement"
|
||||
class ResultatsDepartementEuropeennes2024(Base):
|
||||
__tablename__ = "europeennes_2024_resultats_departement"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
dpt_id: Mapped[str] = mapped_column(ForeignKey("departement.code_insee"))
|
||||
resultats_region_id: Mapped[int] = mapped_column(ForeignKey("resultats2024_region.id"), nullable=True)
|
||||
resultats_region_id: Mapped[int] = mapped_column(ForeignKey("europeennes_2024_resultats_region.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)
|
||||
@ -133,22 +140,22 @@ class ResultatsDepartement(Base):
|
||||
blancs: Mapped[int] = mapped_column(Integer(), default=0)
|
||||
nuls: Mapped[int] = mapped_column(Integer(), default=0)
|
||||
|
||||
departement = relationship(Departement, back_populates="resultats2024")
|
||||
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")
|
||||
departement = relationship(Departement, back_populates="resultats_europeennes_2024")
|
||||
resultats_region = relationship(ResultatsRegionEuropeennes2024, back_populates="resultats_departements")
|
||||
resultats_communes: Mapped[List["ResultatsCommuneEuropeennes2024"]] = relationship(
|
||||
"ResultatsCommuneEuropeennes2024", back_populates="resultats_departement")
|
||||
resultats_circonscriptions: Mapped[List["ResultatsCirconscriptionEuropeennes2024"]] = relationship(
|
||||
"ResultatsCirconscriptionEuropeennes2024", back_populates="resultats_departement")
|
||||
voix_listes: Mapped[List["VoixListeDepartementEuropeennes2024"]] = relationship(
|
||||
"VoixListeDepartementEuropeennes2024", back_populates="resultats_departement")
|
||||
|
||||
|
||||
class ResultatsCirconscription(Base):
|
||||
__tablename__ = "resultats2024_circonscription"
|
||||
class ResultatsCirconscriptionEuropeennes2024(Base):
|
||||
__tablename__ = "europeennes_2024_resultats_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"))
|
||||
resultats_departement_id: Mapped[int] = mapped_column(ForeignKey("europeennes_2024_resultats_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)
|
||||
@ -156,20 +163,21 @@ class ResultatsCirconscription(Base):
|
||||
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")
|
||||
circonscription = relationship("Circonscription", back_populates="resultats_europeennes_2024")
|
||||
resultats_departement = relationship(ResultatsDepartementEuropeennes2024,
|
||||
back_populates="resultats_circonscriptions")
|
||||
resultats_bureaux_vote: Mapped[List["ResultatsBureauVoteEuropeennes2024"]] = relationship(
|
||||
"ResultatsBureauVoteEuropeennes2024", back_populates="resultats_circonscription")
|
||||
voix_listes: Mapped[List["VoixListeCirconscriptionEuropeennes2024"]] = relationship(
|
||||
"VoixListeCirconscriptionEuropeennes2024", back_populates="resultats_circonscription")
|
||||
|
||||
|
||||
class ResultatsCommune(Base):
|
||||
__tablename__ = "resultats2024_commune"
|
||||
class ResultatsCommuneEuropeennes2024(Base):
|
||||
__tablename__ = "europeennes_2024_resultats_commune"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
commune_id: Mapped[str] = mapped_column(ForeignKey("commune.code_insee"))
|
||||
resultats_dpt_id: Mapped[int] = mapped_column(ForeignKey("resultats2024_departement.id"))
|
||||
resultats_dpt_id: Mapped[int] = mapped_column(ForeignKey("europeennes_2024_resultats_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)
|
||||
@ -177,20 +185,22 @@ class ResultatsCommune(Base):
|
||||
blancs: Mapped[int] = mapped_column(Integer(), default=0)
|
||||
nuls: Mapped[int] = mapped_column(Integer(), default=0)
|
||||
|
||||
commune = relationship(Commune, back_populates="resultats2024")
|
||||
resultats_departement = relationship(ResultatsDepartement, back_populates="resultats_communes")
|
||||
resultats_bureaux_vote: Mapped[List["ResultatsBureauVote"]] = relationship("ResultatsBureauVote",
|
||||
back_populates="resultats_commune")
|
||||
voix_listes: Mapped[List["VoixListeCommune"]] = relationship("VoixListeCommune", back_populates="resultats_commune")
|
||||
commune = relationship(Commune, back_populates="resultats_europeennes_2024")
|
||||
resultats_departement = relationship(ResultatsDepartementEuropeennes2024, back_populates="resultats_communes")
|
||||
resultats_bureaux_vote: Mapped[List["ResultatsBureauVoteEuropeennes2024"]] = relationship(
|
||||
"ResultatsBureauVoteEuropeennes2024", back_populates="resultats_commune")
|
||||
voix_listes: Mapped[List["VoixListeCommuneEuropeennes2024"]] = relationship(
|
||||
"VoixListeCommuneEuropeennes2024", back_populates="resultats_commune")
|
||||
|
||||
|
||||
class ResultatsBureauVote(Base):
|
||||
__tablename__ = "resultats2024_bureau_vote"
|
||||
class ResultatsBureauVoteEuropeennes2024(Base):
|
||||
__tablename__ = "europeennes_2024_resultats_bureau_vote"
|
||||
|
||||
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)
|
||||
resultats_commune_id: Mapped[int] = mapped_column(ForeignKey("europeennes_2024_resultats_commune.id"))
|
||||
resultats_circo_id: Mapped[int] = mapped_column(ForeignKey("europeennes_2024_resultats_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)
|
||||
@ -198,77 +208,88 @@ class ResultatsBureauVote(Base):
|
||||
blancs: Mapped[int] = mapped_column(Integer(), default=0)
|
||||
nuls: Mapped[int] = mapped_column(Integer(), default=0)
|
||||
|
||||
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")
|
||||
bureau_vote = relationship("BureauVote", back_populates="resultats_europeennes_2024")
|
||||
resultats_commune = relationship(ResultatsCommuneEuropeennes2024, back_populates="resultats_bureaux_vote")
|
||||
resultats_circonscription = relationship(ResultatsCirconscriptionEuropeennes2024,
|
||||
back_populates="resultats_bureaux_vote")
|
||||
voix_listes: Mapped[List["VoixListeBureauVoteEuropeennes2024"]] = relationship(
|
||||
"VoixListeBureauVoteEuropeennes2024", back_populates="resultats_bureau_vote")
|
||||
|
||||
|
||||
class VoixListeFrance(Base):
|
||||
__tablename__ = "voix2024_france"
|
||||
class VoixListeFranceEuropeennes2024(Base):
|
||||
__tablename__ = "europeennes_2024_voix_france"
|
||||
|
||||
liste_id: Mapped[int] = mapped_column(ForeignKey("liste2024.id"), primary_key=True)
|
||||
resultats_france_id: Mapped[int] = mapped_column(ForeignKey("resultats2024_france.id"), primary_key=True)
|
||||
liste_id: Mapped[int] = mapped_column(ForeignKey("europeennes_2024_liste.id"), primary_key=True)
|
||||
resultats_france_id: Mapped[int] = mapped_column(ForeignKey("europeennes_2024_resultats_france.id"),
|
||||
primary_key=True)
|
||||
voix: Mapped[int] = mapped_column(Integer(), default=0)
|
||||
|
||||
liste: Mapped[Liste] = relationship(Liste, back_populates="resultats_nationaux")
|
||||
resultats_france: Mapped[ResultatsFrance] = relationship(ResultatsFrance, back_populates="voix_listes")
|
||||
liste: Mapped[ListeEuropeennes2024] = relationship(ListeEuropeennes2024, back_populates="resultats_nationaux")
|
||||
resultats_france: Mapped[ResultatsFranceEuropeennes2024] = relationship(ResultatsFranceEuropeennes2024,
|
||||
back_populates="voix_listes")
|
||||
|
||||
|
||||
class VoixListeRegion(Base):
|
||||
__tablename__ = "voix2024_region"
|
||||
class VoixListeRegionEuropeennes2024(Base):
|
||||
__tablename__ = "europeennes_2024_voix_region"
|
||||
|
||||
liste_id: Mapped[int] = mapped_column(ForeignKey("liste2024.id"), primary_key=True)
|
||||
resultats_region_id: Mapped[int] = mapped_column(ForeignKey("resultats2024_region.id"), primary_key=True)
|
||||
liste_id: Mapped[int] = mapped_column(ForeignKey("europeennes_2024_liste.id"), primary_key=True)
|
||||
resultats_region_id: Mapped[int] = mapped_column(ForeignKey("europeennes_2024_resultats_region.id"),
|
||||
primary_key=True)
|
||||
voix: Mapped[int] = mapped_column(Integer(), default=0)
|
||||
|
||||
liste: Mapped[Liste] = relationship(Liste, back_populates="resultats_par_region")
|
||||
resultats_region: Mapped[ResultatsRegion] = relationship(ResultatsRegion, back_populates="voix_listes")
|
||||
liste: Mapped[ListeEuropeennes2024] = relationship(ListeEuropeennes2024, back_populates="resultats_par_region")
|
||||
resultats_region: Mapped[ResultatsRegionEuropeennes2024] = relationship(ResultatsRegionEuropeennes2024,
|
||||
back_populates="voix_listes")
|
||||
|
||||
|
||||
class VoixListeDepartement(Base):
|
||||
__tablename__ = "voix2024_departement"
|
||||
class VoixListeDepartementEuropeennes2024(Base):
|
||||
__tablename__ = "europeennes_2024_voix_departement"
|
||||
|
||||
liste_id: Mapped[int] = mapped_column(ForeignKey("liste2024.id"), primary_key=True)
|
||||
resultats_departement_id: Mapped[int] = mapped_column(ForeignKey("resultats2024_departement.id"), primary_key=True)
|
||||
liste_id: Mapped[int] = mapped_column(ForeignKey("europeennes_2024_liste.id"), primary_key=True)
|
||||
resultats_departement_id: Mapped[int] = mapped_column(ForeignKey("europeennes_2024_resultats_departement.id"),
|
||||
primary_key=True)
|
||||
voix: Mapped[int] = mapped_column(Integer(), default=0)
|
||||
|
||||
liste: Mapped[Liste] = relationship(Liste, back_populates="resultats_par_departement")
|
||||
resultats_departement: Mapped[ResultatsDepartement] = relationship(ResultatsDepartement,
|
||||
back_populates="voix_listes")
|
||||
liste: Mapped[ListeEuropeennes2024] = relationship(ListeEuropeennes2024, back_populates="resultats_par_departement")
|
||||
resultats_departement: Mapped[ResultatsDepartementEuropeennes2024] = relationship(
|
||||
ResultatsDepartementEuropeennes2024, back_populates="voix_listes")
|
||||
|
||||
|
||||
class VoixListeCirconscription(Base):
|
||||
__tablename__ = "voix2024_circonscription"
|
||||
class VoixListeCirconscriptionEuropeennes2024(Base):
|
||||
__tablename__ = "europeennes_2024_voix_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)
|
||||
liste_id: Mapped[int] = mapped_column(ForeignKey("europeennes_2024_liste.id"), primary_key=True)
|
||||
resultats_circonscription_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("europeennes_2024_resultats_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")
|
||||
liste: Mapped[ListeEuropeennes2024] = relationship(ListeEuropeennes2024,
|
||||
back_populates="resultats_par_circonscription")
|
||||
resultats_circonscription: Mapped[ResultatsCirconscriptionEuropeennes2024] = relationship(
|
||||
ResultatsCirconscriptionEuropeennes2024, back_populates="voix_listes")
|
||||
|
||||
|
||||
class VoixListeCommune(Base):
|
||||
__tablename__ = "voix2024_commune"
|
||||
class VoixListeCommuneEuropeennes2024(Base):
|
||||
__tablename__ = "europeennes_2024_voix_commune"
|
||||
|
||||
liste_id: Mapped[int] = mapped_column(ForeignKey("liste2024.id"), primary_key=True)
|
||||
resultats_commune_id: Mapped[int] = mapped_column(ForeignKey("resultats2024_commune.id"), primary_key=True)
|
||||
liste_id: Mapped[int] = mapped_column(ForeignKey("europeennes_2024_liste.id"), primary_key=True)
|
||||
resultats_commune_id: Mapped[int] = mapped_column(ForeignKey("europeennes_2024_resultats_commune.id"),
|
||||
primary_key=True)
|
||||
voix: Mapped[int] = mapped_column(Integer(), default=0)
|
||||
|
||||
liste: Mapped[Liste] = relationship(Liste, back_populates="resultats_par_commune")
|
||||
resultats_commune: Mapped[ResultatsCommune] = relationship(ResultatsCommune, back_populates="voix_listes")
|
||||
liste: Mapped[ListeEuropeennes2024] = relationship(ListeEuropeennes2024, back_populates="resultats_par_commune")
|
||||
resultats_commune: Mapped[ResultatsCommuneEuropeennes2024] = relationship(ResultatsCommuneEuropeennes2024,
|
||||
back_populates="voix_listes")
|
||||
|
||||
|
||||
class VoixListeBureauVote(Base):
|
||||
__tablename__ = "voix2024_bureau_vote"
|
||||
class VoixListeBureauVoteEuropeennes2024(Base):
|
||||
__tablename__ = "europeennes_2024_voix_bureau_vote"
|
||||
|
||||
liste_id: Mapped[int] = mapped_column(ForeignKey("liste2024.id"), primary_key=True)
|
||||
resultats_bureau_vote_id: Mapped[int] = mapped_column(ForeignKey("resultats2024_bureau_vote.id"), primary_key=True)
|
||||
liste_id: Mapped[int] = mapped_column(ForeignKey("europeennes_2024_liste.id"), primary_key=True)
|
||||
resultats_bureau_vote_id: Mapped[int] = mapped_column(ForeignKey("europeennes_2024_resultats_bureau_vote.id"),
|
||||
primary_key=True)
|
||||
voix: Mapped[int] = mapped_column(Integer(), default=0)
|
||||
|
||||
liste: Mapped[Liste] = relationship(Liste, back_populates="resultats_par_bureau_vote")
|
||||
resultats_bureau_vote: Mapped[ResultatsBureauVote] = relationship(ResultatsBureauVote, back_populates="voix_listes")
|
||||
liste: Mapped[ListeEuropeennes2024] = relationship(ListeEuropeennes2024, back_populates="resultats_par_bureau_vote")
|
||||
resultats_bureau_vote: Mapped[ResultatsBureauVoteEuropeennes2024] = relationship(ResultatsBureauVoteEuropeennes2024,
|
||||
back_populates="voix_listes")
|
||||
|
@ -1,6 +1,6 @@
|
||||
from typing import List
|
||||
|
||||
from sqlalchemy import Float, ForeignKey, Integer, JSON, String
|
||||
from sqlalchemy import ForeignKey, Integer, JSON, String
|
||||
from sqlalchemy.orm import mapped_column, Mapped, relationship
|
||||
|
||||
from nupes.models import Base
|
||||
@ -15,7 +15,7 @@ class Region(Base):
|
||||
|
||||
departements: Mapped[List["Departement"]] = relationship("Departement", back_populates="region")
|
||||
|
||||
resultats2024 = relationship("ResultatsRegion", back_populates="region")
|
||||
resultats_europeennes_2024 = relationship("ResultatsRegionEuropeennes2024", back_populates="region")
|
||||
|
||||
|
||||
class Departement(Base):
|
||||
@ -30,7 +30,7 @@ class Departement(Base):
|
||||
circonscriptions: Mapped[List["Circonscription"]] = relationship("Circonscription", back_populates="departement")
|
||||
communes: Mapped[List["Commune"]] = relationship("Commune", back_populates="departement")
|
||||
|
||||
resultats2024 = relationship("ResultatsDepartement", back_populates="departement")
|
||||
resultats_europeennes_2024 = relationship("ResultatsDepartementEuropeennes2024", back_populates="departement")
|
||||
|
||||
|
||||
class Commune(Base):
|
||||
@ -44,7 +44,7 @@ class Commune(Base):
|
||||
departement: Mapped[Departement] = relationship(Departement, back_populates="communes")
|
||||
bureaux_vote: Mapped[List["BureauVote"]] = relationship("BureauVote", back_populates="commune")
|
||||
|
||||
resultats2024 = relationship("ResultatsCommune", back_populates="commune")
|
||||
resultats_europeennes_2024 = relationship("ResultatsCommuneEuropeennes2024", back_populates="commune")
|
||||
|
||||
|
||||
class Circonscription(Base):
|
||||
@ -58,7 +58,8 @@ class Circonscription(Base):
|
||||
departement: Mapped[Departement] = relationship(Departement, back_populates="circonscriptions")
|
||||
bureaux_vote: Mapped[List["BureauVote"]] = relationship("BureauVote", back_populates="circonscription")
|
||||
|
||||
resultats2024 = relationship("ResultatsCirconscription", back_populates="circonscription")
|
||||
resultats_europeennes_2024 = relationship("ResultatsCirconscriptionEuropeennes2024",
|
||||
back_populates="circonscription")
|
||||
|
||||
|
||||
class BureauVote(Base):
|
||||
@ -75,4 +76,4 @@ class BureauVote(Base):
|
||||
commune: Mapped[Commune] = relationship(Commune, back_populates="bureaux_vote")
|
||||
circonscription: Mapped[Circonscription] = relationship(Circonscription, back_populates="bureaux_vote")
|
||||
|
||||
resultats2024 = relationship("ResultatsBureauVote", back_populates="bureau_vote")
|
||||
resultats_europeennes_2024 = relationship("ResultatsBureauVoteEuropeennes2024", back_populates="bureau_vote")
|
||||
|
Reference in New Issue
Block a user