diff --git a/app/scodoc/sco_groups.py b/app/scodoc/sco_groups.py index 43362edd7f..08d09bea25 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 4d88cdb163..fc6128f533 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: