forked from ScoDoc/ScoDoc
Update opolka/ScoDoc from ScoDoc/ScoDoc #2
@ -12,6 +12,7 @@ from sqlalchemy.exc import IntegrityError
|
|||||||
|
|
||||||
from app import db, log
|
from app import db, log
|
||||||
from app.models import Scolog, GROUPNAME_STR_LEN, SHORT_STR_LEN
|
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_cache
|
||||||
from app.scodoc import sco_utils as scu
|
from app.scodoc import sco_utils as scu
|
||||||
from app.scodoc.sco_exceptions import AccessDenied, ScoValueError
|
from app.scodoc.sco_exceptions import AccessDenied, ScoValueError
|
||||||
@ -50,7 +51,7 @@ class Partition(db.Model):
|
|||||||
backref=db.backref("partition", lazy=True),
|
backref=db.backref("partition", lazy=True),
|
||||||
lazy="dynamic",
|
lazy="dynamic",
|
||||||
cascade="all, delete-orphan",
|
cascade="all, delete-orphan",
|
||||||
order_by="GroupDescr.numero",
|
order_by="GroupDescr.numero, GroupDescr.group_name",
|
||||||
)
|
)
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
@ -240,6 +241,21 @@ class GroupDescr(db.Model):
|
|||||||
d["partition"] = self.partition.to_dict(with_groups=False)
|
d["partition"] = self.partition.to_dict(with_groups=False)
|
||||||
return d
|
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
|
@classmethod
|
||||||
def check_name(
|
def check_name(
|
||||||
cls, partition: "Partition", group_name: str, existing=False, default=False
|
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)
|
# Genere liste pour chaque partition (categorie de groupes)
|
||||||
for partition in formsemestre.get_partitions_list():
|
for partition in formsemestre.get_partitions_list():
|
||||||
groups = partition.groups.all()
|
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
|
partition_is_empty = sum(effectifs.values()) == 0
|
||||||
H.append(
|
H.append(
|
||||||
f"""
|
f"""
|
||||||
|
Loading…
Reference in New Issue
Block a user