From f136b80c84eb013dc9d7c6a8f6fc7be20670bf3f Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sun, 18 Aug 2024 18:40:11 +0200 Subject: [PATCH] Templatification: progress --- app/forms/main/config_logos.py | 4 +- app/scodoc/gen_tables.py | 1 - app/scodoc/sco_archives_etud.py | 25 ++++----- app/scodoc/sco_find_etud.py | 20 ++++--- app/scodoc/sco_moduleimpl_inscriptions.py | 12 ++-- app/scodoc/sco_page_etud.py | 18 +++--- app/static/css/scodoc.css | 2 +- app/templates/babase.j2 | 4 ++ app/templates/base.j2 | 4 +- app/templates/sco_page.j2 | 4 -- app/templates/scodoc.j2 | 4 +- app/views/scodoc.py | 24 ++++---- app/views/users.py | 68 ++++++++++++++++------- 13 files changed, 102 insertions(+), 88 deletions(-) diff --git a/app/forms/main/config_logos.py b/app/forms/main/config_logos.py index 6529907d..31f8bc6f 100644 --- a/app/forms/main/config_logos.py +++ b/app/forms/main/config_logos.py @@ -46,10 +46,8 @@ from app.scodoc.sco_config_actions import LogoInsert from app.scodoc.sco_exceptions import ScoValueError from app.scodoc.sco_logos import find_logo - -JAVASCRIPTS = html_sco_header.BOOTSTRAP_JS + [] - CSSSTYLES = html_sco_header.BOOTSTRAP_CSS +JAVASCRIPTS = html_sco_header.BOOTSTRAP_JS # class ItemForm(FlaskForm): # """Unused Generic class to document common behavior for classes diff --git a/app/scodoc/gen_tables.py b/app/scodoc/gen_tables.py index 9c2c2880..f37a55f6 100644 --- a/app/scodoc/gen_tables.py +++ b/app/scodoc/gen_tables.py @@ -57,7 +57,6 @@ from reportlab.lib.units import cm from flask import render_template -from app.scodoc import html_sco_header from app.scodoc import sco_utils as scu from app.scodoc import sco_excel from app.scodoc import sco_pdf diff --git a/app/scodoc/sco_archives_etud.py b/app/scodoc/sco_archives_etud.py index 9b332b03..b7ff7d32 100644 --- a/app/scodoc/sco_archives_etud.py +++ b/app/scodoc/sco_archives_etud.py @@ -41,10 +41,8 @@ from app.scodoc import sco_groups from app.scodoc import sco_trombino from app.scodoc import sco_archives from app.scodoc.sco_permissions import Permission -from app.scodoc.sco_exceptions import AccessDenied, ScoValueError +from app.scodoc.sco_exceptions import AccessDenied from app.scodoc.TrivialFormulator import TrivialFormulator -from app.scodoc import html_sco_header -from app.scodoc import sco_etud class EtudsArchiver(sco_archives.BaseArchiver): @@ -142,9 +140,6 @@ def etud_upload_file_form(etudid): etud = Identite.get_etud(etudid) H = [ - html_sco_header.sco_header( - page_title=f"Chargement d'un document associé à {etud.nomprenom}", - ), f"""

Chargement d'un document associé à {etud.nomprenom}

Le fichier ne doit pas dépasser { @@ -171,8 +166,12 @@ def etud_upload_file_form(etudid): cancelbutton="Annuler", ) if tf[0] == 0: - return "\n".join(H) + tf[1] + html_sco_header.sco_footer() - elif tf[0] == -1: + return render_template( + "sco_page.j2", + title=f"Chargement d'un document associé à {etud.nomprenom}", + content="\n".join(H) + tf[1], + ) + if tf[0] == -1: return flask.redirect(etud.url_fiche()) data = tf[2]["datafile"].read() descr = tf[2]["description"] @@ -263,9 +262,6 @@ def etudarchive_generate_excel_sample(group_id=None): def etudarchive_import_files_form(group_id): """Formulaire pour importation fichiers d'un groupe""" H = [ - html_sco_header.sco_header( - page_title="Import de fichiers associés aux étudiants" - ), """

Téléchargement de fichier associés aux étudiants

Les fichiers associés (dossiers d'admission, certificats, ...), de types quelconques (pdf, doc, images) sont accessibles aux utilisateurs via @@ -292,7 +288,6 @@ def etudarchive_import_files_form(group_id): """ % group_id, ] - F = html_sco_header.sco_footer() tf = TrivialFormulator( request.base_url, scu.get_request_args(), @@ -313,7 +308,11 @@ def etudarchive_import_files_form(group_id): ) if tf[0] == 0: - return "\n".join(H) + tf[1] + "" + F + return render_template( + "sco_page.j2", + title="Import de fichiers associés aux étudiants", + content="\n".join(H) + tf[1] + "", + ) # retrouve le semestre à partir du groupe: group = sco_groups.get_group(group_id) if tf[0] == -1: diff --git a/app/scodoc/sco_find_etud.py b/app/scodoc/sco_find_etud.py index eb3fb169..d0cd13bb 100644 --- a/app/scodoc/sco_find_etud.py +++ b/app/scodoc/sco_find_etud.py @@ -309,7 +309,7 @@ def search_etud_by_name(term: str) -> list: # ---------- Recherche sur plusieurs département -def search_etud_in_accessible_depts( +def search_etuds_in_accessible_depts( expnom=None, ) -> tuple[list[list[Identite]], list[str]]: """ @@ -330,14 +330,14 @@ def search_etud_in_accessible_depts( return result, accessible_depts -def table_etud_in_accessible_depts(expnom=None): +def table_etuds_in_accessible_depts(expnom=None): """ Page avec table étudiants trouvés, dans tous les departements. Attention: nous sommes ici au niveau de ScoDoc, pas dans un département """ - result, accessible_depts = search_etud_in_accessible_depts(expnom=expnom) + result, accessible_depts = search_etuds_in_accessible_depts(expnom=expnom) H = [ - f"""

