From 94eedcc6e8bf4bb3c9961a0bb2a6d9eb90e3941b Mon Sep 17 00:00:00 2001 From: Arthur ZHU Date: Wed, 2 Mar 2022 17:56:58 +0100 Subject: [PATCH] Export des annotations --- app/scodoc/sco_groups.py | 22 ++++++++++++++++++++++ app/scodoc/sco_groups_view.py | 2 ++ app/views/scolar.py | 3 +++ 3 files changed, 27 insertions(+) diff --git a/app/scodoc/sco_groups.py b/app/scodoc/sco_groups.py index 6a1ee4679..f8653fe30 100644 --- a/app/scodoc/sco_groups.py +++ b/app/scodoc/sco_groups.py @@ -60,6 +60,7 @@ from app.scodoc import sco_cache from app.scodoc import sco_etud from app.scodoc import sco_permissions_check from app.scodoc import sco_xml +from app.scodoc import sco_excel from app.scodoc.sco_exceptions import ScoException, AccessDenied, ScoValueError from app.scodoc.sco_permissions import Permission from app.scodoc.TrivialFormulator import TrivialFormulator @@ -1609,6 +1610,27 @@ def make_query_groups(group_ids): return "" +def exportAnnotation(group_ids): + cnx = ndb.GetDBConnexion() + cursor = cnx.cursor() + cursor.execute( + """SELECT i.nom, i.prenom, ea.date, ea.comment + FROM group_membership gm, identite i, etud_annotations ea + WHERE gm.group_id=%(group_ids)s + AND gm.etudid=i.id + AND i.id=ea.etudid + """, + {"group_ids": group_ids}, + ) + titles = ["nom", "prenom", "date", "annotation"] + title = "annotations" + xlsx = sco_excel.excel_simple_table( + titles=titles, lines=cursor.fetchall(), sheet_name=title + ) + filename = title + return scu.send_file(xlsx, filename, scu.XLSX_SUFFIX, scu.XLSX_MIMETYPE) + + class GroupIdInferer(object): """Sert à retrouver l'id d'un groupe dans un semestre donné à partir de son nom. diff --git a/app/scodoc/sco_groups_view.py b/app/scodoc/sco_groups_view.py index 5b89ab44f..cd51a20b2 100644 --- a/app/scodoc/sco_groups_view.py +++ b/app/scodoc/sco_groups_view.py @@ -826,6 +826,8 @@ def tab_absences_html(groups_infos, etat=None): % groups_infos.groups_query_args, """
  • Liste d'appel avec photos
  • """ % groups_infos.groups_query_args, + """
  • Feuille annotations
  • """ + % groups_infos.groups_query_args, "", ] ) diff --git a/app/views/scolar.py b/app/views/scolar.py index 060fd4c38..66a9576e3 100644 --- a/app/views/scolar.py +++ b/app/views/scolar.py @@ -2193,3 +2193,6 @@ def stat_bac(formsemestre_id): sco_publish( "/sco_dump_and_send_db", sco_dump_db.sco_dump_and_send_db, Permission.ScoView ) + +# --- Export annotations +sco_publish("/exportAnnotations", sco_groups.exportAnnotation, Permission.ScoView)