From 7a77b5a81a524d748b23a3bbfc33e6c15f645193 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sun, 28 Jul 2024 17:40:40 +0200 Subject: [PATCH] Nettoyage legacy sco_header --- app/but/jury_but_pv.py | 2 +- app/scodoc/TrivialFormulator.py | 6 +- app/scodoc/html_sco_header.py | 120 ++++---------------- app/scodoc/sco_archives_etud.py | 1 - app/scodoc/sco_archives_formsemestre.py | 1 - app/scodoc/sco_etape_apogee_view.py | 2 - app/scodoc/sco_export_results.py | 1 - app/scodoc/sco_find_etud.py | 1 - app/scodoc/sco_formsemestre_edit.py | 3 - app/scodoc/sco_formsemestre_inscriptions.py | 1 - app/scodoc/sco_groups_view.py | 5 +- app/scodoc/sco_inscr_passage.py | 1 - app/scodoc/sco_lycee.py | 2 - app/scodoc/sco_moduleimpl_inscriptions.py | 2 - app/scodoc/sco_pv_forms.py | 3 - app/scodoc/sco_recapcomplet.py | 1 - app/scodoc/sco_report.py | 1 - app/scodoc/sco_saisie_excel.py | 1 - app/scodoc/sco_saisie_notes.py | 1 - app/scodoc/sco_semset.py | 1 - app/scodoc/sco_synchro_etuds.py | 1 - app/scodoc/sco_utils.py | 9 ++ app/templates/base.j2 | 5 - app/views/absences.py | 1 - app/views/notes.py | 7 +- app/views/scolar.py | 1 - app/views/users.py | 2 +- 27 files changed, 41 insertions(+), 141 deletions(-) diff --git a/app/but/jury_but_pv.py b/app/but/jury_but_pv.py index c0b07ba24..1462f1fbf 100644 --- a/app/but/jury_but_pv.py +++ b/app/but/jury_but_pv.py @@ -105,7 +105,7 @@ def pvjury_page_but(formsemestre_id: int, fmt="html"): }, xls_style_base=xls_style_base, ) - return tab.make_page(fmt=fmt, javascripts=["js/etud_info.js"], init_qtip=True) + return tab.make_page(fmt=fmt, javascripts=["js/etud_info.js"]) def pvjury_table_but( diff --git a/app/scodoc/TrivialFormulator.py b/app/scodoc/TrivialFormulator.py index fe71c12bd..cbabc42d5 100644 --- a/app/scodoc/TrivialFormulator.py +++ b/app/scodoc/TrivialFormulator.py @@ -95,7 +95,6 @@ def TrivialFormulator( To use text_suggest elements, one must: - specify options in text_suggest_options (a dict) - HTML page must load JS AutoSuggest.js and CSS autosuggest_inquisitor.css - - bodyOnLoad must call JS function init_tf_form(formid) """ method = method.lower() if method == "get": @@ -776,9 +775,12 @@ var {field}_as = new bsn.AutoSuggest('{field}', {field}_opts); # => only one form with text_suggest field on a page. R.append( """""" % "\n".join(suggest_js) ) diff --git a/app/scodoc/html_sco_header.py b/app/scodoc/html_sco_header.py index 011ab49d9..7a0f4441a 100644 --- a/app/scodoc/html_sco_header.py +++ b/app/scodoc/html_sco_header.py @@ -27,10 +27,7 @@ """HTML Header/Footer for ScoDoc pages""" -import html - from flask import g, render_template, url_for -from flask import request from flask_login import current_user import app.scodoc.sco_utils as scu @@ -85,7 +82,6 @@ _HTML_BEGIN = f""" - @@ -98,6 +94,7 @@ _HTML_BEGIN = f""" + + + + + + + """ def scodoc_top_html_header(page_title="ScoDoc: bienvenue"): + """HTML header for top level pages""" H = [ _HTML_BEGIN % {"page_title": page_title, "encoding": scu.SCO_ENCODING}, """""", @@ -143,13 +147,8 @@ def sco_header( cssstyles=(), # additionals CSS sheets javascripts=(), # additionals JS filenames to load scripts=(), # script to put in page header - bodyOnLoad="", # JS - init_qtip=False, # include qTip init_google_maps=False, # Google maps - init_datatables=True, titrebandeau="", # titre dans bandeau superieur - head_message="", # message action (petit cadre jaune en haut) DEPRECATED - user_check=True, # verifie passwords temporaires etudid=None, formsemestre_id=None, ): @@ -162,12 +161,6 @@ def sco_header( g.current_etudid = etudid scodoc_flash_status_messages() - # Get head message from http request: - if not head_message: - if request.method == "POST": - head_message = request.form.get("head_message", "") - elif request.method == "GET": - head_message = request.args.get("head_message", "") params = { "page_title": page_title or sco_version.SCONAME, "no_side_bar": no_side_bar, @@ -176,37 +169,13 @@ def sco_header( "titrebandeau_mkup": "" + titrebandeau + "", "authuser": current_user.user_name, } - if bodyOnLoad: - params["bodyOnLoad_mkup"] = """onload="%s" """ % bodyOnLoad - else: - params["bodyOnLoad_mkup"] = "" if no_side_bar: params["margin_left"] = "1em" else: params["margin_left"] = "140px" - H = [ - """ - - - -%(page_title)s - - + H = [_HTML_BEGIN % params] -""" - % params - ] - # jQuery UI - # can modify loaded theme here - H.append( - f""" - - - """ - ) if init_google_maps: # It may be necessary to add an API key: H.append('') @@ -219,61 +188,17 @@ def sco_header( H.append( f""" - - - - - - """ ) - # jQuery - H.append( - f""" - - - """ - ) - # qTip - if init_qtip: - H.append( - f""" - - """ - ) - - H.append( - f""" - - - """ - ) - if init_google_maps: + if init_google_maps: # utilisé uniquement pour carte lycées H.append( f'' ) - if init_datatables: - H.append( - f""" - """ - ) - # H.append( - # f'' - # ) + # JS additionels for js in javascripts: H.append(f"""\n""") @@ -295,15 +220,16 @@ def sco_header( H.append(script) H.append("""""") - H.append("") - - # Body et bandeau haut: - H.append("""""" % params) - H.append(scu.CUSTOM_HTML_HEADER) - # - if not no_side_bar: - H.append(html_sidebar.sidebar(etudid)) - H.append("""
""") + # Fin head, Body et bandeau haut: + H.append( + f""" + + +{scu.CUSTOM_HTML_HEADER} +{'' if no_side_bar else html_sidebar.sidebar(etudid)} +
+""" + ) # En attendant le replacement complet de cette fonction, # inclusion ici des messages flask H.append(render_template("flashed_messages.j2")) @@ -311,10 +237,6 @@ def sco_header( # Barre menu semestre: H.append(formsemestre_page_title(formsemestre_id)) - # - if head_message: - H.append('
' + html.escape(head_message) + "
") - # # div pour affichage messages temporaires H.append('
') # diff --git a/app/scodoc/sco_archives_etud.py b/app/scodoc/sco_archives_etud.py index da1fcbb98..9b332b030 100644 --- a/app/scodoc/sco_archives_etud.py +++ b/app/scodoc/sco_archives_etud.py @@ -217,7 +217,6 @@ def etud_delete_archive(etudid, archive_name, dialog_confirmed=False): "scolar.fiche_etud", scodoc_dept=g.scodoc_dept, etudid=etudid, - head_message="annulation", ), parameters={"etudid": etudid, "archive_name": archive_name}, ) diff --git a/app/scodoc/sco_archives_formsemestre.py b/app/scodoc/sco_archives_formsemestre.py index f3eb098d4..f2fbde23b 100644 --- a/app/scodoc/sco_archives_formsemestre.py +++ b/app/scodoc/sco_archives_formsemestre.py @@ -242,7 +242,6 @@ def formsemestre_archive(formsemestre_id, group_ids: list[int] = None): "Archiver les PV et résultats du semestre", javascripts=sco_groups_view.JAVASCRIPTS, cssstyles=sco_groups_view.CSSSTYLES, - init_qtip=True, ), """

Cette page permet de générer et d'archiver tous les documents résultant de ce semestre: PV de jury, lettres individuelles, diff --git a/app/scodoc/sco_etape_apogee_view.py b/app/scodoc/sco_etape_apogee_view.py index 5845013b3..9a576be8c 100644 --- a/app/scodoc/sco_etape_apogee_view.py +++ b/app/scodoc/sco_etape_apogee_view.py @@ -597,7 +597,6 @@ def _view_etuds_page( return f""" {html_sco_header.sco_header( page_title=title, - init_qtip=True, javascripts=["js/etud_info.js"], )}

{title}

@@ -751,7 +750,6 @@ def view_apo_csv(etape_apo="", semset_id="", fmt="html"): H = [ html_sco_header.sco_header( page_title=f"""Maquette Apogée enregistrée pour {etape_apo}""", - init_qtip=True, javascripts=["js/etud_info.js"], ), f"""

Étudiants dans la maquette Apogée {etape_apo}

diff --git a/app/scodoc/sco_export_results.py b/app/scodoc/sco_export_results.py index 2d90f3c11..b28bd63d5 100644 --- a/app/scodoc/sco_export_results.py +++ b/app/scodoc/sco_export_results.py @@ -287,7 +287,6 @@ def scodoc_table_results( H = [ html_sco_header.sco_header( page_title="Export résultats", - init_qtip=True, javascripts=html_sco_header.BOOTSTRAP_MULTISELECT_JS + ["js/etud_info.js", "js/export_results.js"], cssstyles=html_sco_header.BOOTSTRAP_MULTISELECT_CSS, diff --git a/app/scodoc/sco_find_etud.py b/app/scodoc/sco_find_etud.py index 621390ff1..6fad97cb4 100644 --- a/app/scodoc/sco_find_etud.py +++ b/app/scodoc/sco_find_etud.py @@ -181,7 +181,6 @@ def search_etud_in_dept(expnom=""): html_sco_header.sco_header( page_title="Recherche d'un étudiant", no_side_bar=False, - init_qtip=True, javascripts=["js/etud_info.js"], ) ] diff --git a/app/scodoc/sco_formsemestre_edit.py b/app/scodoc/sco_formsemestre_edit.py index dc066f219..e57449709 100644 --- a/app/scodoc/sco_formsemestre_edit.py +++ b/app/scodoc/sco_formsemestre_edit.py @@ -86,7 +86,6 @@ def formsemestre_createwithmodules(): page_title="Création d'un semestre", javascripts=["libjs/AutoSuggest.js", "js/formsemestre_edit.js"], cssstyles=["css/autosuggest_inquisitor.css"], - bodyOnLoad="init_tf_form('')", ), """

Mise en place d'un semestre de formation

""", ] @@ -108,7 +107,6 @@ def formsemestre_editwithmodules(formsemestre_id): "Modification du semestre", javascripts=["libjs/AutoSuggest.js", "js/formsemestre_edit.js"], cssstyles=["css/autosuggest_inquisitor.css"], - bodyOnLoad="init_tf_form('')", ) ] if not formsemestre.etat: @@ -1168,7 +1166,6 @@ def formsemestre_clone(formsemestre_id): "Copie du semestre", javascripts=["libjs/AutoSuggest.js"], cssstyles=["css/autosuggest_inquisitor.css"], - bodyOnLoad="init_tf_form('')", ), """

Cette opération duplique un semestre: on reprend les mêmes modules et responsables. Aucun étudiant n'est inscrit.

""", ] diff --git a/app/scodoc/sco_formsemestre_inscriptions.py b/app/scodoc/sco_formsemestre_inscriptions.py index 217a096e5..bbe9f4f3c 100644 --- a/app/scodoc/sco_formsemestre_inscriptions.py +++ b/app/scodoc/sco_formsemestre_inscriptions.py @@ -853,7 +853,6 @@ def formsemestre_inscrits_ailleurs(formsemestre_id): H = [ html_sco_header.html_sem_header( "Inscriptions multiples parmi les étudiants du semestre ", - init_qtip=True, javascripts=["js/etud_info.js"], ) ] diff --git a/app/scodoc/sco_groups_view.py b/app/scodoc/sco_groups_view.py index 40ff6d7cf..c111520d1 100644 --- a/app/scodoc/sco_groups_view.py +++ b/app/scodoc/sco_groups_view.py @@ -116,7 +116,6 @@ def groups_view( { html_sco_header.sco_header( javascripts=JAVASCRIPTS, cssstyles=CSSSTYLES, - init_qtip=True, ) }