+ f"""

Recherche multi-département de "{expnom}"

""", ] @@ -362,7 +362,7 @@ def table_etud_in_accessible_depts(expnom=None): rows=rows, html_sortable=True, html_class="table_leftalign", - # table_id="etud_in_accessible_depts", + table_id="etuds_in_accessible_depts", ) H.append('
') @@ -382,8 +382,10 @@ def table_etud_in_accessible_depts(expnom=None):
""" ) - return ( - html_sco_header.scodoc_top_html_header(page_title="Choix d'un étudiant") - + "\n".join(H) - + html_sco_header.standard_html_footer() + return render_template( + "base.j2", + title="Choix d'un étudiant", + content="\n".join(H), + javascripts=["DataTables/datatables.min.js"], + cssstyles=["DataTables/datatables.min.css"], ) diff --git a/app/scodoc/sco_moduleimpl_inscriptions.py b/app/scodoc/sco_moduleimpl_inscriptions.py index 4e2e8674..8ea83d7b 100644 --- a/app/scodoc/sco_moduleimpl_inscriptions.py +++ b/app/scodoc/sco_moduleimpl_inscriptions.py @@ -46,7 +46,6 @@ from app.models import ( UniteEns, Scolog, ) -from app.scodoc import html_sco_header from app.scodoc import htmlutils from app.scodoc import sco_cache from app.scodoc import codes_cursus @@ -82,12 +81,8 @@ def moduleimpl_inscriptions_edit( # -- check permission (and lock) if not modimpl.can_change_inscriptions(): return # can_change_inscriptions raises exception - header = html_sco_header.sco_header( - page_title="Inscription au module", - ) - footer = html_sco_header.sco_footer() + H = [ - header, f"""

Inscriptions au module str: diff --git a/app/scodoc/sco_page_etud.py b/app/scodoc/sco_page_etud.py index 162c0af8..c2f604c3 100644 --- a/app/scodoc/sco_page_etud.py +++ b/app/scodoc/sco_page_etud.py @@ -47,7 +47,6 @@ from app.models import ( ) from app.scodoc import ( codes_cursus, - html_sco_header, htmlutils, sco_archives_etud, sco_bac, @@ -628,8 +627,10 @@ def fiche_etud(etudid=None):

""" ) - header = html_sco_header.sco_header( - page_title=f"Fiche étudiant {etud.nomprenom}", + return render_template( + "sco_page.j2", + content=tmpl % info, + title=f"Fiche étudiant {etud.nomprenom}", cssstyles=[ "libjs/jQuery-tagEditor/jquery.tag-editor.css", "css/jury_but.css", @@ -644,7 +645,6 @@ def fiche_etud(etudid=None): "js/etud_debouche.js", ], ) - return header + tmpl % info + html_sco_header.sco_footer() def _format_adresse(adresse: Adresse | None) -> dict: @@ -874,10 +874,6 @@ def etud_info_html(etudid, with_photo="1", debug=False): H += "
" if debug: - return ( - html_sco_header.standard_html_header() - + H - + html_sco_header.standard_html_footer() - ) - else: - return H + return render_template("sco_page.j2", title="debug", content=H) + + return H diff --git a/app/static/css/scodoc.css b/app/static/css/scodoc.css index e147f51e..3f5f923b 100644 --- a/app/static/css/scodoc.css +++ b/app/static/css/scodoc.css @@ -483,7 +483,7 @@ span.dept_cache { color: rgb(194, 5, 5); } -div.table_etud_in_accessible_depts { +div.table_etuds_in_accessible_depts { margin-left: 3em; margin-bottom: 2em; } diff --git a/app/templates/babase.j2 b/app/templates/babase.j2 index 00a1a6da..544d3f4e 100644 --- a/app/templates/babase.j2 +++ b/app/templates/babase.j2 @@ -10,6 +10,10 @@ {%- endblock metas %} {%- block styles %} + + diff --git a/app/templates/base.j2 b/app/templates/base.j2 index 24341c4d..fd22d3ea 100644 --- a/app/templates/base.j2 +++ b/app/templates/base.j2 @@ -57,7 +57,7 @@ - + {% endblock %} @@ -67,7 +67,7 @@ {# application content needs to be provided in the app_content block #}
- {% block app_content %}{% endblock %} + {% block app_content %}{{ content | safe }}{% endblock %}