From 6d881915bd052c99f67e9535f32a6a1900f28ceb Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sun, 10 Jul 2022 12:08:22 +0200 Subject: [PATCH] Fix: association parcours (restriction au dept.) --- app/models/but_refcomp.py | 6 +++--- app/models/departements.py | 3 +++ app/models/formsemestre.py | 10 +++++++--- sco_version.py | 2 +- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/app/models/but_refcomp.py b/app/models/but_refcomp.py index 8cd7b1c7e..0a4afd076 100644 --- a/app/models/but_refcomp.py +++ b/app/models/but_refcomp.py @@ -84,7 +84,7 @@ class ApcReferentielCompetences(db.Model, XMLModel): formations = db.relationship("Formation", backref="referentiel_competence") def __repr__(self): - return f"" + return f"" def to_dict(self): """Représentation complète du ref. de comp. @@ -432,7 +432,7 @@ class ApcParcours(db.Model, XMLModel): ) def __repr__(self): - return f"<{self.__class__.__name__} {self.code!r}>" + return f"<{self.__class__.__name__} {self.id} {self.code!r} ref={self.referentiel}>" def to_dict(self): return { @@ -452,7 +452,7 @@ class ApcAnneeParcours(db.Model, XMLModel): "numéro de l'année: 1, 2, 3" def __repr__(self): - return f"<{self.__class__.__name__} ordre={self.ordre!r} parcours={self.parcours.code!r}>" + return f"<{self.__class__.__name__} {self.id} ordre={self.ordre!r} parcours={self.parcours.code!r}>" def to_dict(self): return { diff --git a/app/models/departements.py b/app/models/departements.py index 44a963ca0..416c5177b 100644 --- a/app/models/departements.py +++ b/app/models/departements.py @@ -31,6 +31,9 @@ class Departement(db.Model): "ScoPreference", lazy="dynamic", backref="departement" ) semsets = db.relationship("NotesSemSet", lazy="dynamic", backref="departement") + referentiels = db.relationship( + "ApcReferentielCompetences", lazy="dynamic", backref="departement" + ) def __repr__(self): return f"<{self.__class__.__name__}(id={self.id}, acronym='{self.acronym}')>" diff --git a/app/models/formsemestre.py b/app/models/formsemestre.py index 99dd4a597..93a4e5376 100644 --- a/app/models/formsemestre.py +++ b/app/models/formsemestre.py @@ -5,7 +5,7 @@ import datetime from functools import cached_property -from flask import flash +from flask import flash, g import flask_sqlalchemy from sqlalchemy.sql import text @@ -19,11 +19,11 @@ from app.models.but_refcomp import ( ApcNiveau, ApcParcours, ApcParcoursNiveauCompetence, + ApcReferentielCompetences, ) from app.models.groups import GroupDescr, Partition import app.scodoc.sco_utils as scu -from app.models.but_refcomp import ApcParcours from app.models.but_refcomp import parcours_formsemestre from app.models.etudiants import Identite from app.models.modules import Module @@ -577,7 +577,11 @@ class FormSemestre(db.Model): ) # Inscrit les étudiants des groupes de parcours: for group in partition.groups: - query = ApcParcours.query.filter_by(code=group.group_name) + query = ( + ApcParcours.query.filter_by(code=group.group_name) + .join(ApcReferentielCompetences) + .filter_by(dept_id=g.scodoc_dept_id) + ) if query.count() != 1: log( f"""update_inscriptions_parcours_from_groups: { diff --git a/sco_version.py b/sco_version.py index 3a047c3f1..83068bb61 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.3.18" +SCOVERSION = "9.3.19" SCONAME = "ScoDoc"