1
0
forked from ScoDoc/ScoDoc

Nettoyage legacy sco_header

This commit is contained in:
Emmanuel Viennet 2024-07-28 17:40:40 +02:00
parent 7ff0fd39fb
commit 7a77b5a81a
27 changed files with 41 additions and 141 deletions

View File

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

View File

@ -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(
"""<script type="text/javascript">
function init_tf_form(formid) {
function init_tf_form() {
%s
}
document.addEventListener('DOMContentLoaded', function() {
init_tf_form();
});
</script>"""
% "\n".join(suggest_js)
)

View File

@ -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"""<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Type" content="text/html; charset=%(encoding)s" />
<meta http-equiv="Content-Style-Type" content="text/css" />
@ -98,6 +94,7 @@ _HTML_BEGIN = f"""<!DOCTYPE html>
<link href="{scu.STATIC_DIR}/css/scodoc.css" rel="stylesheet" type="text/css" />
<link href="{scu.STATIC_DIR}/css/menu.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="{scu.STATIC_DIR}/DataTables/datatables.min.css" />
<link href="{scu.STATIC_DIR}/css/gt_table.css" rel="stylesheet" type="text/css" />
<script src="{scu.STATIC_DIR}/libjs/menu.js"></script>
<script src="{scu.STATIC_DIR}/libjs/bubble.js"></script>
<script>
@ -121,12 +118,19 @@ _HTML_BEGIN = f"""<!DOCTYPE html>
<script src="{scu.STATIC_DIR}/libjs/qtip/jquery.qtip-3.0.3.min.js"></script>
<link type="text/css" rel="stylesheet" href="{scu.STATIC_DIR}/libjs/qtip/jquery.qtip-3.0.3.min.css" />
<link type="text/css" rel="stylesheet" href="{scu.STATIC_DIR}/libjs/timepicker-1.3.5/jquery.timepicker.min.css" />
<script src="{scu.STATIC_DIR}/libjs/timepicker-1.3.5/jquery.timepicker.min.js"></script>
<script src="{scu.STATIC_DIR}/js/scodoc.js"></script>
<script src="{scu.STATIC_DIR}/js/etud_info.js"></script>
<script src="{scu.STATIC_DIR}/libjs/qtip/jquery.qtip-3.0.3.min.js"></script>
<link type="text/css" rel="stylesheet" href="{scu.STATIC_DIR}/libjs/qtip/jquery.qtip-3.0.3.min.css" />
"""
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},
"""</head><body id="gtrcontent">""",
@ -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": "<td>" + titrebandeau + "</td>",
"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 = [
"""<!DOCTYPE html><html lang="fr">
<!-- ScoDoc legacy -->
<head>
<meta charset="utf-8"/>
<title>%(page_title)s</title>
<meta name="LANG" content="fr" />
<meta name="DESCRIPTION" content="ScoDoc" />
H = [_HTML_BEGIN % params]
"""
% params
]
# jQuery UI
# can modify loaded theme here
H.append(
f"""
<link type="text/css" rel="stylesheet"
href="{scu.STATIC_DIR}/libjs/jquery-ui-1.10.4.custom/css/smoothness/jquery-ui-1.10.4.custom.min.css" />
<link type="text/css" rel="stylesheet"
href="{scu.STATIC_DIR}/libjs/timepicker-1.3.5/jquery.timepicker.min.css" />
"""
)
if init_google_maps:
# It may be necessary to add an API key:
H.append('<script src="https://maps.google.com/maps/api/js"></script>')
@ -219,61 +188,17 @@ def sco_header(
H.append(
f"""
<link href="{scu.STATIC_DIR}/css/scodoc.css" rel="stylesheet" type="text/css" />
<link href="{scu.STATIC_DIR}/css/menu.css" rel="stylesheet" type="text/css" />
<link href="{scu.STATIC_DIR}/css/gt_table.css" rel="stylesheet" type="text/css" />
<script src="{scu.STATIC_DIR}/libjs/menu.js"></script>
<script src="{scu.STATIC_DIR}/libjs/bubble.js"></script>
<script>
window.onload=function(){{
if (document.getElementById('gtrcontent')) {{
enableTooltips("gtrcontent");
}}
if (document.getElementById('sidebar')) {{
enableTooltips("sidebar");
}}
}};
const SCO_URL="{url_for("scolar.index_html", scodoc_dept=g.scodoc_dept)}";
const SCO_TIMEZONE="{scu.TIME_ZONE}";
</script>"""
)
# jQuery
H.append(
f"""
<script src="{scu.STATIC_DIR}/jQuery/jquery.js"></script>
<script src="{scu.STATIC_DIR}/libjs/jquery.field.min.js"></script>
"""
)
# qTip
if init_qtip:
H.append(
f"""<script src="{scu.STATIC_DIR}/libjs/qtip/jquery.qtip-3.0.3.min.js"></script>
<link type="text/css" rel="stylesheet"
href="{scu.STATIC_DIR}/libjs/qtip/jquery.qtip-3.0.3.min.css" />
"""
)
H.append(
f"""<script
src="{scu.STATIC_DIR}/libjs/jquery-ui-1.10.4.custom/js/jquery-ui-1.10.4.custom.min.js"></script>
<script src="{scu.STATIC_DIR}/libjs/timepicker-1.3.5/jquery.timepicker.min.js"></script>
<script src="{scu.STATIC_DIR}/js/scodoc.js"></script>
"""
)
if init_google_maps:
if init_google_maps: # utilisé uniquement pour carte lycées
H.append(
f'<script src="{scu.STATIC_DIR}/libjs/jquery.ui.map.full.min.js"></script>'
)
if init_datatables:
H.append(
f"""<link rel="stylesheet" type="text/css" href="{scu.STATIC_DIR}/DataTables/datatables.min.css"/>
<script src="{scu.STATIC_DIR}/DataTables/datatables.min.js"></script>"""
)
# H.append(
# f'<link href="{scu.STATIC_DIR}/css/tooltip.css" rel="stylesheet" type="text/css" />'
# )
# JS additionels
for js in javascripts:
H.append(f"""<script src="{scu.STATIC_DIR}/{js}"></script>\n""")
@ -295,15 +220,16 @@ def sco_header(
H.append(script)
H.append("""</script>""")
H.append("</head>")
# Body et bandeau haut:
H.append("""<body %(bodyOnLoad_mkup)s>""" % params)
H.append(scu.CUSTOM_HTML_HEADER)
#
if not no_side_bar:
H.append(html_sidebar.sidebar(etudid))
H.append("""<div id="gtrcontent">""")
# Fin head, Body et bandeau haut:
H.append(
f"""</head>
<!-- Legacy ScoDoc header -->
<body>
{scu.CUSTOM_HTML_HEADER}
{'' if no_side_bar else html_sidebar.sidebar(etudid)}
<div id="gtrcontent">
"""
)
# 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('<div class="head_message">' + html.escape(head_message) + "</div>")
#
# div pour affichage messages temporaires
H.append('<div id="sco_msg" class="head_message"></div>')
#

View File

@ -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},
)

