Modifie contrainte sur ApcValidationAnnee (une modif plus sérieuse est nécessaire)

This commit is contained in:
Emmanuel Viennet 2023-06-28 10:09:56 +02:00
parent e190756b98
commit 71ffb33175
4 changed files with 50 additions and 4 deletions

View File

@ -792,7 +792,7 @@ class DecisionsProposeesAnnee(DecisionsProposees):
code=code, code=code,
) )
else: # Update validation année BUT else: # Update validation année BUT
self.validation.etud = self.etud assert self.validation.etudid == self.etud.id
self.validation.formsemestre = self.formsemestre_impair self.validation.formsemestre = self.formsemestre_impair
self.validation.formation_id = self.formsemestre.formation_id self.validation.formation_id = self.formsemestre.formation_id
self.validation.ordre = self.annee_but self.validation.ordre = self.annee_but

View File

@ -306,7 +306,9 @@ class ApcValidationAnnee(db.Model):
__tablename__ = "apc_validation_annee" __tablename__ = "apc_validation_annee"
# Assure unicité de la décision: # Assure unicité de la décision:
__table_args__ = (db.UniqueConstraint("etudid", "annee_scolaire", "ordre"),) __table_args__ = (
db.UniqueConstraint("etudid", "ordre", "formation_id"),
) # il aurait été plus intelligent de mettre ici le refcomp
id = db.Column(db.Integer, primary_key=True) id = db.Column(db.Integer, primary_key=True)
etudid = db.Column( etudid = db.Column(
db.Integer, db.Integer,
@ -320,7 +322,7 @@ class ApcValidationAnnee(db.Model):
db.Integer, db.ForeignKey("notes_formsemestre.id"), nullable=True db.Integer, db.ForeignKey("notes_formsemestre.id"), nullable=True
) )
"le semestre IMPAIR (le 1er) de l'année" "le semestre IMPAIR (le 1er) de l'année"
formation_id = db.Column( formation_id = db.Column( # il aurait été plus intelligent de mettre ici le refcomp
db.Integer, db.Integer,
db.ForeignKey("notes_formations.id"), db.ForeignKey("notes_formations.id"),
nullable=False, nullable=False,

View File

@ -0,0 +1,44 @@
"""Change ApcValidationAnnee
Revision ID: 829683efddc4
Revises: c701224fa255
Create Date: 2023-06-28 09:47:16.591028
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "829683efddc4"
down_revision = "c701224fa255"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("apc_validation_annee", schema=None) as batch_op:
batch_op.drop_constraint(
"apc_validation_annee_etudid_annee_scolaire_ordre_key", type_="unique"
)
# batch_op.create_unique_constraint(
# "apc_validation_annee_etudid_formation_ordre_key",
# ["etudid", "ordre", "formation_id"],
# )
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("apc_validation_annee", schema=None) as batch_op:
# batch_op.drop_constraint(
# "apc_validation_annee_etudid_formation_ordre_key", type_="unique"
# )
batch_op.create_unique_constraint(
"apc_validation_annee_etudid_annee_scolaire_ordre_key",
["etudid", "annee_scolaire", "ordre"],
)
# ### end Alembic commands ###

View File

@ -1,7 +1,7 @@
# -*- mode: python -*- # -*- mode: python -*-
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
SCOVERSION = "9.4.93" SCOVERSION = "9.4.94"
SCONAME = "ScoDoc" SCONAME = "ScoDoc"