From c474e48ec82405347cf55d73557e62bd7bbc318d Mon Sep 17 00:00:00 2001 From: Jean-Marie Place Date: Wed, 1 Mar 2023 14:39:36 +0100 Subject: [PATCH] add default_partition filter in etud_add_group_infos --- app/scodoc/sco_groups.py | 8 +++++--- app/scodoc/sco_import_etuds.py | 6 +++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/scodoc/sco_groups.py b/app/scodoc/sco_groups.py index 43362edd7..08d09bea2 100644 --- a/app/scodoc/sco_groups.py +++ b/app/scodoc/sco_groups.py @@ -456,11 +456,13 @@ def get_etud_formsemestre_groups( # Ancienne fonction: -def etud_add_group_infos(etud, formsemestre_id, sep=" ", only_to_show=False): +def etud_add_group_infos( + etud, formsemestre_id, sep=" ", only_to_show=False, with_default_partition=True +): """Add informations on partitions and group memberships to etud (a dict with an etudid) If only_to_show, restrict to partions such that show_in_lists is True. - + If with_default_partition, does not discard partition whose name is None etud['partitions'] = { partition_id : group + partition_name } etud['groupes'] = "TDB, Gr2, TPB1" etud['partitionsgroupes'] = "Groupes TD:TDB, Groupes TP:Gr2 (...)" @@ -471,7 +473,6 @@ def etud_add_group_infos(etud, formsemestre_id, sep=" ", only_to_show=False): if not formsemestre_id: etud["groupes"] = "" return etud - infos = ndb.SimpleDictFetch( """SELECT p.partition_name, p.show_in_lists, g.*, g.id AS group_id FROM group_descr g, partition p, group_membership gm WHERE gm.etudid=%(etudid)s @@ -480,6 +481,7 @@ def etud_add_group_infos(etud, formsemestre_id, sep=" ", only_to_show=False): and p.formsemestre_id = %(formsemestre_id)s """ + (" and (p.show_in_lists is True) " if only_to_show else "") + + (" and (p.partition_name is not null) " if not with_default_partition else "") + """ ORDER BY p.numero """, diff --git a/app/scodoc/sco_import_etuds.py b/app/scodoc/sco_import_etuds.py index 4d88cdb16..fc6128f53 100644 --- a/app/scodoc/sco_import_etuds.py +++ b/app/scodoc/sco_import_etuds.py @@ -197,13 +197,17 @@ def sco_import_generate_excel_sample( titles_styles = [style] + titles_styles # rempli table avec données actuelles lines = [] + breakpoint() for i in members: etud = sco_etud.get_etud_info(etudid=i["etudid"], filled=True)[0] l = [] for field in titles: if field == "groupes": sco_groups.etud_add_group_infos( - etud, groups_infos.formsemestre_id, sep=";" + etud, + groups_infos.formsemestre_id, + sep=";", + with_default_partition=False, ) l.append(etud["partitionsgroupes"]) else: