forked from ScoDoc/ScoDoc
Fix comptes membres groupes
This commit is contained in:
parent
366bd0bea7
commit
7a9c399812
@ -12,6 +12,7 @@ from sqlalchemy.exc import IntegrityError
|
||||
|
||||
from app import db, log
|
||||
from app.models import Scolog, GROUPNAME_STR_LEN, SHORT_STR_LEN
|
||||
from app.models.etudiants import Identite
|
||||
from app.scodoc import sco_cache
|
||||
from app.scodoc import sco_utils as scu
|
||||
from app.scodoc.sco_exceptions import AccessDenied, ScoValueError
|
||||
@ -50,7 +51,7 @@ class Partition(db.Model):
|
||||
backref=db.backref("partition", lazy=True),
|
||||
lazy="dynamic",
|
||||
cascade="all, delete-orphan",
|
||||
order_by="GroupDescr.numero",
|
||||
order_by="GroupDescr.numero, GroupDescr.group_name",
|
||||
)
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
@ -240,6 +241,21 @@ class GroupDescr(db.Model):
|
||||
d["partition"] = self.partition.to_dict(with_groups=False)
|
||||
return d
|
||||
|
||||
def get_nb_inscrits(self) -> int:
|
||||
"""Nombre inscrits à ce group et au formsemestre.
|
||||
C'est nécessaire car lors d'une désinscription, on conserve l'appartenance
|
||||
aux groupes pour facilier une éventuelle ré-inscription.
|
||||
"""
|
||||
from app.models.formsemestre import FormSemestreInscription
|
||||
|
||||
return (
|
||||
Identite.query.join(group_membership)
|
||||
.filter_by(group_id=self.id)
|
||||
.join(FormSemestreInscription)
|
||||
.filter_by(formsemestre_id=self.partition.formsemestre.id)
|
||||
.count()
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def check_name(
|
||||
cls, partition: "Partition", group_name: str, existing=False, default=False
|
||||
|
@ -828,7 +828,7 @@ def _make_listes_sem(formsemestre: FormSemestre) -> str:
|
||||
# Genere liste pour chaque partition (categorie de groupes)
|
||||
for partition in formsemestre.get_partitions_list():
|
||||
groups = partition.groups.all()
|
||||
effectifs = {g.id: g.etuds.count() for g in groups}
|
||||
effectifs = {g.id: g.get_nb_inscrits() for g in groups}
|
||||
partition_is_empty = sum(effectifs.values()) == 0
|
||||
H.append(
|
||||
f"""
|
||||
|
Loading…
Reference in New Issue
Block a user