diff --git a/app/models/__init__.py b/app/models/__init__.py index d763012ca..e4db11299 100644 --- a/app/models/__init__.py +++ b/app/models/__init__.py @@ -33,7 +33,7 @@ from app.models.formations import ( from app.models.formsemestre import ( FormSemestre, NotesFormsemestreEtape, - FormModalite, + NotesFormModalite, NotesFormsemestreUECoef, NotesFormsemestreUEComputationExpr, NotesFormsemestreCustomMenu, diff --git a/app/models/formations.py b/app/models/formations.py index bb0c5d6a7..b92d113c4 100644 --- a/app/models/formations.py +++ b/app/models/formations.py @@ -88,6 +88,7 @@ class NotesModule(db.Model): heures_td = db.Column(db.Float) heures_tp = db.Column(db.Float) coefficient = db.Column(db.Float) # coef PPN + ects = db.Column(db.Float) # Crédits ECTS ue_id = db.Column(db.Integer, db.ForeignKey("notes_ue.id"), index=True) formation_id = db.Column(db.Integer, db.ForeignKey("notes_formations.id")) matiere_id = db.Column(db.Integer, db.ForeignKey("notes_matieres.id")) diff --git a/app/models/formsemestre.py b/app/models/formsemestre.py index 372582924..5c1bcc39b 100644 --- a/app/models/formsemestre.py +++ b/app/models/formsemestre.py @@ -25,7 +25,7 @@ class FormSemestre(db.Model): date_debut = db.Column(db.Date()) date_fin = db.Column(db.Date()) etat = db.Column(db.Boolean(), nullable=False, default=True) # False si verrouillé - modalite = db.Column(db.String(16), db.ForeignKey("form_modalite.modalite")) + modalite = db.Column(db.String(16), db.ForeignKey("notes_form_modalites.modalite")) # gestion compensation sem DUT: gestion_compensation = db.Column(db.Boolean(), nullable=False, default=False) # ne publie pas le bulletin XML: @@ -52,7 +52,7 @@ class FormSemestre(db.Model): def __init__(self, **kwargs): super(FormSemestre, self).__init__(**kwargs) if self.modalite is None: - self.modalite = FormModalite.DEFAULT_MODALITE + self.modalite = NotesFormModalite.DEFAULT_MODALITE # Association id des utilisateurs responsables (aka directeurs des etudes) du semestre @@ -79,11 +79,13 @@ class NotesFormsemestreEtape(db.Model): etape_apo = db.Column(db.String(APO_CODE_STR_LEN)) -class FormModalite(db.Model): +class NotesFormModalite(db.Model): """Modalités de formation, utilisées pour la présentation (grouper les semestres, générer des codes, etc.) """ + __tablename__ = "notes_form_modalites" + id = db.Column(db.Integer, primary_key=True) modalite = db.Column(db.String(16), unique=True, index=True) # code titre = db.Column(db.Text()) # texte explicatif @@ -97,7 +99,7 @@ class FormModalite(db.Model): """Create default modalities""" numero = 0 for (code, titre) in ( - (FormModalite.DEFAULT_MODALITE, "Formation Initiale"), + (NotesFormModalite.DEFAULT_MODALITE, "Formation Initiale"), ("FAP", "Apprentissage"), ("FC", "Formation Continue"), ("DEC", "Formation Décalées"), @@ -108,9 +110,9 @@ class FormModalite(db.Model): ("EXT", "Extérieur"), ("OTHER", "Autres formations"), ): - modalite = FormModalite.query.filter_by(modalite=code).first() + modalite = NotesFormModalite.query.filter_by(modalite=code).first() if modalite is None: - modalite = FormModalite(modalite=code, titre=titre, numero=numero) + modalite = NotesFormModalite(modalite=code, titre=titre, numero=numero) db.session.add(modalite) numero += 1 db.session.commit() @@ -249,7 +251,7 @@ class NotesEvaluation(db.Model): id = db.Column(db.Integer, primary_key=True) evaluation_id = db.synonym("id") moduleimpl_id = db.Column( - db.Integer, db.ForeignKey("notes_moduleimpl.moduleimpl_id"), index=True + db.Integer, db.ForeignKey("notes_moduleimpl.id"), index=True ) jour = db.Column(db.Date) heure_debut = db.Column(db.Time) diff --git a/app/scodoc/sco_formsemestre_edit.py b/app/scodoc/sco_formsemestre_edit.py index e10ab0fa7..6d4120c62 100644 --- a/app/scodoc/sco_formsemestre_edit.py +++ b/app/scodoc/sco_formsemestre_edit.py @@ -195,10 +195,12 @@ def do_formsemestre_createwithmodules(context, REQUEST=None, edit=False): ) # Liste des ID de semestres - cnx = ndb.GetDBConnexion() - cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor) - cursor.execute("select semestre_id from notes_semestres") - semestre_id_list = [str(x[0]) for x in cursor.fetchall()] + if F["type_parcours"] is not None: + parcours = sco_codes_parcours.get_parcours_from_code(F["type_parcours"]) + NB_SEM = parcours.NB_SEM + else: + NB_SEM = 10 # fallback, max 10 semestres + semestre_id_list = [-1] + [str(x) for x in range(1, NB_SEM + 1)] semestre_id_labels = [] for sid in semestre_id_list: if sid == "-1": @@ -680,10 +682,10 @@ def do_formsemestre_createwithmodules(context, REQUEST=None, edit=False): if tf[0] == 0 or msg: return ( - '
Formation %(titre)s (%(acronyme)s), version %(version)d, code %(formation_code)s
' + 'Formation %(titre)s (%(acronyme)s), version %(version)s, code %(formation_code)s
' % F + msg - + tf[1] + + str(tf[1]) ) elif tf[0] == -1: return "