View File

@ -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,
),
"""<p class="help">Cette page permet de générer et d'archiver tous
les documents résultant de ce semestre: PV de jury, lettres individuelles,

View File

@ -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"],
)}
<h2>{title}</h2>
@ -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"""<h2>Étudiants dans la maquette Apogée {etape_apo}</h2>

View File

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

View File

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

View File

@ -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('')",
),
"""<h2>Mise en place d'un semestre de formation</h2>""",
]
@ -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('')",
),
"""<p class="help">Cette opération duplique un semestre: on reprend les mêmes modules et responsables. Aucun étudiant n'est inscrit.</p>""",
]

View File

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

View File

@ -116,7 +116,6 @@ def groups_view(
{ html_sco_header.sco_header(
javascripts=JAVASCRIPTS,
cssstyles=CSSSTYLES,
init_qtip=True,
)
}
<style>
@ -586,8 +585,8 @@ def groups_table(
etud_info["_nom_disp_order"] = etud_sort_key(etud_info)
etud_info["_prenom_target"] = fiche_url
etud_info["_nom_disp_td_attrs"] = (
'id="%s" class="etudinfo"' % (etud_info["etudid"])
etud_info["_nom_disp_td_attrs"] = 'id="%s" class="etudinfo"' % (
etud_info["etudid"]
)
etud_info["bourse_str"] = "oui" if etud_info["boursier"] else "non"
if etud_info["etat"] == "D":

View File

@ -315,7 +315,6 @@ def formsemestre_inscr_passage(
H = [
html_sco_header.sco_header(
page_title="Passage des étudiants",
init_qtip=True,
javascripts=["js/etud_info.js"],
)
]

View File

@ -98,7 +98,6 @@ def scodoc_table_etuds_lycees(fmt="html"):
html_sco_header.sco_header(
page_title=tab.page_title,
init_google_maps=True,
init_qtip=True,
javascripts=["js/etud_info.js", "js/map_lycees.js"],
),
"""<h2 class="formsemestre">Lycées d'origine des %d étudiants (%d semestres)</h2>"""
@ -219,7 +218,6 @@ def formsemestre_etuds_lycees(
html_sco_header.sco_header(
page_title=tab.page_title,
init_google_maps=True,
init_qtip=True,
cssstyles=sco_groups_view.CSSSTYLES,
javascripts=sco_groups_view.JAVASCRIPTS
+ ["js/etud_info.js", "js/map_lycees.js"],

View File

@ -84,7 +84,6 @@ def moduleimpl_inscriptions_edit(
return # can_change_inscriptions raises exception
header = html_sco_header.sco_header(
page_title="Inscription au module",
init_qtip=True,
javascripts=["js/etud_info.js"],
)
footer = html_sco_header.sco_footer()
@ -304,7 +303,6 @@ def moduleimpl_inscriptions_stats(formsemestre_id):
html_sco_header.html_sem_header(
"Inscriptions aux modules et UE du semestre",
javascripts=["js/etud_info.js", "js/moduleimpl_inscriptions_stats.js"],
init_qtip=True,
)
]

View File

@ -264,7 +264,6 @@ def formsemestre_pvjury(formsemestre_id, fmt="html", publish=True):
H = [
html_sco_header.html_sem_header(
"Décisions du jury pour le semestre",
init_qtip=True,
javascripts=["js/etud_info.js"],
),
"""<p>(dernière modif le %s)</p>""" % dpv["date"],
@ -372,7 +371,6 @@ def formsemestre_pvjury_pdf(formsemestre_id, group_ids: list[int] = None, etudid
f"Édition du PV de jury {etuddescr}",
javascripts=sco_groups_view.JAVASCRIPTS,
cssstyles=sco_groups_view.CSSSTYLES,
init_qtip=True,
),
f"""<div class="help">Utiliser cette page pour éditer des versions provisoires des PV.
<span class="fontred">Il est recommandé d'archiver les versions définitives:
@ -559,7 +557,6 @@ def formsemestre_lettres_individuelles(formsemestre_id, group_ids=[]):
"Édition des lettres individuelles",
javascripts=sco_groups_view.JAVASCRIPTS,
cssstyles=sco_groups_view.CSSSTYLES,
init_qtip=True,
),
f"""<p class="help">Utiliser cette page pour éditer des versions provisoires des PV.
<span class="fontred">Il est recommandé d'archiver les versions définitives: <a

View File

@ -123,7 +123,6 @@ def formsemestre_recapcomplet(
page_title=f"{formsemestre.sem_modalite()}: "
+ ("jury" if mode_jury else "moyennes"),
no_side_bar=True,
init_qtip=True,
javascripts=["js/etud_info.js", "js/table_recap.js"],
),
sco_formsemestre_status.formsemestre_status_head(

View File

@ -1367,7 +1367,6 @@ def formsemestre_suivi_cursus(
H = [
html_sco_header.sco_header(
page_title=tab.page_title,
init_qtip=True,
javascripts=["js/etud_info.js"],
),
"""<h2 class="formsemestre">Cursus suivis par les étudiants de ce semestre</h2>""",

View File

@ -1001,7 +1001,6 @@ def saisie_notes_tableur(evaluation_id: int, group_ids=()):
page_title=page_title,
javascripts=sco_groups_view.JAVASCRIPTS,
cssstyles=sco_groups_view.CSSSTYLES,
init_qtip=True,
),
sco_evaluations.evaluation_describe(evaluation_id=evaluation_id),
"""<span class="eval_title">Saisie des notes par fichier</span>""",

View File

@ -668,7 +668,6 @@ def saisie_notes(evaluation_id: int, group_ids: list = None):
page_title=page_title,
javascripts=sco_groups_view.JAVASCRIPTS + ["js/saisie_notes.js"],
cssstyles=sco_groups_view.CSSSTYLES,
init_qtip=True,
),
sco_evaluations.evaluation_describe(
evaluation_id=evaluation_id, link_saisie=False

View File

@ -519,7 +519,6 @@ def semset_page(fmt="html"):
H = [
html_sco_header.sco_header(
page_title=page_title,
init_qtip=True,
javascripts=["libjs/jinplace-1.2.1.min.js"],
),
"""<script>$(function() {

View File

@ -171,7 +171,6 @@ def formsemestre_synchro_etuds(
H = [
html_sco_header.sco_header(
page_title="Synchronisation étudiants",
init_qtip=True,
javascripts=["js/etud_info.js"],
)
]

View File

@ -1056,6 +1056,15 @@ def flash_once(message: str):
g.sco_flashed_once.add(message)
def html_flash_message(message: str):
"""HTML for flashed messaged, for legacy codes"""
return f"""<div class="container flashes">
<div class="alert alert-info alert-message" role="alert">
{message}
</div>
</div>"""
def sendCSVFile(data, filename): # DEPRECATED utiliser send_file
"""publication fichier CSV."""
return send_file(data, filename=filename, mime=CSV_MIMETYPE, attached=True)

View File

@ -94,11 +94,6 @@
{{ super() }}
<script src="{{scu.STATIC_DIR}}/libjs/menu.js"></script>
<script src="{{scu.STATIC_DIR}}/libjs/bubble.js"></script>
<script src="{{scu.STATIC_DIR}}/jQuery/jquery.js"></script>
<script src="{{scu.STATIC_DIR}}/jQuery/jquery-migrate-1.2.0.min.js"></script>
<script src="{{scu.STATIC_DIR}}/libjs/jquery.field.min.js"></script>
<script src="{{scu.STATIC_DIR}}/libjs/jquery-ui-1.10.4.custom/js/jquery-ui-1.10.4.custom.min.js"></script>
<script src="{{scu.STATIC_DIR}}/libjs/qtip/jquery.qtip-3.0.3.min.js"></script>
<script src="{{scu.STATIC_DIR}}/js/scodoc.js"></script>
<script>
const SCO_URL = "{% if g.scodoc_dept %}{{

View File

@ -247,7 +247,6 @@ def list_billets():
html_sco_header.sco_header(
page_title="Billet d'absence non traités",
javascripts=["js/etud_info.js"],
init_qtip=True,
),
f"<h2>Billets d'absence en attente de traitement ({table.get_nb_rows()})</h2>",
]

View File

@ -951,7 +951,6 @@ def edit_enseignants_form(moduleimpl_id):
page_title=f"Enseignants du module {modimpl.module.titre or modimpl.module.code}",
javascripts=["libjs/AutoSuggest.js"],
cssstyles=["css/autosuggest_inquisitor.css"],
bodyOnLoad="init_tf_form('')",
)
footer = html_sco_header.sco_footer()
@ -1044,7 +1043,9 @@ def edit_enseignants_form(moduleimpl_id):
or ens.id == modimpl.responsable_id
):
H.append(
f"""<p class="help">Enseignant {ens.user_name} déjà dans la liste !</p>"""
scu.html_flash_message(
f"Enseignant {ens.user_name} déjà dans la liste !"
)
)
else:
modimpl.enseignants.append(ens)
@ -1078,7 +1079,6 @@ def edit_moduleimpl_resp(moduleimpl_id: int):
}">module {modimpl.module.titre or ""}</a>""",
javascripts=["libjs/AutoSuggest.js"],
cssstyles=["css/autosuggest_inquisitor.css"],
bodyOnLoad="init_tf_form('')",
)
]
help_str = """<p class="help">Taper le début du nom de l'enseignant.</p>"""
@ -1770,7 +1770,6 @@ def evaluation_listenotes():
page_title=page_title,
cssstyles=["css/verticalhisto.css"],
javascripts=["js/etud_info.js"],
init_qtip=True,
)
F = html_sco_header.sco_footer()
return H + html_content + F

View File

@ -951,7 +951,6 @@ def partition_editor(formsemestre_id: int, edit_partition=False):
"js/partition_editor.js",
],
page_title=f"Partitions de {formsemestre.titre_annee()}",
init_datatables=True,
),
"""<h2></h2>""",
render_template(

View File

@ -1002,7 +1002,7 @@ def form_change_password(user_name=None):
if not can_handle_passwd(user):
return "\n".join(
[
html_sco_header.sco_header(user_check=False),
html_sco_header.sco_header(),
"<p>Vous n'avez pas la permission de changer ce mot de passe</p>",
html_sco_header.sco_footer(),
]