From 908f78477dd0a0399251db6dbd1f353f81d2a523 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Wed, 19 Jan 2022 23:02:15 +0100 Subject: [PATCH] =?UTF-8?q?Augmente=20taille=20max=20code=20Apog=C3=A9e=20?= =?UTF-8?q?+=20check=20edit=20module?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/__init__.py | 2 +- app/scodoc/sco_edit_module.py | 9 +- app/scodoc/sco_edit_ue.py | 3 +- ...874ed6af64_augmente_taille_codes_apogee.py | 84 +++++++++++++++++++ 4 files changed, 92 insertions(+), 6 deletions(-) create mode 100644 migrations/versions/28874ed6af64_augmente_taille_codes_apogee.py diff --git a/app/models/__init__.py b/app/models/__init__.py index 0fee7bc4..4a3328b3 100644 --- a/app/models/__init__.py +++ b/app/models/__init__.py @@ -6,7 +6,7 @@ XXX version préliminaire ScoDoc8 #sco8 sans département CODE_STR_LEN = 16 # chaine pour les codes SHORT_STR_LEN = 32 # courtes chaine, eg acronymes -APO_CODE_STR_LEN = 24 # nb de car max d'un code Apogée +APO_CODE_STR_LEN = 512 # nb de car max d'un code Apogée (il peut y en avoir plusieurs) GROUPNAME_STR_LEN = 64 from app.models.raw_sql_init import create_database_functions diff --git a/app/scodoc/sco_edit_module.py b/app/scodoc/sco_edit_module.py index 813320d5..25ec3d25 100644 --- a/app/scodoc/sco_edit_module.py +++ b/app/scodoc/sco_edit_module.py @@ -32,15 +32,15 @@ import flask from flask import url_for, render_template from flask import g, request from flask_login import current_user + +from app import log +from app import models from app.models import APO_CODE_STR_LEN -from app.models import Matiere, Module, UniteEns +from app.models import Formation, Matiere, Module, UniteEns import app.scodoc.notesdb as ndb import app.scodoc.sco_utils as scu from app.scodoc.sco_utils import ModuleType -from app import log -from app import models -from app.models import Formation from app.scodoc.TrivialFormulator import TrivialFormulator from app.scodoc.sco_permissions import Permission from app.scodoc.sco_exceptions import ( @@ -294,6 +294,7 @@ def module_create(matiere_id=None, module_type=None, semestre_id=None): "title": "Code Apogée", "size": 25, "explanation": "(optionnel) code élément pédagogique Apogée ou liste de codes ELP séparés par des virgules", + "validator": lambda val, _: len(val) < APO_CODE_STR_LEN, }, ), ( diff --git a/app/scodoc/sco_edit_ue.py b/app/scodoc/sco_edit_ue.py index a52826b7..c9a2da17 100644 --- a/app/scodoc/sco_edit_ue.py +++ b/app/scodoc/sco_edit_ue.py @@ -1216,7 +1216,8 @@ def do_ue_edit(args, bypass_lock=False, dont_invalidate_cache=False): def edit_ue_set_code_apogee(id=None, value=None): "set UE code apogee" ue_id = id - value = value.strip("-_ \t") + value = value.strip("-_ \t")[:APO_CODE_STR_LEN] # tronque + log("edit_ue_set_code_apogee: ue_id=%s code_apogee=%s" % (ue_id, value)) ues = ue_list(args={"ue_id": ue_id}) diff --git a/migrations/versions/28874ed6af64_augmente_taille_codes_apogee.py b/migrations/versions/28874ed6af64_augmente_taille_codes_apogee.py new file mode 100644 index 00000000..7ac8c8c3 --- /dev/null +++ b/migrations/versions/28874ed6af64_augmente_taille_codes_apogee.py @@ -0,0 +1,84 @@ +"""augmente taille codes Apogée + +Revision ID: 28874ed6af64 +Revises: f40fbaf5831c +Create Date: 2022-01-19 22:57:59.678313 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +# revision identifiers, used by Alembic. +revision = "28874ed6af64" +down_revision = "f40fbaf5831c" +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + + op.alter_column( + "notes_formsemestre_etapes", + "etape_apo", + existing_type=sa.VARCHAR(length=24), + type_=sa.String(length=512), + existing_nullable=True, + ) + op.alter_column( + "notes_formsemestre_inscription", + "etape", + existing_type=sa.VARCHAR(length=24), + type_=sa.String(length=512), + existing_nullable=True, + ) + op.alter_column( + "notes_modules", + "code_apogee", + existing_type=sa.VARCHAR(length=24), + type_=sa.String(length=512), + existing_nullable=True, + ) + op.alter_column( + "notes_ue", + "code_apogee", + existing_type=sa.VARCHAR(length=24), + type_=sa.String(length=512), + existing_nullable=True, + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.alter_column( + "notes_ue", + "code_apogee", + existing_type=sa.String(length=512), + type_=sa.VARCHAR(length=24), + existing_nullable=True, + ) + op.alter_column( + "notes_modules", + "code_apogee", + existing_type=sa.String(length=512), + type_=sa.VARCHAR(length=24), + existing_nullable=True, + ) + op.alter_column( + "notes_formsemestre_inscription", + "etape", + existing_type=sa.String(length=512), + type_=sa.VARCHAR(length=24), + existing_nullable=True, + ) + op.alter_column( + "notes_formsemestre_etapes", + "etape_apo", + existing_type=sa.String(length=512), + type_=sa.VARCHAR(length=24), + existing_nullable=True, + ) + + # ### end Alembic commands ###