Fix: association parcours (restriction au dept.)

This commit is contained in:
Emmanuel Viennet 2022-07-10 12:08:22 +02:00
parent 51178795e2
commit 6d881915bd
4 changed files with 14 additions and 7 deletions

View File

@ -84,7 +84,7 @@ class ApcReferentielCompetences(db.Model, XMLModel):
formations = db.relationship("Formation", backref="referentiel_competence")
def __repr__(self):
return f"<ApcReferentielCompetences {self.id} {self.specialite!r}>"
return f"<ApcReferentielCompetences {self.id} {self.specialite!r} {self.departement!r}>"
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 {

View File

@ -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}')>"

View File

@ -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: {

View File

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