From 5ea9944be2d996e4a1f31049a2a4130db0862db5 Mon Sep 17 00:00:00 2001 From: iziram Date: Thu, 20 Jul 2023 13:10:26 +0200 Subject: [PATCH] =?UTF-8?q?Assiduit=C3=A9s=20:=20changement=20champ=20desc?= =?UTF-8?q?=20Table=20assiduites?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/assiduites.py | 2 +- app/models/assiduites.py | 10 +++---- ...6229f_assiduites_champ_desc_description.py | 28 +++++++++++++++++++ tools/migrate_abs_to_assiduites.py | 6 ++-- 4 files changed, 37 insertions(+), 9 deletions(-) create mode 100644 migrations/versions/50f7e0b6229f_assiduites_champ_desc_description.py diff --git a/app/api/assiduites.py b/app/api/assiduites.py index 3c02c7e75..8a7cac59f 100644 --- a/app/api/assiduites.py +++ b/app/api/assiduites.py @@ -616,7 +616,7 @@ def assiduite_edit(assiduite_id: int): # Cas 3 : desc desc = data.get("desc", False) if desc is not False: - assiduite_unique.desc = desc + assiduite_unique.description = desc # Cas 4 : est_just est_just = data.get("est_just") diff --git a/app/models/assiduites.py b/app/models/assiduites.py index d16e0d9f2..3b467904b 100644 --- a/app/models/assiduites.py +++ b/app/models/assiduites.py @@ -53,7 +53,7 @@ class Assiduite(db.Model): ) etat = db.Column(db.Integer, nullable=False) - desc = db.Column(db.Text) + description = db.Column(db.Text) entry_date = db.Column(db.DateTime(timezone=True), server_default=db.func.now()) @@ -85,7 +85,7 @@ class Assiduite(db.Model): "date_debut": self.date_debut, "date_fin": self.date_fin, "etat": etat, - "desc": self.desc, + "desc": self.description, "entry_date": self.entry_date, "user_id": username, "est_just": self.est_just, @@ -121,7 +121,7 @@ class Assiduite(db.Model): etat=etat, etudiant=etud, moduleimpl_id=moduleimpl.id, - desc=description, + description=description, entry_date=entry_date, user_id=user_id, est_just=est_just, @@ -134,7 +134,7 @@ class Assiduite(db.Model): date_fin=date_fin, etat=etat, etudiant=etud, - desc=description, + description=description, entry_date=entry_date, user_id=user_id, est_just=est_just, @@ -162,7 +162,7 @@ class Assiduite(db.Model): etat=etat, etudid=etudid, moduleimpl_id=moduleimpl_id, - desc=description, + description=description, entry_date=entry_date, est_just=est_just, ) diff --git a/migrations/versions/50f7e0b6229f_assiduites_champ_desc_description.py b/migrations/versions/50f7e0b6229f_assiduites_champ_desc_description.py new file mode 100644 index 000000000..f37b1ce6f --- /dev/null +++ b/migrations/versions/50f7e0b6229f_assiduites_champ_desc_description.py @@ -0,0 +1,28 @@ +"""assiduites_champ_desc_description + +Revision ID: 50f7e0b6229f +Revises: b555390780b2 +Create Date: 2023-07-20 12:52:27.882303 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = "50f7e0b6229f" +down_revision = "b555390780b2" +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.alter_column("assiduites", "desc", new_column_name="description") + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.alter_column("assiduites", "description", new_column_name="desc") + # ### end Alembic commands ### diff --git a/tools/migrate_abs_to_assiduites.py b/tools/migrate_abs_to_assiduites.py index 2a096b981..8843f4bce 100644 --- a/tools/migrate_abs_to_assiduites.py +++ b/tools/migrate_abs_to_assiduites.py @@ -129,8 +129,8 @@ class _Merger: _glob.cursor.execute( """INSERT INTO assiduites - (etudid,date_debut,date_fin,etat,moduleimpl_id,"desc",entry_date) - VALUES (%(etudid)s,%(date_debut)s,%(date_fin)s,%(etat)s,%(moduleimpl_id)s,%(desc)s,%(entry_date)s) + (etudid,date_debut,date_fin,etat,moduleimpl_id,"description",entry_date) + VALUES (%(etudid)s,%(date_debut)s,%(date_fin)s,%(etat)s,%(moduleimpl_id)s,%(description)s,%(entry_date)s) """, { "etudid": self.etudid, @@ -138,7 +138,7 @@ class _Merger: "date_fin": date_fin, "etat": EtatAssiduite.ABSENT, "moduleimpl_id": self.moduleimpl, - "desc": self.raison, + "description": self.raison, "entry_date": self.entry_date, }, )