From e918b5bcb4f3de9bb1dd062cc2211e3a76cfac30 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Thu, 21 Sep 2023 10:20:19 +0200 Subject: [PATCH] =?UTF-8?q?Remplace=20variable=20'format'=20par=20'fmt'=20?= =?UTF-8?q?dans=20toutes=20les=20fonctions=20et=20URLs=20(sauf=20routes=20?= =?UTF-8?q?API=20document=C3=A9es)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/etudiants.py | 2 +- app/but/bulletin_but.py | 2 +- app/but/bulletin_but_court_pdf.py | 2 +- app/but/bulletin_but_pdf.py | 4 +- app/but/bulletin_but_xml_compat.py | 2 +- app/but/jury_but_pv.py | 2 +- app/scodoc/gen_tables.py | 50 +++++++------ app/scodoc/sco_archives.py | 2 +- app/scodoc/sco_bulletins.py | 58 +++++++-------- app/scodoc/sco_bulletins_generator.py | 16 ++--- app/scodoc/sco_bulletins_legacy.py | 2 +- app/scodoc/sco_bulletins_pdf.py | 10 +-- app/scodoc/sco_bulletins_standard.py | 2 +- app/scodoc/sco_bulletins_xml.py | 2 +- app/scodoc/sco_cost_formation.py | 4 +- app/scodoc/sco_debouche.py | 14 ++-- app/scodoc/sco_edit_ue.py | 6 +- app/scodoc/sco_etape_apogee_view.py | 26 +++---- app/scodoc/sco_etape_bilan.py | 4 +- app/scodoc/sco_evaluations.py | 4 +- app/scodoc/sco_export_results.py | 6 +- app/scodoc/sco_find_etud.py | 4 +- app/scodoc/sco_formation_recap.py | 6 +- app/scodoc/sco_formations.py | 10 +-- app/scodoc/sco_formsemestre.py | 4 +- app/scodoc/sco_formsemestre_status.py | 6 +- app/scodoc/sco_groups.py | 4 +- app/scodoc/sco_groups_exports.py | 6 +- app/scodoc/sco_groups_view.py | 66 +++++++++-------- app/scodoc/sco_liste_notes.py | 14 ++-- app/scodoc/sco_lycee.py | 20 +++--- app/scodoc/sco_placement.py | 2 +- app/scodoc/sco_poursuite_dut.py | 4 +- app/scodoc/sco_pv_forms.py | 12 ++-- app/scodoc/sco_report.py | 80 ++++++++++----------- app/scodoc/sco_report_but.py | 6 +- app/scodoc/sco_semset.py | 6 +- app/scodoc/sco_trombino.py | 24 +++---- app/scodoc/sco_undo_notes.py | 6 +- app/scodoc/sco_users.py | 2 +- app/scodoc/sco_utils.py | 14 ++-- app/templates/assiduites/pages/visu_assi.j2 | 2 +- app/templates/bul_head.j2 | 4 +- app/views/absences.py | 14 ++-- app/views/assiduites.py | 2 +- app/views/notes.py | 52 +++++++------- app/views/scodoc.py | 4 +- app/views/scolar.py | 29 ++++---- misc/example-api-python2.py | 10 +-- tests/api/exemple-api-basic.py | 40 ----------- tests/api/exemple-api-scodoc7.py | 7 +- tests/unit/test_formations.py | 10 +-- tests/unit/test_formsemestre.py | 8 +-- 53 files changed, 327 insertions(+), 371 deletions(-) diff --git a/app/api/etudiants.py b/app/api/etudiants.py index 29132a99ec..53f2ed3e5f 100755 --- a/app/api/etudiants.py +++ b/app/api/etudiants.py @@ -399,7 +399,7 @@ def bulletin( formsemestre, etud, version=version, - format="pdf", + fmt="pdf", with_img_signatures_pdf=with_img_signatures_pdf, ) return pdf_response diff --git a/app/but/bulletin_but.py b/app/but/bulletin_but.py index 452c0b2543..494fe090bb 100644 --- a/app/but/bulletin_but.py +++ b/app/but/bulletin_but.py @@ -515,7 +515,7 @@ class BulletinBUT: infos, _ = sco_bulletins.etud_descr_situation_semestre( etud.id, self.res.formsemestre, - format="html", + fmt="html", show_date_inscr=self.prefs["bul_show_date_inscr"], show_decisions=self.prefs["bul_show_decision"], show_uevalid=self.prefs["bul_show_uevalid"], diff --git a/app/but/bulletin_but_court_pdf.py b/app/but/bulletin_but_court_pdf.py index a657cf43a0..9446d84792 100644 --- a/app/but/bulletin_but_court_pdf.py +++ b/app/but/bulletin_but_court_pdf.py @@ -50,7 +50,7 @@ def make_bulletin_but_court_pdf( try: PDFLOCK.acquire() bul_generator = BulletinGeneratorBUTCourt(**locals()) - bul_pdf = bul_generator.generate(format="pdf") + bul_pdf = bul_generator.generate(fmt="pdf") finally: PDFLOCK.release() return bul_pdf diff --git a/app/but/bulletin_but_pdf.py b/app/but/bulletin_but_pdf.py index 82750d2064..dd3ec68702 100644 --- a/app/but/bulletin_but_pdf.py +++ b/app/but/bulletin_but_pdf.py @@ -14,7 +14,7 @@ La génération du bulletin PDF suit le chemin suivant: - sco_bulletins_generator.make_formsemestre_bulletin_etud() - instance de BulletinGeneratorStandardBUT -- BulletinGeneratorStandardBUT.generate(format="pdf") +- BulletinGeneratorStandardBUT.generate(fmt="pdf") sco_bulletins_generator.BulletinGenerator.generate() .generate_pdf() .bul_table() (ci-dessous) @@ -74,7 +74,7 @@ class BulletinGeneratorStandardBUT(BulletinGeneratorStandard): html_class_ignore_default=True, html_with_td_classes=True, ) - table_objects = table.gen(format=fmt) + table_objects = table.gen(fmt=fmt) objects += table_objects # objects += [KeepInFrame(0, 0, table_objects, mode="shrink")] if i != 2: diff --git a/app/but/bulletin_but_xml_compat.py b/app/but/bulletin_but_xml_compat.py index 75dade0a18..4ab940f7ae 100644 --- a/app/but/bulletin_but_xml_compat.py +++ b/app/but/bulletin_but_xml_compat.py @@ -258,7 +258,7 @@ def bulletin_but_xml_compat( infos, dpv = sco_bulletins.etud_descr_situation_semestre( etudid, formsemestre, - format="xml", + fmt="xml", show_uevalid=sco_preferences.get_preference( "bul_show_uevalid", formsemestre_id ), diff --git a/app/but/jury_but_pv.py b/app/but/jury_but_pv.py index d0933c7a6c..0b8dfd064d 100644 --- a/app/but/jury_but_pv.py +++ b/app/but/jury_but_pv.py @@ -94,7 +94,7 @@ def pvjury_page_but(formsemestre_id: int, fmt="html"): }, xls_style_base=xls_style_base, ) - return tab.make_page(format=fmt, javascripts=["js/etud_info.js"], init_qtip=True) + return tab.make_page(fmt=fmt, javascripts=["js/etud_info.js"], init_qtip=True) def pvjury_table_but( diff --git a/app/scodoc/gen_tables.py b/app/scodoc/gen_tables.py index 7647f3e4c9..8fcda8fb96 100644 --- a/app/scodoc/gen_tables.py +++ b/app/scodoc/gen_tables.py @@ -297,23 +297,23 @@ class GenTable: "list of titles" return [self.titles.get(cid, "") for cid in self.columns_ids] - def gen(self, format="html", columns_ids=None): + def gen(self, fmt="html", columns_ids=None): """Build representation of the table in the specified format. See make_page() for more sophisticated output. """ - if format == "html": + if fmt == "html": return self.html() - elif format == "xls" or format == "xlsx": + elif fmt == "xls" or fmt == "xlsx": return self.excel() - elif format == "text" or format == "csv": + elif fmt == "text" or fmt == "csv": return self.text() - elif format == "pdf": + elif fmt == "pdf": return self.pdf() - elif format == "xml": + elif fmt == "xml": return self.xml() - elif format == "json": + elif fmt == "json": return self.json() - raise ValueError(f"GenTable: invalid format: {format}") + raise ValueError(f"GenTable: invalid format: {fmt}") def _gen_html_row(self, row, line_num=0, elem="td", css_classes=""): "row is a dict, returns a string ..." @@ -477,15 +477,13 @@ class GenTable: H.append('') if self.xls_link: H.append( - ' %s' - % (self.base_url, scu.ICON_XLS) + ' %s' % (self.base_url, scu.ICON_XLS) ) if self.xls_link and self.pdf_link: H.append(" ") if self.pdf_link: H.append( - ' %s' - % (self.base_url, scu.ICON_PDF) + ' %s' % (self.base_url, scu.ICON_PDF) ) H.append("") H.append("

") @@ -653,7 +651,7 @@ class GenTable: def make_page( self, title="", - format="html", + fmt="html", page_title="", filename=None, javascripts=[], @@ -670,7 +668,7 @@ class GenTable: filename = self.filename page_title = page_title or self.page_title html_title = self.html_title or title - if format == "html": + if fmt == "html": H = [] if with_html_headers: H.append( @@ -687,7 +685,7 @@ class GenTable: if with_html_headers: H.append(html_sco_header.sco_footer()) return "\n".join(H) - elif format == "pdf": + elif fmt == "pdf": pdf_objs = self.pdf() pdf_doc = sco_pdf.pdf_basic_page( pdf_objs, title=title, preferences=self.preferences @@ -701,7 +699,7 @@ class GenTable: ) else: return pdf_doc - elif format == "xls" or format == "xlsx": # dans les 2 cas retourne du xlsx + elif fmt == "xls" or fmt == "xlsx": # dans les 2 cas retourne du xlsx xls = self.excel() if publish: return scu.send_file( @@ -712,9 +710,9 @@ class GenTable: ) else: return xls - elif format == "text": + elif fmt == "text": return self.text() - elif format == "csv": + elif fmt == "csv": return scu.send_file( self.text(), filename, @@ -722,14 +720,14 @@ class GenTable: mime=scu.CSV_MIMETYPE, attached=True, ) - elif format == "xml": + elif fmt == "xml": xml = self.xml() if publish: return scu.send_file( xml, filename, suffix=".xml", mime=scu.XML_MIMETYPE ) return xml - elif format == "json": + elif fmt == "json": js = self.json() if publish: return scu.send_file( @@ -737,7 +735,7 @@ class GenTable: ) return js else: - log("make_page: format=%s" % format) + log(f"make_page: format={fmt}") raise ValueError("_make_page: invalid format") @@ -771,18 +769,18 @@ if __name__ == "__main__": columns_ids=("nom", "age"), ) print("--- HTML:") - print(table.gen(format="html")) + print(table.gen(fmt="html")) print("\n--- XML:") - print(table.gen(format="xml")) + print(table.gen(fmt="xml")) print("\n--- JSON:") - print(table.gen(format="json")) + print(table.gen(fmt="json")) # Test pdf: import io from app.scodoc import sco_preferences preferences = sco_preferences.SemPreferences() table.preferences = preferences - objects = table.gen(format="pdf") + objects = table.gen(fmt="pdf") objects = [KeepInFrame(0, 0, objects, mode="shrink")] doc = io.BytesIO() document = sco_pdf.BaseDocTemplate(doc) @@ -795,6 +793,6 @@ if __name__ == "__main__": data = doc.getvalue() with open("/tmp/gen_table.pdf", "wb") as f: f.write(data) - p = table.make_page(format="pdf") + p = table.make_page(fmt="pdf") with open("toto.pdf", "wb") as f: f.write(p) diff --git a/app/scodoc/sco_archives.py b/app/scodoc/sco_archives.py index 6fe8f7669d..789509c3f5 100644 --- a/app/scodoc/sco_archives.py +++ b/app/scodoc/sco_archives.py @@ -406,7 +406,7 @@ def do_formsemestre_archive( data = response.get_data() else: # formations classiques data = sco_pv_forms.formsemestre_pvjury( - formsemestre_id, format="xls", publish=False + formsemestre_id, fmt="xls", publish=False ) if data: PV_ARCHIVER.store( diff --git a/app/scodoc/sco_bulletins.py b/app/scodoc/sco_bulletins.py index 0fe70efa3d..b1600c1d5a 100644 --- a/app/scodoc/sco_bulletins.py +++ b/app/scodoc/sco_bulletins.py @@ -95,7 +95,7 @@ def get_formsemestre_bulletin_etud_json( return formsemestre_bulletinetud( etud, formsemestre_id=formsemestre.id, - format="json", + fmt="json", version=version, xml_with_decisions=True, force_publishing=force_publishing, @@ -201,7 +201,7 @@ def formsemestre_bulletinetud_dict(formsemestre_id, etudid, version="long"): infos, dpv = etud_descr_situation_semestre( etudid, formsemestre, - format="html", + fmt="html", show_date_inscr=prefs["bul_show_date_inscr"], show_decisions=prefs["bul_show_decision"], show_uevalid=prefs["bul_show_uevalid"], @@ -582,7 +582,7 @@ def _ue_mod_bulletin( "notes.evaluation_listenotes", scodoc_dept=g.scodoc_dept, evaluation_id=e.id, - format="html", + fmt="html", tf_submitted=1, ) e_dict[ @@ -679,14 +679,14 @@ def etud_descr_situation_semestre( etudid, formsemestre: FormSemestre, ne="", - format="html", # currently unused + fmt="html", # currently unused show_decisions=True, show_uevalid=True, show_date_inscr=True, show_mention=False, ): """Dict décrivant la situation de l'étudiant dans ce semestre. - Si format == 'html', peut inclure du balisage html (actuellement inutilisé) + Si fmt == 'html', peut inclure du balisage html (actuellement inutilisé) situation : chaine résumant en français la situation de l'étudiant. Par ex. "Inscrit le 31/12/1999. Décision jury: Validé. ..." @@ -889,7 +889,7 @@ def _format_situation_fields( def formsemestre_bulletinetud( etud: Identite = None, formsemestre_id=None, - format=None, + fmt=None, version="long", xml_with_decisions=False, force_publishing=False, # force publication meme si semestre non publie sur "portail" @@ -910,7 +910,7 @@ def formsemestre_bulletinetud( - prefer_mail_perso: pour pdfmail, utilise adresse mail perso en priorité. """ - format = format or "html" + fmt = fmt or "html" formsemestre: FormSemestre = db.session.get(FormSemestre, formsemestre_id) if not formsemestre: raise ScoValueError(f"semestre {formsemestre_id} inconnu !") @@ -918,21 +918,21 @@ def formsemestre_bulletinetud( bulletin = do_formsemestre_bulletinetud( formsemestre, etud, - format=format, + fmt=fmt, version=version, xml_with_decisions=xml_with_decisions, force_publishing=force_publishing, prefer_mail_perso=prefer_mail_perso, )[0] - if format not in {"html", "pdfmail"}: + if fmt not in {"html", "pdfmail"}: filename = scu.bul_filename(formsemestre, etud) - mime, suffix = scu.get_mime_suffix(format) + mime, suffix = scu.get_mime_suffix(fmt) return scu.send_file(bulletin, filename, mime=mime, suffix=suffix) - elif format == "pdfmail": + elif fmt == "pdfmail": return "" H = [ - _formsemestre_bulletinetud_header_html(etud, formsemestre, format, version), + _formsemestre_bulletinetud_header_html(etud, formsemestre, fmt, version), bulletin, render_template( "bul_foot.j2", @@ -963,7 +963,7 @@ def do_formsemestre_bulletinetud( formsemestre: FormSemestre, etud: Identite, version="long", # short, long, selectedevals - format=None, + fmt=None, xml_with_decisions: bool = False, force_publishing: bool = False, prefer_mail_perso: bool = False, @@ -985,8 +985,8 @@ def do_formsemestre_bulletinetud( où bul est str ou bytes au format demandé (html, pdf, pdfmail, pdfpart, xml, json) et filigranne est un message à placer en "filigranne" (eg "Provisoire"). """ - format = format or "html" - if format == "xml": + fmt = fmt or "html" + if fmt == "xml": bul = sco_bulletins_xml.make_xml_formsemestre_bulletinetud( formsemestre.id, etud.id, @@ -997,7 +997,7 @@ def do_formsemestre_bulletinetud( return bul, "" - elif format == "json": # utilisé pour classic et "oldjson" + elif fmt == "json": # utilisé pour classic et "oldjson" bul = sco_bulletins_json.make_json_formsemestre_bulletinetud( formsemestre.id, etud.id, @@ -1015,23 +1015,23 @@ def do_formsemestre_bulletinetud( else: bul_dict = formsemestre_bulletinetud_dict(formsemestre.id, etud.id) - if format == "html": + if fmt == "html": htm, _ = sco_bulletins_generator.make_formsemestre_bulletin_etud( bul_dict, etud=etud, formsemestre=formsemestre, version=version, fmt="html" ) return htm, bul_dict["filigranne"] - elif format == "pdf" or format == "pdfpart": + if fmt == "pdf" or fmt == "pdfpart": bul, filename = sco_bulletins_generator.make_formsemestre_bulletin_etud( bul_dict, etud=etud, formsemestre=formsemestre, version=version, fmt="pdf", - stand_alone=(format != "pdfpart"), + stand_alone=(fmt != "pdfpart"), with_img_signatures_pdf=with_img_signatures_pdf, ) - if format == "pdf": + if fmt == "pdf": return ( scu.sendPDFFile(bul, filename), bul_dict["filigranne"], @@ -1039,7 +1039,7 @@ def do_formsemestre_bulletinetud( else: return bul, bul_dict["filigranne"] - elif format == "pdfmail": + elif fmt == "pdfmail": # format pdfmail: envoie le pdf par mail a l'etud, et affiche le html # check permission if not can_send_bulletin_by_mail(formsemestre.id): @@ -1067,7 +1067,7 @@ def do_formsemestre_bulletinetud( return True, bul_dict["filigranne"] - raise ValueError(f"do_formsemestre_bulletinetud: invalid format ({format})") + raise ValueError(f"do_formsemestre_bulletinetud: invalid format ({fmt})") def mail_bulletin(formsemestre_id, infos, pdfdata, filename, recipient_addr): @@ -1156,7 +1156,7 @@ def make_menu_autres_operations( "formsemestre_id": formsemestre.id, "etudid": etud.id, "version": version, - "format": "pdf", + "fmt": "pdf", }, }, { @@ -1166,7 +1166,7 @@ def make_menu_autres_operations( "formsemestre_id": formsemestre.id, "etudid": etud.id, "version": version, - "format": "pdfmail", + "fmt": "pdfmail", }, # possible slt si on a un mail... "enabled": etud_email and can_send_bulletin_by_mail(formsemestre.id), @@ -1178,7 +1178,7 @@ def make_menu_autres_operations( "formsemestre_id": formsemestre.id, "etudid": etud.id, "version": version, - "format": "pdfmail", + "fmt": "pdfmail", "prefer_mail_perso": 1, }, # possible slt si on a un mail... @@ -1191,7 +1191,7 @@ def make_menu_autres_operations( "formsemestre_id": formsemestre.id, "etudid": etud.id, "version": version, - "format": "json", + "fmt": "json", }, }, { @@ -1201,7 +1201,7 @@ def make_menu_autres_operations( "formsemestre_id": formsemestre.id, "etudid": etud.id, "version": version, - "format": "xml", + "fmt": "xml", }, }, { @@ -1269,7 +1269,7 @@ def make_menu_autres_operations( def _formsemestre_bulletinetud_header_html( etud, formsemestre: FormSemestre, - format=None, + fmt=None, version=None, ): H = [ @@ -1285,7 +1285,7 @@ def _formsemestre_bulletinetud_header_html( render_template( "bul_head.j2", etud=etud, - format=format, + fmt=fmt, formsemestre=formsemestre, menu_autres_operations=make_menu_autres_operations( etud=etud, diff --git a/app/scodoc/sco_bulletins_generator.py b/app/scodoc/sco_bulletins_generator.py index 34e38f871e..2ec0e23950 100644 --- a/app/scodoc/sco_bulletins_generator.py +++ b/app/scodoc/sco_bulletins_generator.py @@ -35,7 +35,7 @@ class BulletinGenerator: .bul_part_below(fmt) .bul_signatures_pdf() - .__init__ et .generate(format) methodes appelees par le client (sco_bulletin) + .__init__ et .generate(fmt) methodes appelees par le client (sco_bulletin) La préférence 'bul_class_name' donne le nom de la classe generateur. La préférence 'bul_pdf_class_name' est obsolete (inutilisée). @@ -139,18 +139,18 @@ class BulletinGenerator: sem = sco_formsemestre.get_formsemestre(self.bul_dict["formsemestre_id"]) return scu.bul_filename_old(sem, self.bul_dict["etud"], "pdf") - def generate(self, format="", stand_alone=True): + def generate(self, fmt="", stand_alone=True): """Return bulletin in specified format""" - if not format in self.supported_formats: - raise ValueError(f"unsupported bulletin format ({format})") + if not fmt in self.supported_formats: + raise ValueError(f"unsupported bulletin format ({fmt})") try: PDFLOCK.acquire() # this lock is necessary since reportlab is not re-entrant - if format == "html": + if fmt == "html": return self.generate_html() - elif format == "pdf": + elif fmt == "pdf": return self.generate_pdf(stand_alone=stand_alone) else: - raise ValueError(f"invalid bulletin format ({format})") + raise ValueError(f"invalid bulletin format ({fmt})") finally: PDFLOCK.release() @@ -330,7 +330,7 @@ def make_formsemestre_bulletin_etud( version=version, with_img_signatures_pdf=with_img_signatures_pdf, ) - data = bul_generator.generate(format=fmt, stand_alone=stand_alone) + data = bul_generator.generate(fmt=fmt, stand_alone=stand_alone) finally: PDFLOCK.release() diff --git a/app/scodoc/sco_bulletins_legacy.py b/app/scodoc/sco_bulletins_legacy.py index 5ba649f9a2..9650e74ac9 100644 --- a/app/scodoc/sco_bulletins_legacy.py +++ b/app/scodoc/sco_bulletins_legacy.py @@ -252,7 +252,7 @@ class BulletinGeneratorLegacy(sco_bulletins_generator.BulletinGenerator): elif fmt == "html": return self.bul_part_below_html() else: - raise ValueError("invalid bulletin format (%s)" % fmt) + raise ValueError(f"invalid bulletin format ({fmt})") def bul_part_below_pdf(self): """ diff --git a/app/scodoc/sco_bulletins_pdf.py b/app/scodoc/sco_bulletins_pdf.py index 01c39aefad..a3786c828c 100644 --- a/app/scodoc/sco_bulletins_pdf.py +++ b/app/scodoc/sco_bulletins_pdf.py @@ -146,15 +146,15 @@ def process_field( field, cdict, style, suppress_empty_pars=False, fmt="pdf", field_name=None ): """Process a field given in preferences, returns - - if format = 'pdf': a list of Platypus objects - - if format = 'html' : a string + - if fmt = 'pdf': a list of Platypus objects + - if fmt = 'html' : a string Substitutes all %()s markup Remove potentialy harmful tags Replaces by - If format = 'html', replaces by

. HTML does not allow logos. + If fmt = 'html', replaces by

. HTML does not allow logos. """ try: # None values are mapped to empty strings by WrapDict @@ -225,7 +225,7 @@ def get_formsemestre_bulletins_pdf(formsemestre_id, version="selectedevals"): frag, _ = sco_bulletins.do_formsemestre_bulletinetud( formsemestre, etud, - format="pdfpart", + fmt="pdfpart", version=version, ) fragments += frag @@ -270,7 +270,7 @@ def get_etud_bulletins_pdf(etudid, version="selectedevals"): frag, filigranne = sco_bulletins.do_formsemestre_bulletinetud( formsemestre, etud, - format="pdfpart", + fmt="pdfpart", version=version, ) fragments += frag diff --git a/app/scodoc/sco_bulletins_standard.py b/app/scodoc/sco_bulletins_standard.py index e8dda75f08..ab49f8a8b1 100644 --- a/app/scodoc/sco_bulletins_standard.py +++ b/app/scodoc/sco_bulletins_standard.py @@ -116,7 +116,7 @@ class BulletinGeneratorStandard(sco_bulletins_generator.BulletinGenerator): html_with_td_classes=True, ) - return T.gen(format=fmt) + return T.gen(fmt=fmt) def bul_part_below(self, fmt="html"): """Génère les informations placées sous la table de notes diff --git a/app/scodoc/sco_bulletins_xml.py b/app/scodoc/sco_bulletins_xml.py index 3eafc5cabf..58305f1458 100644 --- a/app/scodoc/sco_bulletins_xml.py +++ b/app/scodoc/sco_bulletins_xml.py @@ -357,7 +357,7 @@ def make_xml_formsemestre_bulletinetud( infos, dpv = sco_bulletins.etud_descr_situation_semestre( etudid, formsemestre, - format="xml", + fmt="xml", show_uevalid=sco_preferences.get_preference( "bul_show_uevalid", formsemestre_id ), diff --git a/app/scodoc/sco_cost_formation.py b/app/scodoc/sco_cost_formation.py index 87937b5e13..f266b0638e 100644 --- a/app/scodoc/sco_cost_formation.py +++ b/app/scodoc/sco_cost_formation.py @@ -152,7 +152,7 @@ def formsemestre_estim_cost( n_group_tp=1, coef_tp=1, coef_cours=1.5, - format="html", + fmt="html", ): """Page (formulaire) estimation coûts""" @@ -192,4 +192,4 @@ def formsemestre_estim_cost( coef_tp, ) - return tab.make_page(format=format) + return tab.make_page(fmt=fmt) diff --git a/app/scodoc/sco_debouche.py b/app/scodoc/sco_debouche.py index 09ae1f5a5b..c08a6e9995 100644 --- a/app/scodoc/sco_debouche.py +++ b/app/scodoc/sco_debouche.py @@ -49,7 +49,7 @@ from app.scodoc import sco_etud import sco_version -def report_debouche_date(start_year=None, format="html"): +def report_debouche_date(start_year=None, fmt="html"): """Rapport (table) pour les débouchés des étudiants sortis à partir de l'année indiquée. """ @@ -63,7 +63,7 @@ def report_debouche_date(start_year=None, format="html"): "Année invalide. Année de début de la recherche" ) - if format == "xls": + if fmt == "xls": keep_numeric = True # pas de conversion des notes en strings else: keep_numeric = False @@ -81,7 +81,7 @@ def report_debouche_date(start_year=None, format="html"): title="""

Débouchés étudiants

""", init_qtip=True, javascripts=["js/etud_info.js"], - format=format, + fmt=fmt, with_html_headers=True, ) @@ -276,7 +276,7 @@ def itemsuivi_suppress(itemsuivi_id): return ("", 204) -def itemsuivi_create(etudid, item_date=None, situation="", format=None): +def itemsuivi_create(etudid, item_date=None, situation="", fmt=None): """Creation d'un item""" if not sco_permissions_check.can_edit_suivi(): raise AccessDenied("Vous n'avez pas le droit d'effectuer cette opération !") @@ -287,7 +287,7 @@ def itemsuivi_create(etudid, item_date=None, situation="", format=None): logdb(cnx, method="itemsuivi_create", etudid=etudid) log("created itemsuivi %s for %s" % (itemsuivi_id, etudid)) item = itemsuivi_get(cnx, itemsuivi_id) - if format == "json": + if fmt == "json": return scu.sendJSON(item) return item @@ -320,13 +320,13 @@ def itemsuivi_set_situation(object, value): return situation or scu.IT_SITUATION_MISSING_STR -def itemsuivi_list_etud(etudid, format=None): +def itemsuivi_list_etud(etudid, fmt=None): """Liste des items pour cet étudiant, avec tags""" cnx = ndb.GetDBConnexion() items = _itemsuivi_list(cnx, {"etudid": etudid}) for it in items: it["tags"] = ", ".join(itemsuivi_tag_list(it["itemsuivi_id"])) - if format == "json": + if fmt == "json": return scu.sendJSON(items) return items diff --git a/app/scodoc/sco_edit_ue.py b/app/scodoc/sco_edit_ue.py index 39360d5f8a..80047fcd66 100644 --- a/app/scodoc/sco_edit_ue.py +++ b/app/scodoc/sco_edit_ue.py @@ -979,18 +979,18 @@ du programme" (menu "Semestre") si vous avez un semestre en cours);
  • Export XML de la formation ou sans codes Apogée (permet de l'enregistrer pour l'échanger avec un autre site)
  • Export JSON de la formation
  • diff --git a/app/scodoc/sco_etape_apogee_view.py b/app/scodoc/sco_etape_apogee_view.py index c5ae128e8a..8f11532b84 100644 --- a/app/scodoc/sco_etape_apogee_view.py +++ b/app/scodoc/sco_etape_apogee_view.py @@ -495,7 +495,7 @@ def table_apo_csv_list(semset): return tab -def view_apo_etuds(semset_id, title="", nip_list="", format="html"): +def view_apo_etuds(semset_id, title="", nip_list="", fmt="html"): """Table des étudiants Apogée par nips nip_list est une chaine, codes nip séparés par des , """ @@ -530,11 +530,11 @@ def view_apo_etuds(semset_id, title="", nip_list="", format="html"): title=title, etuds=list(etuds.values()), keys=("nip", "etape_apo", "nom", "prenom", "inscriptions_scodoc"), - format=format, + fmt=fmt, ) -def view_scodoc_etuds(semset_id, title="", nip_list="", format="html"): +def view_scodoc_etuds(semset_id, title="", nip_list="", fmt="html"): """Table des étudiants ScoDoc par nips ou etudids""" if not isinstance(nip_list, str): nip_list = str(nip_list) @@ -553,12 +553,12 @@ def view_scodoc_etuds(semset_id, title="", nip_list="", format="html"): title=title, etuds=etuds, keys=("code_nip", "nom", "prenom"), - format=format, + fmt=fmt, ) def _view_etuds_page( - semset_id: int, title="", etuds: list = None, keys=(), format="html" + semset_id: int, title="", etuds: list = None, keys=(), fmt="html" ) -> str: "Affiche les étudiants indiqués" # Tri les étudiants par nom: @@ -581,8 +581,8 @@ def _view_etuds_page( filename="students_apo", preferences=sco_preferences.SemPreferences(), ) - if format != "html": - return tab.make_page(format=format) + if fmt != "html": + return tab.make_page(fmt=fmt) return f""" {html_sco_header.sco_header( @@ -711,9 +711,9 @@ def view_apo_csv_delete(etape_apo="", semset_id="", dialog_confirmed=False): return flask.redirect(dest_url) -def view_apo_csv(etape_apo="", semset_id="", format="html"): +def view_apo_csv(etape_apo="", semset_id="", fmt="html"): """Visualise une maquette stockée - Si format="raw", renvoie le fichier maquette tel quel + Si fmt="raw", renvoie le fichier maquette tel quel """ if not semset_id: raise ValueError("invalid null semset_id") @@ -721,7 +721,7 @@ def view_apo_csv(etape_apo="", semset_id="", format="html"): annee_scolaire = semset["annee_scolaire"] sem_id = semset["sem_id"] csv_data = sco_etape_apogee.apo_csv_get(etape_apo, annee_scolaire, sem_id) - if format == "raw": + if fmt == "raw": return scu.send_file(csv_data, etape_apo, suffix=".txt", mime=scu.CSV_MIMETYPE) apo_data = sco_apogee_csv.ApoData(csv_data, periode=semset["sem_id"]) @@ -798,8 +798,8 @@ def view_apo_csv(etape_apo="", semset_id="", format="html"): preferences=sco_preferences.SemPreferences(), ) - if format != "html": - return tab.make_page(format=format) + if fmt != "html": + return tab.make_page(fmt=fmt) H += [ f""" @@ -807,7 +807,7 @@ def view_apo_csv(etape_apo="", semset_id="", format="html"):

    fichier maquette CSV brut (non rempli par ScoDoc)

    diff --git a/app/scodoc/sco_etape_bilan.py b/app/scodoc/sco_etape_bilan.py index ec1a8c8bfb..07c57b05b4 100644 --- a/app/scodoc/sco_etape_bilan.py +++ b/app/scodoc/sco_etape_bilan.py @@ -668,7 +668,7 @@ class EtapeBilan: self.titres, html_class="repartition", html_with_td_classes=True, - ).gen(format="html") + ).gen(fmt="html") ) return "\n".join(H) @@ -766,7 +766,7 @@ class EtapeBilan: table_id="detail", html_class="table_leftalign", html_sortable=True, - ).gen(format="html") + ).gen(fmt="html") ) return "\n".join(H) diff --git a/app/scodoc/sco_evaluations.py b/app/scodoc/sco_evaluations.py index 433f0d445c..7c5ffd4743 100644 --- a/app/scodoc/sco_evaluations.py +++ b/app/scodoc/sco_evaluations.py @@ -561,7 +561,7 @@ def evaluation_date_first_completion(evaluation_id) -> datetime.datetime: return max(date_premiere_note.values()) -def formsemestre_evaluations_delai_correction(formsemestre_id, format="html"): +def formsemestre_evaluations_delai_correction(formsemestre_id, fmt="html"): """Experimental: un tableau indiquant pour chaque évaluation le nombre de jours avant la publication des notes. @@ -638,7 +638,7 @@ def formsemestre_evaluations_delai_correction(formsemestre_id, format="html"): origin=f"""Généré par {sco_version.SCONAME} le {scu.timedate_human_repr()}""", filename=scu.make_filename("evaluations_delais_" + formsemestre.titre_annee()), ) - return tab.make_page(format=format) + return tab.make_page(fmt=fmt) # -------------- VIEWS diff --git a/app/scodoc/sco_export_results.py b/app/scodoc/sco_export_results.py index 01c6c53622..9a4cee6436 100644 --- a/app/scodoc/sco_export_results.py +++ b/app/scodoc/sco_export_results.py @@ -220,7 +220,7 @@ def get_set_formsemestre_id_dates(start_date, end_date) -> set: def scodoc_table_results( - start_date="", end_date="", types_parcours: list = None, format="html" + start_date="", end_date="", types_parcours: list = None, fmt="html" ): """Page affichant la table des résultats Les dates sont en dd/mm/yyyy (datepicker javascript) @@ -248,8 +248,8 @@ def scodoc_table_results( end_date, "&types_parcours=".join([str(x) for x in types_parcours]), ) - if format != "html": - return tab.make_page(format=format, with_html_headers=False) + if fmt != "html": + return tab.make_page(fmt=fmt, with_html_headers=False) tab_html = tab.html() nb_rows = tab.get_nb_rows() else: diff --git a/app/scodoc/sco_find_etud.py b/app/scodoc/sco_find_etud.py index d3fa462eca..8601586f65 100644 --- a/app/scodoc/sco_find_etud.py +++ b/app/scodoc/sco_find_etud.py @@ -366,7 +366,7 @@ def table_etud_in_accessible_depts(expnom=None): ) -def search_inscr_etud_by_nip(code_nip, format="json"): +def search_inscr_etud_by_nip(code_nip, fmt="json"): """Recherche multi-departement d'un étudiant par son code NIP Seuls les départements accessibles par l'utilisateur sont cherchés. @@ -408,4 +408,4 @@ def search_inscr_etud_by_nip(code_nip, format="json"): ) tab = GenTable(columns_ids=columns_ids, rows=T) - return tab.make_page(format=format, with_html_headers=False, publish=True) + return tab.make_page(fmt=fmt, with_html_headers=False, publish=True) diff --git a/app/scodoc/sco_formation_recap.py b/app/scodoc/sco_formation_recap.py index 7717e4f916..02c2578d36 100644 --- a/app/scodoc/sco_formation_recap.py +++ b/app/scodoc/sco_formation_recap.py @@ -45,7 +45,7 @@ import app.scodoc.sco_utils as scu # ---- Table recap formation -def formation_table_recap(formation_id, format="html") -> Response: +def formation_table_recap(formation_id, fmt="html") -> Response: """Table recapitulant formation.""" T = [] formation = Formation.query.get_or_404(formation_id) @@ -162,7 +162,7 @@ def formation_table_recap(formation_id, format="html") -> Response: preferences=sco_preferences.SemPreferences(), table_id="formation_table_recap", ) - return tab.make_page(format=format, javascripts=["js/formation_recap.js"]) + return tab.make_page(fmt=fmt, javascripts=["js/formation_recap.js"]) def export_recap_formations_annee_scolaire(annee_scolaire): @@ -179,7 +179,7 @@ def export_recap_formations_annee_scolaire(annee_scolaire): formation_ids = {formsemestre.formation.id for formsemestre in formsemestres} for formation_id in formation_ids: formation = db.session.get(Formation, formation_id) - xls = formation_table_recap(formation_id, format="xlsx").data + xls = formation_table_recap(formation_id, fmt="xlsx").data filename = ( scu.sanitize_filename(formation.get_titre_version()) + scu.XLSX_SUFFIX ) diff --git a/app/scodoc/sco_formations.py b/app/scodoc/sco_formations.py index d0c8b6884a..c58a81d23c 100644 --- a/app/scodoc/sco_formations.py +++ b/app/scodoc/sco_formations.py @@ -212,7 +212,7 @@ def formation_export( export_tags=True, export_external_ues=False, export_codes_apo=True, - format=None, + fmt=None, ) -> flask.Response: """Get a formation, with UE, matieres, modules in desired format @@ -224,13 +224,13 @@ def formation_export( export_tags=export_tags, export_external_ues=export_external_ues, export_codes_apo=export_codes_apo, - ac_as_list=format == "xml", + ac_as_list=fmt == "xml", ) filename = f"scodoc_formation_{formation.departement.acronym}_{formation.acronyme or ''}_v{formation.version}" return scu.sendResult( f_dict, name="formation", - format=format, + fmt=fmt, force_outer_xml_tag=False, attached=True, filename=filename, @@ -283,7 +283,7 @@ def _formation_retreive_apc_niveau( def formation_import_xml(doc: str, import_tags=True, use_local_refcomp=False): """Create a formation from XML representation - (format dumped by formation_export( format='xml' )) + (format dumped by formation_export( fmt='xml' )) XML may contain object (UE, modules) ids: this function returns two dicts mapping these ids to the created ids. @@ -627,7 +627,7 @@ def formation_create_new_version(formation_id, redirect=True): "duplicate formation, with new version number" formation = Formation.query.get_or_404(formation_id) resp = formation_export( - formation_id, export_ids=True, export_external_ues=True, format="xml" + formation_id, export_ids=True, export_external_ues=True, fmt="xml" ) xml_data = resp.get_data(as_text=True) new_id, modules_old2new, ues_old2new = formation_import_xml( diff --git a/app/scodoc/sco_formsemestre.py b/app/scodoc/sco_formsemestre.py index 40a34a2aeb..8c77ed6a35 100644 --- a/app/scodoc/sco_formsemestre.py +++ b/app/scodoc/sco_formsemestre.py @@ -559,7 +559,7 @@ def list_formsemestre_by_etape(etape_apo=False, annee_scolaire=False) -> list[di return sems -def view_formsemestre_by_etape(etape_apo=None, format="html"): +def view_formsemestre_by_etape(etape_apo=None, fmt="html"): """Affiche table des semestres correspondants à l'étape""" if etape_apo: html_title = f"""

    Semestres courants de l'étape {etape_apo}

    """ @@ -575,7 +575,7 @@ def view_formsemestre_by_etape(etape_apo=None, format="html"): """, ) tab.base_url = "%s?etape_apo=%s" % (request.base_url, etape_apo or "") - return tab.make_page(format=format) + return tab.make_page(fmt=fmt) def sem_has_etape(sem, code_etape): diff --git a/app/scodoc/sco_formsemestre_status.py b/app/scodoc/sco_formsemestre_status.py index 0f018d47b3..1b46a0484e 100755 --- a/app/scodoc/sco_formsemestre_status.py +++ b/app/scodoc/sco_formsemestre_status.py @@ -325,7 +325,7 @@ def formsemestre_status_menubar(formsemestre: FormSemestre) -> str: "title": "Exporter table des étudiants", "endpoint": "scolar.groups_view", "args": { - "format": "allxls", + "fmt": "allxls", "group_ids": sco_groups.get_default_group( formsemestre_id, fix_if_missing=True ), @@ -787,7 +787,7 @@ def formsemestre_description_table( def formsemestre_description( - formsemestre_id, format="html", with_evals=False, with_parcours=False + formsemestre_id, fmt="html", with_evals=False, with_parcours=False ): """Description du semestre sous forme de table exportable Liste des modules et de leurs coefficients @@ -807,7 +807,7 @@ def formsemestre_description( >indiquer les parcours BUT """ - return tab.make_page(format=format) + return tab.make_page(fmt=fmt) # genere liste html pour accès aux groupes de ce semestre diff --git a/app/scodoc/sco_groups.py b/app/scodoc/sco_groups.py index 8511ca692e..6a4d77e841 100644 --- a/app/scodoc/sco_groups.py +++ b/app/scodoc/sco_groups.py @@ -516,7 +516,7 @@ def get_etud_groups_in_partition(partition_id): return R -def formsemestre_partition_list(formsemestre_id, format="xml"): +def formsemestre_partition_list(formsemestre_id, fmt="xml"): """Get partitions and groups in this semestre Supported formats: xml, json """ @@ -524,7 +524,7 @@ def formsemestre_partition_list(formsemestre_id, format="xml"): # Ajoute les groupes for p in partitions: p["group"] = get_partition_groups(p) - return scu.sendResult(partitions, name="partition", format=format) + return scu.sendResult(partitions, name="partition", fmt=fmt) # Encore utilisé par groupmgr.js diff --git a/app/scodoc/sco_groups_exports.py b/app/scodoc/sco_groups_exports.py index d6f63ea071..232f4cc3c6 100644 --- a/app/scodoc/sco_groups_exports.py +++ b/app/scodoc/sco_groups_exports.py @@ -60,7 +60,7 @@ def groups_list_annotation(group_ids: list[int]) -> list[dict]: return annotations -def groups_export_annotations(group_ids, formsemestre_id=None, format="html"): +def groups_export_annotations(group_ids, formsemestre_id=None, fmt="html"): """Les annotations""" groups_infos = sco_groups_view.DisplayedGroupsInfos( group_ids, formsemestre_id=formsemestre_id @@ -68,7 +68,7 @@ def groups_export_annotations(group_ids, formsemestre_id=None, format="html"): annotations = groups_list_annotation(groups_infos.group_ids) for annotation in annotations: annotation["date_str"] = annotation["date"].strftime("%d/%m/%Y à %Hh%M") - if format == "xls": + if fmt == "xls": columns_ids = ("etudid", "nom", "prenom", "date", "comment") else: columns_ids = ("etudid", "nom", "prenom", "date_str", "comment") @@ -93,4 +93,4 @@ def groups_export_annotations(group_ids, formsemestre_id=None, format="html"): html_class="table_leftalign", preferences=sco_preferences.SemPreferences(formsemestre_id), ) - return table.make_page(format=format) + return table.make_page(fmt=fmt) diff --git a/app/scodoc/sco_groups_view.py b/app/scodoc/sco_groups_view.py index 794c4ba3d3..835207735f 100644 --- a/app/scodoc/sco_groups_view.py +++ b/app/scodoc/sco_groups_view.py @@ -70,7 +70,7 @@ CSSSTYLES = html_sco_header.BOOTSTRAP_MULTISELECT_CSS # view: def groups_view( group_ids=(), - format="html", + fmt="html", # Options pour listes: with_codes=0, etat=None, @@ -82,7 +82,7 @@ def groups_view( ): """Affichage des étudiants des groupes indiqués group_ids: liste de group_id - format: csv, json, xml, xls, allxls, xlsappel, moodlecsv, pdf + fmt: csv, json, xml, xls, allxls, xlsappel, moodlecsv, pdf """ # Informations sur les groupes à afficher: groups_infos = DisplayedGroupsInfos( @@ -92,10 +92,10 @@ def groups_view( select_all_when_unspecified=True, ) # Formats spéciaux: download direct - if format != "html": + if fmt != "html": return groups_table( groups_infos=groups_infos, - format=format, + fmt=fmt, with_codes=with_codes, etat=etat, with_paiement=with_paiement, @@ -135,7 +135,7 @@ def groups_view( """, groups_table( groups_infos=groups_infos, - format=format, + fmt=fmt, with_codes=with_codes, etat=etat, with_paiement=with_paiement, @@ -437,14 +437,14 @@ def groups_table( groups_infos: DisplayedGroupsInfos = None, with_codes=0, etat=None, - format="html", + fmt="html", with_paiement=0, # si vrai, ajoute colonnes infos paiement droits et finalisation inscription (lent car interrogation portail) with_archives=0, # ajoute colonne avec noms fichiers archivés with_annotations=0, with_bourse=0, ): """liste etudiants inscrits dans ce semestre - format: csv, json, xml, xls, allxls, xlsappel, moodlecsv, pdf + fmt: csv, json, xml, xls, allxls, xlsappel, moodlecsv, pdf Si with_codes, ajoute 4 colonnes avec les codes etudid, NIP, INE et etape """ from app.scodoc import sco_report @@ -499,12 +499,12 @@ def groups_table( p["partition_id"]: p["partition_name"] for p in groups_infos.partitions } - if format != "html": # ne mentionne l'état que en Excel (style en html) + if fmt != "html": # ne mentionne l'état que en Excel (style en html) columns_ids.append("etat") columns_ids.append("email") columns_ids.append("emailperso") - if format == "moodlecsv": + if fmt == "moodlecsv": columns_ids = ["email", "semestre_groupe"] if with_codes: @@ -579,7 +579,7 @@ def groups_table( else: s = "" - if format == "moodlecsv": + if fmt == "moodlecsv": # de la forme S1-[FI][FA]-groupe.csv if not moodle_groupenames: moodle_groupenames = {"tous"} @@ -612,7 +612,7 @@ def groups_table( preferences=prefs, ) # - if format == "html": + if fmt == "html": amail_inst = [ x["email"] for x in groups_infos.members if x["email"] and x["etat"] != "D" ] @@ -683,11 +683,11 @@ def groups_table( [ tab.html(), "
    " elif ( - format == "pdf" - or format == "xml" - or format == "json" - or format == "xls" - or format == "moodlecsv" + fmt == "pdf" + or fmt == "xml" + or fmt == "json" + or fmt == "xls" + or fmt == "moodlecsv" ): - if format == "moodlecsv": - format = "csv" - return tab.make_page(format=format) + if fmt == "moodlecsv": + fmt = "csv" + return tab.make_page(fmt=fmt) - elif format == "xlsappel": + elif fmt == "xlsappel": xls = sco_excel.excel_feuille_listeappel( groups_infos.formsemestre, groups_infos.groups_titles, @@ -745,7 +745,7 @@ def groups_table( ) filename = "liste_%s" % groups_infos.groups_filename return scu.send_file(xls, filename, scu.XLSX_SUFFIX, scu.XLSX_MIMETYPE) - elif format == "allxls": + elif fmt == "allxls": # feuille Excel avec toutes les infos etudiants if not groups_infos.members: return "" @@ -834,20 +834,24 @@ def tab_absences_html(groups_infos, etat=None): form_choix_jour_saisie_hebdo(groups_infos), "", f"""
  • État de l'assiduité du groupe
  • """, "", "

    Feuilles

    ", '
      ', - """
    • Feuille d'émargement %s (Excel)
    • """ + """
    • Feuille d'émargement %s (Excel)
    • """ % (groups_infos.base_url, groups_infos.groups_titles), - """
    • Trombinoscope en PDF
    • """ + """
    • Trombinoscope en PDF
    • """ % groups_infos.groups_query_args, - """
    • Trombinoscope en PDF (format "IUT de Tours", beta)
    • """ + """
    • Trombinoscope en PDF (format "IUT de Tours", beta)
    • """ % groups_infos.groups_query_args, - """
    • Feuille relevé absences hebdomadaire (beta)
    • """ + """
    • Feuille relevé absences hebdomadaire (beta)
    • """ % groups_infos.groups_query_args, - """
    • Liste d'appel avec photos
    • """ + """
    • Liste d'appel avec photos
    • """ % groups_infos.groups_query_args, """
    • Liste des annotations
    • """ % groups_infos.groups_query_args, @@ -966,4 +970,4 @@ def export_groups_as_moodle_csv(formsemestre_id=None): text_with_titles=prefs["moodle_csv_with_headerline"], preferences=prefs, ) - return tab.make_page(format="csv") + return tab.make_page(fmt="csv") diff --git a/app/scodoc/sco_liste_notes.py b/app/scodoc/sco_liste_notes.py index 00818e54d1..6ac88dc51c 100644 --- a/app/scodoc/sco_liste_notes.py +++ b/app/scodoc/sco_liste_notes.py @@ -60,7 +60,7 @@ from app.scodoc.htmlutils import histogram_notes def do_evaluation_listenotes( - evaluation_id=None, moduleimpl_id=None, format="html" + evaluation_id=None, moduleimpl_id=None, fmt="html" ) -> tuple[str, str]: """ Affichage des notes d'une évaluation (si evaluation_id) @@ -220,7 +220,7 @@ def do_evaluation_listenotes( _make_table_notes( tf[1], evals, - fmt=format, + fmt=fmt, note_sur_20=note_sur_20, anonymous_listing=anonymous_listing, group_ids=group_ids, @@ -424,7 +424,7 @@ def _make_table_notes( key_mgr, note_sur_20, keep_numeric, - format=fmt, + fmt=fmt, ) columns_ids.append(e["evaluation_id"]) # @@ -596,7 +596,7 @@ def _make_table_notes( ) if fmt == "bordereau": fmt = "pdf" - t = tab.make_page(format=fmt, with_html_headers=False) + t = tab.make_page(fmt=fmt, with_html_headers=False) if fmt != "html": return t @@ -622,7 +622,7 @@ def _make_table_notes( histo = histogram_notes(notes) # 2 colonnes: histo, comments C = [ - f'
      Bordereau de Signatures (version PDF)', + f'
      Bordereau de Signatures (version PDF)', "\n", @@ -670,7 +670,7 @@ def _add_eval_columns( K, note_sur_20, keep_numeric, - format="html", + fmt="html", ): """Add eval e""" nb_notes = 0 @@ -774,7 +774,7 @@ def _add_eval_columns( row_coefs[evaluation_id] = "coef. %s" % e["coefficient"] if is_apc: - if format == "html": + if fmt == "html": row_poids[evaluation_id] = _mini_table_eval_ue_poids( evaluation_id, evals_poids, ues ) diff --git a/app/scodoc/sco_lycee.py b/app/scodoc/sco_lycee.py index 4d9cf02fe3..d3585cd1cf 100644 --- a/app/scodoc/sco_lycee.py +++ b/app/scodoc/sco_lycee.py @@ -63,7 +63,7 @@ def formsemestre_table_etuds_lycees( ) -def scodoc_table_etuds_lycees(format="html"): +def scodoc_table_etuds_lycees(fmt="html"): """Table avec _tous_ les étudiants des semestres non verrouillés de _tous_ les départements. """ @@ -71,7 +71,7 @@ def scodoc_table_etuds_lycees(format="html"): semdepts = sco_formsemestre.scodoc_get_all_unlocked_sems() etuds = [] try: - for (sem, dept) in semdepts: + for sem, dept in semdepts: app.set_sco_dept(dept.acronym) etuds += sco_report.tsp_etud_list(sem["formsemestre_id"])[0] finally: @@ -85,8 +85,8 @@ def scodoc_table_etuds_lycees(format="html"): no_links=True, ) tab.base_url = request.base_url - t = tab.make_page(format=format, with_html_headers=False) - if format != "html": + t = tab.make_page(fmt=fmt, with_html_headers=False) + if fmt != "html": return t H = [ html_sco_header.sco_header( @@ -178,7 +178,7 @@ def _table_etuds_lycees(etuds, group_lycees, title, preferences, no_links=False) def formsemestre_etuds_lycees( formsemestre_id, - format="html", + fmt="html", only_primo=False, no_grouping=False, ): @@ -191,14 +191,10 @@ def formsemestre_etuds_lycees( tab.base_url += "&only_primo=1" if no_grouping: tab.base_url += "&no_grouping=1" - t = tab.make_page(format=format, with_html_headers=False) - if format != "html": + t = tab.make_page(fmt=fmt, with_html_headers=False) + if fmt != "html": return t - F = [ - sco_report.tsp_form_primo_group( - only_primo, no_grouping, formsemestre_id, format - ) - ] + F = [sco_report.tsp_form_primo_group(only_primo, no_grouping, formsemestre_id, fmt)] H = [ html_sco_header.sco_header( page_title=tab.page_title, diff --git a/app/scodoc/sco_placement.py b/app/scodoc/sco_placement.py index 3bc9c2a619..d0cc4ca1b6 100644 --- a/app/scodoc/sco_placement.py +++ b/app/scodoc/sco_placement.py @@ -383,7 +383,7 @@ class PlacementRunner: self.moduleimpl_data["formsemestre_id"] ), ) - return tab.make_page(format="pdf", with_html_headers=False) + return tab.make_page(fmt="pdf", with_html_headers=False) def _one_header(self, worksheet): cells = [ diff --git a/app/scodoc/sco_poursuite_dut.py b/app/scodoc/sco_poursuite_dut.py index 77c631e4ef..428f60aec6 100644 --- a/app/scodoc/sco_poursuite_dut.py +++ b/app/scodoc/sco_poursuite_dut.py @@ -178,7 +178,7 @@ def _getEtudInfoGroupes(group_ids, etat=None): return etuds -def formsemestre_poursuite_report(formsemestre_id, format="html"): +def formsemestre_poursuite_report(formsemestre_id, fmt="html"): """Table avec informations "poursuite" """ sem = sco_formsemestre.get_formsemestre(formsemestre_id) etuds = _getEtudInfoGroupes([sco_groups.get_default_group(formsemestre_id)]) @@ -230,6 +230,6 @@ def formsemestre_poursuite_report(formsemestre_id, format="html"): title="""

      Poursuite d'études

      """, init_qtip=True, javascripts=["js/etud_info.js"], - format=format, + fmt=fmt, with_html_headers=True, ) diff --git a/app/scodoc/sco_pv_forms.py b/app/scodoc/sco_pv_forms.py index 5b7be89e2b..014a84228f 100644 --- a/app/scodoc/sco_pv_forms.py +++ b/app/scodoc/sco_pv_forms.py @@ -206,14 +206,14 @@ def pvjury_table( return lines, titles, columns_ids -def formsemestre_pvjury(formsemestre_id, format="html", publish=True): +def formsemestre_pvjury(formsemestre_id, fmt="html", publish=True): """Page récapitulant les décisions de jury En classique: table spécifique avec les deux semestres pour le DUT En APC/BUT: renvoie vers table recap, en mode jury. """ formsemestre = FormSemestre.get_formsemestre(formsemestre_id) is_apc = formsemestre.formation.is_apc() - if format == "html" and is_apc: + if fmt == "html" and is_apc: return redirect( url_for( "notes.formsemestre_recapcomplet", @@ -227,7 +227,7 @@ def formsemestre_pvjury(formsemestre_id, format="html", publish=True): dpv = sco_pv_dict.dict_pvjury(formsemestre_id, with_prev=True) if not dpv: - if format == "html": + if fmt == "html": return ( html_sco_header.sco_header() + "

      Aucune information disponible !

      " @@ -239,7 +239,7 @@ def formsemestre_pvjury(formsemestre_id, format="html", publish=True): formsemestre_id = sem["formsemestre_id"] rows, titles, columns_ids = pvjury_table(dpv) - if format != "html" and format != "pdf": + if fmt != "html" and fmt != "pdf": columns_ids = ["etudid", "code_nip"] + columns_ids tab = GenTable( @@ -255,9 +255,9 @@ def formsemestre_pvjury(formsemestre_id, format="html", publish=True): html_sortable=True, preferences=sco_preferences.SemPreferences(formsemestre_id), ) - if format != "html": + if fmt != "html": return tab.make_page( - format=format, + fmt=fmt, with_html_headers=False, publish=publish, ) diff --git a/app/scodoc/sco_report.py b/app/scodoc/sco_report.py index 70bc7afe5b..a558bce129 100644 --- a/app/scodoc/sco_report.py +++ b/app/scodoc/sco_report.py @@ -205,7 +205,7 @@ def _results_by_category( bottom_titles["row_title"] = "Total" # ajout titre ligne: - for (cat, l) in zip(categories, C): + for cat, l in zip(categories, C): l["row_title"] = cat if cat is not None else "?" # @@ -274,7 +274,7 @@ def formsemestre_report( return tab -# def formsemestre_report_bacs(formsemestre_id, format='html'): +# def formsemestre_report_bacs(formsemestre_id, fmt='html'): # """ # Tableau sur résultats par type de bac # """ @@ -287,12 +287,12 @@ def formsemestre_report( # title=title) # return tab.make_page( # title = """

      Résultats de %(titreannee)s

      """ % sem, -# format=format, page_title = title) +# fmt=fmt, page_title = title) def formsemestre_report_counts( formsemestre_id: int, - format="html", + fmt="html", category: str = "bac", result: str = None, allkeys: bool = False, @@ -397,10 +397,10 @@ def formsemestre_report_counts( t = tab.make_page( title="""

      Comptes croisés

      """, - format=format, + fmt=fmt, with_html_headers=False, ) - if format != "html": + if fmt != "html": return t H = [ html_sco_header.sco_header(page_title=title), @@ -734,7 +734,7 @@ def table_suivi_cohorte( def formsemestre_suivi_cohorte( formsemestre_id, - format="html", + fmt="html", percent=1, bac="", bacspecialite="", @@ -774,8 +774,8 @@ def formsemestre_suivi_cohorte( ) if only_primo: tab.base_url += "&only_primo=on" - t = tab.make_page(format=format, with_html_headers=False) - if format != "html": + t = tab.make_page(fmt=fmt, with_html_headers=False) + if fmt != "html": return t base_url = request.base_url @@ -1246,7 +1246,7 @@ def table_suivi_cursus(formsemestre_id, only_primo=False, grouped_parcours=True) return tab -def tsp_form_primo_group(only_primo, no_grouping, formsemestre_id, format): +def tsp_form_primo_group(only_primo, no_grouping, formsemestre_id, fmt): """Element de formulaire pour choisir si restriction aux primos entrants et groupement par lycees""" F = ["""""" % request.base_url] if only_primo: @@ -1268,14 +1268,14 @@ def tsp_form_primo_group(only_primo, no_grouping, formsemestre_id, format): F.append( '' % formsemestre_id ) - F.append('' % format) + F.append('' % fmt) F.append("""""") return "\n".join(F) def formsemestre_suivi_cursus( formsemestre_id, - format="html", + fmt="html", only_primo=False, no_grouping=False, ): @@ -1290,10 +1290,10 @@ def formsemestre_suivi_cursus( tab.base_url += "&only_primo=1" if no_grouping: tab.base_url += "&no_grouping=1" - t = tab.make_page(format=format, with_html_headers=False) - if format != "html": + t = tab.make_page(fmt=fmt, with_html_headers=False) + if fmt != "html": return t - F = [tsp_form_primo_group(only_primo, no_grouping, formsemestre_id, format)] + F = [tsp_form_primo_group(only_primo, no_grouping, formsemestre_id, fmt)] H = [ html_sco_header.sco_header( @@ -1312,7 +1312,7 @@ def formsemestre_suivi_cursus( # ------------- def graph_cursus( formsemestre_id, - format="svg", + fmt="svg", only_primo=False, bac="", # selection sur type de bac bacspecialite="", @@ -1437,7 +1437,7 @@ def graph_cursus( g.add_node(n) g.set("rankdir", "LR") # left to right g.set_fontname("Helvetica") - if format == "svg": + if fmt == "svg": g.set_bgcolor("#fffff0") # ou 'transparent' # titres des semestres: for s in sems.values(): @@ -1489,7 +1489,7 @@ def graph_cursus( n.set("label", "Diplome") # bug si accent (pas compris pourquoi) # Arètes: bubbles = {} # substitue titres pour bulle aides: src_id:dst_id : etud_descr - for (src_id, dst_id) in edges.keys(): + for src_id, dst_id in edges.keys(): e = g.get_edge(src_id, dst_id)[0] e.set("arrowhead", "normal") e.set("arrowsize", 1) @@ -1503,20 +1503,19 @@ def graph_cursus( e.set_URL(f"__xxxetudlist__?{src_id}:{dst_id}") # Genere graphe _, path = tempfile.mkstemp(".gr") - g.write(path=path, format=format) + g.write(path=path, format=fmt) with open(path, "rb") as f: data = f.read() - log("dot generated %d bytes in %s format" % (len(data), format)) + log("dot generated %d bytes in %s format" % (len(data), fmt)) if not data: log("graph.to_string=%s" % g.to_string()) - raise ValueError( - "Erreur lors de la génération du document au format %s" % format - ) + raise ValueError("Erreur lors de la génération du document au format %s" % fmt) os.unlink(path) - if format == "svg": + if fmt == "svg": # dot génère un document XML complet, il faut enlever l'en-tête data_str = data.decode("utf-8") data = "Origine et devenir des étudiants inscrits dans %(titreannee)s""" % sem, """(version pdf""" - % url_for("notes.formsemestre_graph_cursus", format="pdf", **url_kw), + % url_for("notes.formsemestre_graph_cursus", fmt="pdf", **url_kw), """, image PNG)""" - % url_for("notes.formsemestre_graph_cursus", format="png", **url_kw), - """

      """, - """

      Le graphe permet de suivre les étudiants inscrits dans le semestre + % url_for("notes.formsemestre_graph_cursus", fmt="png", **url_kw), + f""" +

      +

      Le graphe permet de suivre les étudiants inscrits dans le semestre sélectionné (dessiné en vert). Chaque rectangle représente un semestre (cliquez dedans - pour afficher son tableau de bord). Les flèches indiquent le nombre d'étudiants passant - d'un semestre à l'autre (s'il y en a moins de %s, vous pouvez visualiser leurs noms en - passant la souris sur le chiffre). -

      """ - % MAX_ETUD_IN_DESCR, + pour afficher son tableau de bord). Les flèches indiquent le nombre d'étudiants + passant d'un semestre à l'autre (s'il y en a moins de {MAX_ETUD_IN_DESCR}, vous + pouvez visualiser leurs noms en passant le curseur sur le chiffre). +

      + """, html_sco_header.sco_footer(), ] return "\n".join(H) else: - raise ValueError("invalid format: %s" % format) + raise ValueError(f"invalid format: {fmt}") diff --git a/app/scodoc/sco_report_but.py b/app/scodoc/sco_report_but.py index 5cfaa99e58..cb216d4eb2 100644 --- a/app/scodoc/sco_report_but.py +++ b/app/scodoc/sco_report_but.py @@ -67,7 +67,7 @@ INDICATEUR_NAMES = { } -def formsemestre_but_indicateurs(formsemestre_id: int, format="html"): +def formsemestre_but_indicateurs(formsemestre_id: int, fmt="html"): """Page avec tableau indicateurs enquête ADIUT BUT 2022""" formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id) @@ -100,10 +100,10 @@ def formsemestre_but_indicateurs(formsemestre_id: int, format="html"): title = "Indicateurs suivi annuel BUT" t = tab.make_page( title=f"""

      {title}

      """, - format=format, + fmt=fmt, with_html_headers=False, ) - if format != "html": + if fmt != "html": return t H = [ html_sco_header.sco_header(page_title=title), diff --git a/app/scodoc/sco_semset.py b/app/scodoc/sco_semset.py index c1ed85c5ef..34f940fc4e 100644 --- a/app/scodoc/sco_semset.py +++ b/app/scodoc/sco_semset.py @@ -465,7 +465,7 @@ def do_semset_remove_sem(semset_id, formsemestre_id): # ---------------------------------------- -def semset_page(format="html"): +def semset_page(fmt="html"): """Page avec liste semsets: Table avec : date_debut date_fin titre liste des semestres """ @@ -514,8 +514,8 @@ def semset_page(format="html"): filename="semsets", preferences=sco_preferences.SemPreferences(), ) - if format != "html": - return tab.make_page(format=format) + if fmt != "html": + return tab.make_page(fmt=fmt) page_title = "Ensembles de semestres" H = [ diff --git a/app/scodoc/sco_trombino.py b/app/scodoc/sco_trombino.py index b2203ba97d..396df98ecd 100644 --- a/app/scodoc/sco_trombino.py +++ b/app/scodoc/sco_trombino.py @@ -66,7 +66,7 @@ def trombino( group_ids=(), # liste des groupes à afficher formsemestre_id=None, # utilisé si pas de groupes selectionné etat=None, - format="html", + fmt="html", dialog_confirmed=False, ): """Trombinoscope""" @@ -78,18 +78,18 @@ def trombino( ) # - if format != "html" and not dialog_confirmed: - ok, dialog = check_local_photos_availability(groups_infos, fmt=format) + if fmt != "html" and not dialog_confirmed: + ok, dialog = check_local_photos_availability(groups_infos, fmt=fmt) if not ok: return dialog - if format == "zip": + if fmt == "zip": return _trombino_zip(groups_infos) - elif format == "pdf": + elif fmt == "pdf": return _trombino_pdf(groups_infos) - elif format == "pdflist": + elif fmt == "pdflist": return _listeappel_photos_pdf(groups_infos) - elif format == "doc": + elif fmt == "doc": return sco_trombino_doc.trombino_doc(groups_infos) else: raise Exception("invalid format") @@ -110,7 +110,7 @@ def trombino_html(groups_infos): { "title": "Obtenir archive Zip des photos", "endpoint": "scolar.trombino", - "args": {"group_ids": groups_infos.group_ids, "format": "zip"}, + "args": {"group_ids": groups_infos.group_ids, "fmt": "zip"}, }, { "title": "Recopier les photos depuis le portail", @@ -176,10 +176,10 @@ def trombino_html(groups_infos): H.append( f"""
      Version PDF + fmt='pdf', group_ids=groups_infos.group_ids)}">Version PDF    Version doc + fmt='doc', group_ids=groups_infos.group_ids)}">Version doc
      """ ) return "\n".join(H) @@ -198,14 +198,14 @@ def check_local_photos_availability(groups_infos, fmt=""): if not sco_photos.etud_photo_is_local(t["photo_filename"]): nb_missing += 1 if nb_missing > 0: - parameters = {"group_ids": groups_infos.group_ids, "format": fmt} + parameters = {"group_ids": groups_infos.group_ids, "fmt": fmt} return ( False, scu.confirm_dialog( f"""

      Attention: {nb_missing} photos ne sont pas disponibles et ne peuvent pas être exportées.

      Vous pouvez exporter seulement les photos existantes""", dest_url="trombino", OK="Exporter seulement les photos existantes", diff --git a/app/scodoc/sco_undo_notes.py b/app/scodoc/sco_undo_notes.py index faaf1f519f..61b84c0c4a 100644 --- a/app/scodoc/sco_undo_notes.py +++ b/app/scodoc/sco_undo_notes.py @@ -173,7 +173,7 @@ def evaluation_list_operations(evaluation_id): return tab.make_page() -def formsemestre_list_saisies_notes(formsemestre_id, format="html"): +def formsemestre_list_saisies_notes(formsemestre_id, fmt="html"): """Table listant toutes les opérations de saisies de notes, dans toutes les évaluations du semestre. """ @@ -194,7 +194,7 @@ def formsemestre_list_saisies_notes(formsemestre_id, format="html"): {"formsemestre_id": formsemestre_id}, ) # Formate les notes - keep_numeric = format in scu.FORMATS_NUMERIQUES + keep_numeric = fmt in scu.FORMATS_NUMERIQUES for row in rows: row["value"] = scu.fmt_note(row["value"], keep_numeric=keep_numeric) row["date_evaluation"] = ( @@ -242,7 +242,7 @@ def formsemestre_list_saisies_notes(formsemestre_id, format="html"): base_url="%s?formsemestre_id=%s" % (request.base_url, formsemestre_id), origin=f"Généré par {sco_version.SCONAME} le " + scu.timedate_human_repr() + "", ) - return tab.make_page(format=format) + return tab.make_page(fmt=fmt) def get_note_history(evaluation_id, etudid, fmt=""): diff --git a/app/scodoc/sco_users.py b/app/scodoc/sco_users.py index 63ae2aaef2..8492dcff92 100644 --- a/app/scodoc/sco_users.py +++ b/app/scodoc/sco_users.py @@ -240,7 +240,7 @@ def list_users( preferences=sco_preferences.SemPreferences(), ) - return tab.make_page(format=fmt, with_html_headers=False) + return tab.make_page(fmt=fmt, with_html_headers=False) def get_users_count(dept=None) -> int: diff --git a/app/scodoc/sco_utils.py b/app/scodoc/sco_utils.py index f92ab38e38..5baba63447 100644 --- a/app/scodoc/sco_utils.py +++ b/app/scodoc/sco_utils.py @@ -879,10 +879,10 @@ DB_MIN_INT = -(1 << 31) DB_MAX_INT = (1 << 31) - 1 -def bul_filename_old(sem: dict, etud: dict, format): +def bul_filename_old(sem: dict, etud: dict, fmt): """Build a filename for this bulletin""" dt = time.strftime("%Y-%m-%d") - filename = f"bul-{sem['titre_num']}-{dt}-{etud['nom']}.{format}" + filename = f"bul-{sem['titre_num']}-{dt}-{etud['nom']}.{fmt}" filename = make_filename(filename) return filename @@ -952,15 +952,15 @@ def sendXML( def sendResult( data, name=None, - format=None, + fmt=None, force_outer_xml_tag=True, attached=False, quote_xml=False, filename=None, ): - if (format is None) or (format == "html"): + if (fmt is None) or (fmt == "html"): return data - elif format == "xml": # name is outer tagname + elif fmt == "xml": # name is outer tagname return sendXML( data, tagname=name, @@ -969,10 +969,10 @@ def sendResult( quote=quote_xml, filename=filename, ) - elif format == "json": + elif fmt == "json": return sendJSON(data, attached=attached, filename=filename) else: - raise ValueError("invalid format: %s" % format) + raise ValueError(f"invalid format: {fmt}") def send_file(data, filename="", suffix="", mime=None, attached=None): diff --git a/app/templates/assiduites/pages/visu_assi.j2 b/app/templates/assiduites/pages/visu_assi.j2 index 3f1c3b497c..f947928f33 100644 --- a/app/templates/assiduites/pages/visu_assi.j2 +++ b/app/templates/assiduites/pages/visu_assi.j2 @@ -16,7 +16,7 @@ value="{{date_fin}}"> - {{scu.ICON_XLS|safe}} + {{scu.ICON_XLS|safe}} {{tableau | safe}} diff --git a/app/templates/bul_head.j2 b/app/templates/bul_head.j2 index c851fa5775..6c284062e6 100644 --- a/app/templates/bul_head.j2 +++ b/app/templates/bul_head.j2 @@ -13,7 +13,7 @@
      - + Bulletin {{formsemestre.html_link_status() | safe}} @@ -39,7 +39,7 @@ scodoc_dept=g.scodoc_dept, formsemestre_id=formsemestre.id, etudid=etud.id, - format='pdf', + fmt='pdf', version=version, )}}">{{scu.ICON_PDF|safe}} diff --git a/app/views/absences.py b/app/views/absences.py index fd8a1443e0..0edc56cd2b 100644 --- a/app/views/absences.py +++ b/app/views/absences.py @@ -110,7 +110,7 @@ def AddBilletAbsence( code_nip=None, code_ine=None, justified=True, - format="json", + fmt="json", xml_reply=True, # deprecated ): """Mémorise un "billet" @@ -131,7 +131,7 @@ def AddBilletAbsence( justified = bool(justified) xml_reply = bool(xml_reply) if xml_reply: # backward compat - format = "xml" + fmt = "xml" # billet = BilletAbsence( etudid=etud.id, @@ -147,7 +147,7 @@ def AddBilletAbsence( # Renvoie le nouveau billet au format demandé table = sco_abs_billets.table_billets([billet], etud=etud) log(f"AddBilletAbsence: new billet_id={billet.id}") - return table.make_page(format=format) + return table.make_page(fmt=fmt) @bp.route("/add_billets_absence_form", methods=["GET", "POST"]) @@ -203,14 +203,14 @@ def add_billets_absence_form(etudid): @bp.route("/billets_etud/") @scodoc @permission_required(Permission.ScoView) -def billets_etud(etudid=False, format=False): +def billets_etud(etudid=False, fmt=False): """Liste billets pour un étudiant""" - fmt = format or request.args.get("format", "html") + fmt = fmt or request.args.get("fmt", "html") if not fmt in {"html", "json", "xml", "xls", "xlsx"}: return ScoValueError("Format invalide") table = sco_abs_billets.table_billets_etud(etudid) if table: - return table.make_page(format=fmt) + return table.make_page(fmt=fmt) return "" @@ -229,7 +229,7 @@ def XMLgetBilletsEtud(etudid=False, code_nip=False): etudid = etud.id table = sco_abs_billets.table_billets_etud(etudid) if table: - return table.make_page(format="xml") + return table.make_page(fmt="xml") return "" diff --git a/app/views/assiduites.py b/app/views/assiduites.py index 3d85636741..2af34bdb1b 100644 --- a/app/views/assiduites.py +++ b/app/views/assiduites.py @@ -958,7 +958,7 @@ def visu_assi_group(): "debut": request.args.get("date_debut"), "fin": request.args.get("date_fin"), } - fmt = request.args.get("format", "html") + fmt = request.args.get("fmt", "html") group_ids: list[int] = request.args.get("group_ids", None) if group_ids is None: diff --git a/app/views/notes.py b/app/views/notes.py index 8d18445185..9f198ba3bc 100644 --- a/app/views/notes.py +++ b/app/views/notes.py @@ -280,7 +280,7 @@ sco_publish( def formsemestre_bulletinetud( etudid=None, formsemestre_id=None, - format=None, + fmt=None, version="long", xml_with_decisions=False, force_publishing=False, @@ -288,7 +288,7 @@ def formsemestre_bulletinetud( code_nip=None, code_ine=None, ): - format = format or "html" + fmt = fmt or "html" if not isinstance(etudid, int): raise ScoInvalidIdType("formsemestre_bulletinetud: etudid must be an integer !") if formsemestre_id is not None and not isinstance(formsemestre_id, int): @@ -312,11 +312,11 @@ def formsemestre_bulletinetud( raise ScoValueError( "Paramètre manquant: spécifier etudid, code_nip ou code_ine" ) - if format == "json": + if fmt == "json": return sco_bulletins.get_formsemestre_bulletin_etud_json( formsemestre, etud, version=version, force_publishing=force_publishing ) - if formsemestre.formation.is_apc() and format == "html": + if formsemestre.formation.is_apc() and fmt == "html": return render_template( "but/bulletin.j2", appreciations=BulAppreciations.get_appreciations_list( @@ -327,7 +327,7 @@ def formsemestre_bulletinetud( scodoc_dept=g.scodoc_dept, formsemestre_id=formsemestre_id, etudid=etud.id, - format="json", + fmt="json", force_publishing=1, # pour ScoDoc lui même version=version, ), @@ -348,20 +348,20 @@ def formsemestre_bulletinetud( version=version, ) - if format == "oldjson": - format = "json" + if fmt == "oldjson": + fmt = "json" response = sco_bulletins.formsemestre_bulletinetud( etud, formsemestre_id=formsemestre_id, - format=format, + fmt=fmt, version=version, xml_with_decisions=xml_with_decisions, force_publishing=force_publishing, prefer_mail_perso=prefer_mail_perso, ) - if format == "pdfmail": # ne renvoie rien dans ce cas (mails envoyés) + if fmt == "pdfmail": # ne renvoie rien dans ce cas (mails envoyés) return redirect( url_for( "notes.formsemestre_bulletinetud", @@ -557,8 +557,8 @@ sco_publish( @scodoc @permission_required(Permission.ScoView) @scodoc7func -def formation_table_recap(formation_id, format="html"): - return sco_formation_recap.formation_table_recap(formation_id, format=format) +def formation_table_recap(formation_id, fmt="html"): + return sco_formation_recap.formation_table_recap(formation_id, fmt=fmt) sco_publish( @@ -724,14 +724,12 @@ def index_html(): @scodoc @permission_required(Permission.ScoView) @scodoc7func -def formation_export( - formation_id, export_ids=False, format=None, export_codes_apo=True -): +def formation_export(formation_id, export_ids=False, fmt=None, export_codes_apo=True): "Export de la formation au format indiqué (xml ou json)" return sco_formations.formation_export( formation_id, export_ids=export_ids, - format=format, + fmt=fmt, export_codes_apo=export_codes_apo, ) @@ -840,14 +838,14 @@ def ue_clone(): @permission_required_compat_scodoc7(Permission.ScoView) @scodoc7func def formsemestre_list( - format="json", + fmt="json", formsemestre_id=None, formation_id=None, etape_apo=None, ): """List formsemestres in given format. kw can specify some conditions: examples: - formsemestre_list( format='json', formation_id='F777') + formsemestre_list( fmt='json', formation_id='F777') """ log("Warning: calling deprecated view formsemestre_list") try: @@ -861,7 +859,7 @@ def formsemestre_list( if L[argname] is not None: args[argname] = L[argname] sems = sco_formsemestre.do_formsemestre_list(args=args) - return scu.sendResult(sems, name="formsemestre", format=format) + return scu.sendResult(sems, name="formsemestre", fmt=fmt) sco_publish( @@ -1224,7 +1222,7 @@ def view_module_abs(moduleimpl_id, fmt="html"): ) if fmt != "html": - return tab.make_page(format=fmt) + return tab.make_page(fmt=fmt) return "\n".join(H) + tab.html() + html_sco_header.sco_footer() @@ -1256,7 +1254,7 @@ def delete_ue_expr(formsemestre_id: int, ue_id: int): @scodoc @permission_required(Permission.ScoView) @scodoc7func -def formsemestre_enseignants_list(formsemestre_id, format="html"): +def formsemestre_enseignants_list(formsemestre_id, fmt="html"): """Liste les enseignants intervenants dans le semestre (resp. modules et chargés de TD) et indique les absences saisies par chacun. """ @@ -1340,7 +1338,7 @@ def formsemestre_enseignants_list(formsemestre_id, format="html"): caption="Tous les enseignants (responsables ou associés aux modules de ce semestre) apparaissent. Le nombre de saisies d'absences est le nombre d'opérations d'ajout effectuées sur ce semestre, sans tenir compte des annulations ou double saisies.", preferences=sco_preferences.SemPreferences(formsemestre_id), ) - return T.make_page(page_title=title, title=title, format=format) + return T.make_page(page_title=title, title=title, fmt=fmt) @bp.route("/edit_enseignants_form_delete", methods=["GET", "POST"]) @@ -1402,12 +1400,12 @@ sco_publish( @scodoc @permission_required(Permission.ScoView) @scodoc7func -def do_formsemestre_inscription_listinscrits(formsemestre_id, format=None): +def do_formsemestre_inscription_listinscrits(formsemestre_id, fmt=None): """Liste les inscrits (état I) à ce semestre et cache le résultat""" r = sco_formsemestre_inscriptions.do_formsemestre_inscription_listinscrits( formsemestre_id ) - return scu.sendResult(r, format=format, name="inscrits") + return scu.sendResult(r, fmt=fmt, name="inscrits") @bp.route("/formsemestre_desinscription", methods=["GET", "POST"]) @@ -1770,11 +1768,11 @@ def evaluation_listenotes(): except ValueError as exc: raise ScoValueError("evaluation_listenotes: id invalides !") from exc - format = vals.get("format", "html") + fmt = vals.get("fmt", "html") html_content, page_title = sco_liste_notes.do_evaluation_listenotes( - evaluation_id=evaluation_id, moduleimpl_id=moduleimpl_id, format=format + evaluation_id=evaluation_id, moduleimpl_id=moduleimpl_id, fmt=fmt ) - if format == "html": + if fmt == "html": H = html_sco_header.sco_header( page_title=page_title, cssstyles=["css/verticalhisto.css"], @@ -2022,7 +2020,7 @@ def formsemestre_bulletins_mailetuds( inscription.etud, version=version, prefer_mail_perso=prefer_mail_perso, - format="pdfmail", + fmt="pdfmail", ) if sent: nb_sent += 1 diff --git a/app/views/scodoc.py b/app/views/scodoc.py index e69a6688bd..7891e52b6a 100644 --- a/app/views/scodoc.py +++ b/app/views/scodoc.py @@ -364,7 +364,7 @@ def get_etud_dept(): ) # pour compat anciens clients PHP @scodoc @scodoc7func -def search_inscr_etud_by_nip(code_nip, format="json", __ac_name="", __ac_password=""): +def search_inscr_etud_by_nip(code_nip, fmt="json", __ac_name="", __ac_password=""): auth_ok = False user_name = __ac_name user_password = __ac_password @@ -376,7 +376,7 @@ def search_inscr_etud_by_nip(code_nip, format="json", __ac_name="", __ac_passwor if not auth_ok: abort(403) else: - return sco_find_etud.search_inscr_etud_by_nip(code_nip=code_nip, format=format) + return sco_find_etud.search_inscr_etud_by_nip(code_nip=code_nip, fmt=fmt) @bp.route("/ScoDoc/about") diff --git a/app/views/scolar.py b/app/views/scolar.py index 3d8b6f296a..7b13e2dd4f 100644 --- a/app/views/scolar.py +++ b/app/views/scolar.py @@ -294,7 +294,7 @@ class DeptLogosConfigurationForm(FlaskForm): @scodoc @permission_required(Permission.ScoView) @scodoc7func -def showEtudLog(etudid, format="html"): +def showEtudLog(etudid, fmt="html"): """Display log of operations on this student""" etud = sco_etud.get_etud_info(filled=True)[0] @@ -324,7 +324,7 @@ def showEtudLog(etudid, format="html"): preferences=sco_preferences.SemPreferences(), ) - return tab.make_page(format=format) + return tab.make_page(fmt=fmt) # ---------- PAGE ACCUEIL (listes) -------------- @@ -442,7 +442,7 @@ sco_publish( @scodoc7func def groups_view( group_ids=(), - format="html", + fmt="html", # Options pour listes: with_codes=0, etat=None, @@ -454,7 +454,7 @@ def groups_view( ): return sco_groups_view.groups_view( group_ids=group_ids, - format=format, + fmt=fmt, # Options pour listes: with_codes=with_codes, etat=etat, @@ -478,17 +478,16 @@ sco_publish( @scodoc @permission_required(Permission.ScoView) @scodoc7func -def getEtudInfo(etudid=False, code_nip=False, filled=False, format=None): +def getEtudInfo(etudid=False, code_nip=False, filled=False, fmt=None): """infos sur un etudiant (API) On peut specifier etudid ou code_nip ou bien cherche dans les arguments de la requête: etudid, code_nip, code_ine (dans cet ordre). """ etud = sco_etud.get_etud_info(etudid=etudid, code_nip=code_nip, filled=filled) - if format is None: + if fmt is None: return etud - else: - return scu.sendResult(etud, name="etud", format=format) + return scu.sendResult(etud, name="etud", fmt=fmt) sco_publish( @@ -524,9 +523,9 @@ def search_etud_by_name(): @scodoc @permission_required_compat_scodoc7(Permission.ScoView) @scodoc7func -def etud_info(etudid=None, format="xml"): +def etud_info(etudid=None, fmt="xml"): "Donne les informations sur un etudiant" - if not format in ("xml", "json"): + if not fmt in ("xml", "json"): raise ScoValueError("format demandé non supporté par cette fonction.") t0 = time.time() args = make_etud_args(etudid=etudid) @@ -545,9 +544,7 @@ def etud_info(etudid=None, format="xml"): "emailperso": "", "error": "code etudiant inconnu", } - return scu.sendResult( - d, name="etudiant", format=format, force_outer_xml_tag=False - ) + return scu.sendResult(d, name="etudiant", fmt=fmt, force_outer_xml_tag=False) d = {} etud = etuds[0] sco_etud.fill_etuds_info([etud]) @@ -615,7 +612,7 @@ def etud_info(etudid=None, format="xml"): log("etud_info (%gs)" % (time.time() - t0)) return scu.sendResult( - d, name="etudiant", format=format, force_outer_xml_tag=False, quote_xml=False + d, name="etudiant", fmt=fmt, force_outer_xml_tag=False, quote_xml=False ) @@ -2145,9 +2142,9 @@ def import_generate_excel_sample(with_codesemestre="1"): with_codesemestre = int(with_codesemestre) else: with_codesemestre = 0 - format = sco_import_etuds.sco_import_format() + fmt = sco_import_etuds.sco_import_format() data = sco_import_etuds.sco_import_generate_excel_sample( - format, with_codesemestre, exclude_cols=["photo_filename"] + fmt, with_codesemestre, exclude_cols=["photo_filename"] ) return scu.send_file( data, "ImportEtudiants", scu.XLSX_SUFFIX, mime=scu.XLSX_MIMETYPE diff --git a/misc/example-api-python2.py b/misc/example-api-python2.py index 7bd1bec2e1..03fd26beb2 100644 --- a/misc/example-api-python2.py +++ b/misc/example-api-python2.py @@ -32,12 +32,12 @@ response = urllib2.urlopen(req) # --- Use API # Affiche la liste des formations en format XML -req = urllib2.Request(BASEURL + "/Notes/formation_list?format=xml") +req = urllib2.Request(BASEURL + "/Notes/formation_list?fmt=xml") response = urllib2.urlopen(req) print response.read()[:100] # limite aux 100 premiers caracteres... # Recupere la liste de tous les semestres: -req = urllib2.Request(BASEURL + "/Notes/formsemestre_list?format=json") # format json +req = urllib2.Request(BASEURL + "/Notes/formsemestre_list?fmt=json") # format json response = urllib2.urlopen(req) js_data = response.read() @@ -55,7 +55,7 @@ else: # Obtient la liste des groupes: req = urllib2.Request( BASEURL - + "/Notes/formsemestre_partition_list?format=json&formsemestre_id=" + + "/Notes/formsemestre_partition_list?fmt=json&formsemestre_id=" + str(formsemestre_id) ) # format json response = urllib2.urlopen(req) @@ -66,7 +66,7 @@ else: ] # premier groupe (normalement existe toujours) # Liste les étudiants de ce groupe: req = urllib2.Request( - BASEURL + "/Notes/group_list?format=json&with_codes=1&group_id=" + str(group_id) + BASEURL + "/Notes/group_list?fmt=json&with_codes=1&group_id=" + str(group_id) ) # format json response = urllib2.urlopen(req) js_data = response.read() @@ -83,7 +83,7 @@ else: + str(formsemestre_id) + "&etudid=" + str(etudid) - + "&format=xml" + + "&fmt=xml" ) # format XML ici ! response = urllib2.urlopen(req) xml_bulletin = response.read() diff --git a/tests/api/exemple-api-basic.py b/tests/api/exemple-api-basic.py index 5433fadcff..8b0abad353 100644 --- a/tests/api/exemple-api-basic.py +++ b/tests/api/exemple-api-basic.py @@ -293,43 +293,3 @@ pp(GET(f"/formsemestre/880/resultats", headers=HEADERS)[0]) # # Affiche le semestre trouvé: # pp(sem) - -# # ---- Récupère la description de ce semestre: -# # semdescr = GET(s, f"Notes/formsemestre_description?formsemestre_id={sem['formsemestre_id']}&with_evals=0&format=json" ) - -# # ---- Liste les modules et prend le premier -# mods = GET(s, f"/Notes/moduleimpl_list?formsemestre_id={sem['formsemestre_id']}") -# print(f"{len(mods)} modules dans le semestre {sem['titre']}") - -# mod = mods[0] - -# # ---- Etudiants inscrits dans ce module -# inscrits = GET( -# s, f"Notes/do_moduleimpl_inscription_list?moduleimpl_id={mod['moduleimpl_id']}" -# ) -# print(f"{len(inscrits)} inscrits dans ce module") -# # prend le premier inscrit, au hasard: -# etudid = inscrits[0]["etudid"] - -# # ---- Création d'une evaluation le dernier jour du semestre -# jour = sem["date_fin"] -# evaluation_id = POST( -# s, -# f"/moduleimpl/{mod['moduleimpl_id']}/evaluation/create", -# data={ -# "coefficient": 1, -# "jour": jour, # "2023-08-23", -# "heure_debut": "9:00", -# "heure_fin": "10:00", -# "note_max": 20, # notes sur 20 -# "description": "essai", -# }, -# errmsg="échec création évaluation", -# ) - -# print( -# f"Evaluation créée dans le module {mod['moduleimpl_id']}, evaluation_id={evaluation_id}" -# ) -# print( -# f"Pour vérifier, aller sur: {DEPT_URL}/Notes/moduleimpl_status?moduleimpl_id={mod['moduleimpl_id']}", -# ) diff --git a/tests/api/exemple-api-scodoc7.py b/tests/api/exemple-api-scodoc7.py index fc80d13e55..a73a36cef2 100644 --- a/tests/api/exemple-api-scodoc7.py +++ b/tests/api/exemple-api-scodoc7.py @@ -2,6 +2,9 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- +# OBSOLETE - NE PLUS UTILISER CETTE API +# VOIR https://scodoc.org/ScoDoc9API/ + """Exemple connexion sur ScoDoc 9 et utilisation de l'ancienne API ScoDoc 7 à la mode "PHP": les gens passaient directement __ac_name et __ac_password dans chaque requête, en POST ou en GET. @@ -81,7 +84,7 @@ def POST(path: str, data: dict, errmsg=None): # pas besoin d'ouvrir une session, on y va directement: # --- Recupere la liste de tous les semestres: -sems = GET("Notes/formsemestre_list", params={"format": "json"}) +sems = GET("Notes/formsemestre_list", params={"fmt": "json"}) # sems est une liste de semestres (dictionnaires) for sem in sems: @@ -100,7 +103,7 @@ group_list = GET( params={ "formsemestre_id": sem["formsemestre_id"], "with_codes": 1, - "format": "json", + "fmt": "json", }, ) if not group_list: diff --git a/tests/unit/test_formations.py b/tests/unit/test_formations.py index f4ed753644..4e5a5e69f9 100644 --- a/tests/unit/test_formations.py +++ b/tests/unit/test_formations.py @@ -184,7 +184,7 @@ def test_formations(test_client): # --- Export de formation vers JSON exp = sco_formations.formation_export( - formation_id=formation_id, format="json", export_ids=True + formation_id=formation_id, fmt="json", export_ids=True ).get_data(as_text=True) assert isinstance(exp, str) load_exp = json.loads(exp) @@ -201,7 +201,7 @@ def test_formations(test_client): # --- Liste des semestres li_sem1 = notes.formsemestre_list( - formsemestre_id=formsemestre_id1, format="json" + formsemestre_id=formsemestre_id1, fmt="json" ).get_data(as_text=True) assert isinstance(li_sem1, str) load_li_sem1 = json.loads(li_sem1) # uniquement le semestre 1 dans la liste @@ -214,7 +214,7 @@ def test_formations(test_client): li_semf = notes.formsemestre_list( formation_id=formation_id, - format="json", + fmt="json", ).get_data(as_text=True) assert isinstance(li_semf, str) load_li_semf = json.loads(li_semf) @@ -224,7 +224,7 @@ def test_formations(test_client): sem2 = sco_formsemestre.get_formsemestre(formsemestre_id2) assert load_li_semf[1]["semestre_id"] == sem2["semestre_id"] - li_sem = notes.formsemestre_list(format="json").get_data(as_text=True) + li_sem = notes.formsemestre_list(fmt="json").get_data(as_text=True) load_li_sem = json.loads(li_sem) assert len(load_li_sem) == 3 @@ -379,7 +379,7 @@ def test_import_formation(test_client, filename="formation-exemple-1.xml"): assert mi["module_id"] == mod["module_id"] # --- Export formation en XML - doc1 = sco_formations.formation_export(formation_id, format="xml").get_data( + doc1 = sco_formations.formation_export(formation_id, fmt="xml").get_data( as_text=True ) assert isinstance(doc1, str) diff --git a/tests/unit/test_formsemestre.py b/tests/unit/test_formsemestre.py index 1af482eb1c..3328f30e02 100644 --- a/tests/unit/test_formsemestre.py +++ b/tests/unit/test_formsemestre.py @@ -105,13 +105,13 @@ def test_formsemestre_misc_views(test_client): ) assert isinstance(ans, (str, Response)) # ici c'est une str ans = sco_formsemestre_status.formsemestre_description( - formsemestre.id, with_evals=True, format="xls" + formsemestre.id, with_evals=True, fmt="xls" ) assert isinstance(ans, Response) assert ans.status == "200 OK" assert ans.mimetype == scu.XLSX_MIMETYPE ans = sco_formsemestre_status.formsemestre_description( - formsemestre.id, with_evals=True, format="pdf" + formsemestre.id, with_evals=True, fmt="pdf" ) assert isinstance(ans, Response) assert ans.status == "200 OK" @@ -187,12 +187,12 @@ def test_formsemestre_misc_views(test_client): # ----- MENU STATISTIQUES ans = sco_report.formsemestre_report_counts(formsemestre.id) - ans = sco_report.formsemestre_report_counts(formsemestre.id, format="xls") + ans = sco_report.formsemestre_report_counts(formsemestre.id, fmt="xls") assert isinstance(ans, Response) assert ans.status == "200 OK" assert ans.mimetype == scu.XLSX_MIMETYPE ans = sco_report.formsemestre_suivi_cohorte(formsemestre.id) - ans = sco_report.formsemestre_suivi_cohorte(formsemestre.id, format="pdf") + ans = sco_report.formsemestre_suivi_cohorte(formsemestre.id, fmt="pdf") assert isinstance(ans, Response) assert ans.status == "200 OK" assert ans.mimetype == scu.PDF_MIMETYPE

      Répartition des notes:

      " + histo + "