Début analyse résultats, importation des candidatures 2024
This commit is contained in:
2
nupes/models/__init__.py
Normal file
2
nupes/models/__init__.py
Normal file
@ -0,0 +1,2 @@
|
||||
from .base import Base
|
||||
from .europeennes2024 import Bloc as Bloc2024, Nuance as Nuance2024, Liste as Liste2024, Candidat as Candidat2024
|
5
nupes/models/base.py
Normal file
5
nupes/models/base.py
Normal file
@ -0,0 +1,5 @@
|
||||
from sqlalchemy.orm import DeclarativeBase
|
||||
|
||||
|
||||
class Base(DeclarativeBase):
|
||||
pass
|
70
nupes/models/europeennes2024.py
Normal file
70
nupes/models/europeennes2024.py
Normal file
@ -0,0 +1,70 @@
|
||||
import enum
|
||||
from datetime import date
|
||||
from typing import List
|
||||
|
||||
from sqlalchemy import Boolean, Date, Enum, ForeignKey, Integer, String
|
||||
from sqlalchemy.orm import mapped_column, Mapped, relationship
|
||||
|
||||
from nupes.models import Base
|
||||
|
||||
|
||||
class Bloc(Base):
|
||||
__tablename__ = "bloc2024"
|
||||
|
||||
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")
|
||||
|
||||
|
||||
class Nuance(Base):
|
||||
__tablename__ = "nuance2024"
|
||||
|
||||
code: Mapped[str] = mapped_column(String(8), 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="nuance")
|
||||
|
||||
|
||||
class Liste(Base):
|
||||
__tablename__ = "liste2024"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
nom: Mapped[str] = mapped_column(String(256), unique=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: Mapped[Nuance] = relationship(Nuance, back_populates="listes")
|
||||
bloc: Mapped[Bloc] = relationship(Bloc, back_populates="listes")
|
||||
|
||||
|
||||
class Candidat(Base):
|
||||
class Genre(enum.Enum):
|
||||
MASCULIN = "M"
|
||||
FEMININ = "F"
|
||||
|
||||
class Personnalite(enum.Enum):
|
||||
DEFAUT = ""
|
||||
EURODEPUTE = "RPE"
|
||||
DEPUTE = "DEP"
|
||||
SENATEUR = "SEN"
|
||||
MINISTRE = "MIN"
|
||||
PRESIDENT_CONSEIL_REGIONAL = "PCR"
|
||||
PRESIDENT_CONSEIL_DEPARTEMENTAL = "PCD"
|
||||
MAIRE = "MAI"
|
||||
|
||||
__tablename__ = "candidat2024"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
liste_id: Mapped[int] = mapped_column(ForeignKey("liste2024.id"))
|
||||
ordre: Mapped[int] = mapped_column(Integer())
|
||||
nom: Mapped[str] = mapped_column(String(256))
|
||||
prenom: Mapped[str] = mapped_column(String(256))
|
||||
sexe: Mapped[str] = mapped_column(Enum(Genre))
|
||||
date_naissance: Mapped[date] = mapped_column(Date())
|
||||
profession: Mapped[str] = mapped_column(String(256))
|
||||
code_personnalite: Mapped[str] = mapped_column(Enum(Personnalite))
|
||||
sortant: Mapped[bool] = mapped_column(Boolean())
|
Reference in New Issue
Block a user