Merge pull request 'add default_partition filter in etud_add_group_infos' (#611) from jmplace/ScoDoc-Lille:discard_default_partition_from_export into master

Reviewed-on: https://scodoc.org/git/ScoDoc/ScoDoc/pulls/611
This commit is contained in:
Emmanuel Viennet 2023-03-01 14:51:47 +01:00
commit 0ab31a92cc
2 changed files with 10 additions and 4 deletions

View File

@ -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
""",

View File

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