Remplace anciens head_message par flash()

This commit is contained in:
IDK 2023-04-15 10:50:20 +02:00
parent bff7e40fd8
commit 88bf24ba79
8 changed files with 34 additions and 27 deletions

View File

@ -140,7 +140,7 @@ def sco_header(
init_google_maps=False, # Google maps init_google_maps=False, # Google maps
init_datatables=True, init_datatables=True,
titrebandeau="", # titre dans bandeau superieur titrebandeau="", # titre dans bandeau superieur
head_message="", # message action (petit cadre jaune en haut) head_message="", # message action (petit cadre jaune en haut) DEPRECATED
user_check=True, # verifie passwords temporaires user_check=True, # verifie passwords temporaires
etudid=None, etudid=None,
formsemestre_id=None, formsemestre_id=None,

View File

@ -342,11 +342,11 @@ def do_formsemestre_archive(
formsemestre, res, include_evaluations=True formsemestre, res, include_evaluations=True
) )
if table_html: if table_html:
flash(f"Moyennes archivées le {date}", category="info")
data = "\n".join( data = "\n".join(
[ [
html_sco_header.sco_header( html_sco_header.sco_header(
page_title=f"Moyennes archivées le {date}", page_title=f"Moyennes archivées le {date}",
head_message=f"Moyennes archivées le {date}",
no_side_bar=True, no_side_bar=True,
), ),
f'<h2 class="fontorange">Valeurs archivées le {date}</h2>', f'<h2 class="fontorange">Valeurs archivées le {date}</h2>',

View File

@ -30,7 +30,7 @@
les dossiers d'admission et autres pièces utiles. les dossiers d'admission et autres pièces utiles.
""" """
import flask import flask
from flask import url_for, render_template from flask import flash, render_template, url_for
from flask import g, request from flask import g, request
from flask_login import current_user from flask_login import current_user
@ -38,7 +38,6 @@ import app.scodoc.sco_utils as scu
from app.scodoc import sco_import_etuds from app.scodoc import sco_import_etuds
from app.scodoc import sco_groups from app.scodoc import sco_groups
from app.scodoc import sco_trombino from app.scodoc import sco_trombino
from app.scodoc import sco_excel
from app.scodoc import sco_archives from app.scodoc import sco_archives
from app.scodoc.sco_permissions import Permission from app.scodoc.sco_permissions import Permission
from app.scodoc.sco_exceptions import AccessDenied, ScoValueError from app.scodoc.sco_exceptions import AccessDenied, ScoValueError
@ -233,13 +232,9 @@ def etud_delete_archive(etudid, archive_name, dialog_confirmed=False):
) )
EtudsArchive.delete_archive(archive_id) EtudsArchive.delete_archive(archive_id)
flash("Archive supprimée")
return flask.redirect( return flask.redirect(
url_for( url_for("scolar.ficheEtud", scodoc_dept=g.scodoc_dept, etudid=etudid)
"scolar.ficheEtud",
scodoc_dept=g.scodoc_dept,
etudid=etudid,
head_message="Archive%20supprimée",
)
) )

View File

@ -32,7 +32,7 @@ import io
from zipfile import ZipFile from zipfile import ZipFile
import flask import flask
from flask import url_for, g, send_file, request from flask import flash, g, request, send_file, url_for
import app.scodoc.sco_utils as scu import app.scodoc.sco_utils as scu
from app import log from app import log
@ -692,8 +692,10 @@ def view_apo_csv_delete(etape_apo="", semset_id="", dialog_confirmed=False):
) )
if info: if info:
sco_etape_apogee.apo_csv_delete(info["archive_id"]) sco_etape_apogee.apo_csv_delete(info["archive_id"])
return flask.redirect(dest_url + "&head_message=Archive%20supprimée") flash("Archive supprimée")
return flask.redirect(dest_url + "&head_message=Archive%20inexistante") return flask.redirect(dest_url)
flash("Archive inexistante", category="error")
return flask.redirect(dest_url)
def view_apo_csv(etape_apo="", semset_id="", format="html"): def view_apo_csv(etape_apo="", semset_id="", format="html"):

View File

@ -1179,9 +1179,13 @@ def formsemestre_clone(formsemestre_id):
clone_evaluations=tf[2]["clone_evaluations"], clone_evaluations=tf[2]["clone_evaluations"],
clone_partitions=tf[2]["clone_partitions"], clone_partitions=tf[2]["clone_partitions"],
) )
flash("Nouveau semestre créé")
return flask.redirect( return flask.redirect(
"formsemestre_status?formsemestre_id=%s&head_message=Nouveau%%20semestre%%20créé" url_for(
% new_formsemestre_id "notes.formsemestre_status",
scodoc_dept=g.scodoc_dept,
formsemestre_id=new_formsemestre_id,
)
) )
@ -1364,7 +1368,8 @@ def formsemestre_delete2(formsemestre_id, dialog_confirmed=False):
) )
# Bon, s'il le faut... # Bon, s'il le faut...
do_formsemestre_delete(formsemestre_id) do_formsemestre_delete(formsemestre_id)
return flask.redirect(scu.ScoURL() + "?head_message=Semestre%20supprimé") flash("Semestre supprimé !")
return flask.redirect(scu.ScoURL())
def formsemestre_has_decisions_or_compensations(formsemestre: FormSemestre): def formsemestre_has_decisions_or_compensations(formsemestre: FormSemestre):

View File

@ -111,7 +111,7 @@ get_base_preferences(formsemestre_id)
""" """
import flask import flask
from flask import g, request, current_app from flask import flash, g, request
# from flask_login import current_user # from flask_login import current_user
@ -2115,7 +2115,8 @@ class BasePreferences(object):
for pref in self.prefs_definition: for pref in self.prefs_definition:
self.prefs[None][pref[0]] = tf[2][pref[0]] self.prefs[None][pref[0]] = tf[2][pref[0]]
self.save() self.save()
return flask.redirect(scu.ScoURL() + "?head_message=Préférences modifiées") flash("Préférences modifiées")
return flask.redirect(scu.ScoURL())
def build_tf_form(self, categories: list[str] = None, formsemestre_id: int = None): def build_tf_form(self, categories: list[str] = None, formsemestre_id: int = None):
"""Build list of elements for TrivialFormulator. """Build list of elements for TrivialFormulator.
@ -2287,7 +2288,8 @@ function set_global_pref(el, pref_name) {
if tf[0] == 0: if tf[0] == 0:
return "\n".join(H) + tf[1] + html_sco_header.sco_footer() return "\n".join(H) + tf[1] + html_sco_header.sco_footer()
elif tf[0] == -1: elif tf[0] == -1:
return flask.redirect(dest_url + "&head_message=Annulé") # cancel flash("Annulé")
return flask.redirect(dest_url)
else: else:
# Supprime pref locale du semestre (retour à la valeur globale) # Supprime pref locale du semestre (retour à la valeur globale)
if tf[2]["suppress"]: if tf[2]["suppress"]:
@ -2299,7 +2301,7 @@ function set_global_pref(el, pref_name) {
self.formsemestre_id, tf[2]["create_local"], cur_value self.formsemestre_id, tf[2]["create_local"], cur_value
) )
# Modifie valeurs: # Modifie valeurs:
for (pref_name, descr) in self.base_prefs.prefs_definition: for pref_name, descr in self.base_prefs.prefs_definition:
if ( if (
pref_name in tf[2] pref_name in tf[2]
and not descr.get("only_global", False) and not descr.get("only_global", False)
@ -2321,7 +2323,8 @@ function set_global_pref(el, pref_name) {
# done: change prefs and redirect to semestre status # done: change prefs and redirect to semestre status
destination = tf[2]["destination"] destination = tf[2]["destination"]
if destination == "done" or destination == "": if destination == "done" or destination == "":
return flask.redirect(dest_url + "&head_message=Préférences modifiées") flash("Préférences modifiées")
return flask.redirect(dest_url)
elif destination == "again": elif destination == "again":
return flask.redirect( return flask.redirect(
request.base_url + "?formsemestre_id=" + str(self.formsemestre_id) request.base_url + "?formsemestre_id=" + str(self.formsemestre_id)

View File

@ -1193,12 +1193,12 @@ def edit_moduleimpl_expr(moduleimpl_id):
sco_cache.invalidate_formsemestre( sco_cache.invalidate_formsemestre(
formsemestre_id=sem["formsemestre_id"] formsemestre_id=sem["formsemestre_id"]
) # > modif regle calcul ) # > modif regle calcul
flash("règle de calcul modifiée")
return flask.redirect( return flask.redirect(
url_for( url_for(
"notes.moduleimpl_status", "notes.moduleimpl_status",
scodoc_dept=g.scodoc_dept, scodoc_dept=g.scodoc_dept,
moduleimpl_id=moduleimpl_id, moduleimpl_id=moduleimpl_id,
head_message="règle%20de%20calcul%20modifiée",
) )
) )
@ -1321,7 +1321,6 @@ def delete_ue_expr(formsemestre_id: int, ue_id: int):
"notes.formsemestre_status", "notes.formsemestre_status",
scodoc_dept=g.scodoc_dept, scodoc_dept=g.scodoc_dept,
formsemestre_id=formsemestre_id, formsemestre_id=formsemestre_id,
head_message="formule supprimée",
) )
) )
@ -2009,7 +2008,7 @@ def formsemestre_bulletins_choice(
""", """,
] ]
H.append("""<select name="version" class="noprint">""") H.append("""<select name="version" class="noprint">""")
for (version, description) in ( for version, description in (
("short", "Version courte"), ("short", "Version courte"),
("selectedevals", "Version intermédiaire"), ("selectedevals", "Version intermédiaire"),
("long", "Version complète"), ("long", "Version complète"),

View File

@ -730,12 +730,12 @@ def doSuppressAnnotation(etudid, annotation_id):
logdb(cnx, method="SuppressAnnotation", etudid=etudid) logdb(cnx, method="SuppressAnnotation", etudid=etudid)
sco_etud.etud_annotations_delete(cnx, annotation_id) sco_etud.etud_annotations_delete(cnx, annotation_id)
flash("Annotation supprimée")
return flask.redirect( return flask.redirect(
url_for( url_for(
"scolar.ficheEtud", "scolar.ficheEtud",
scodoc_dept=g.scodoc_dept, scodoc_dept=g.scodoc_dept,
etudid=etudid, etudid=etudid,
head_message="Annotation%%20supprimée",
) )
) )
@ -895,6 +895,7 @@ sco_publish(
methods=["GET", "POST"], methods=["GET", "POST"],
) )
# Nouvel éditeur de partitions et groupe, @SebL Jul 2022 # Nouvel éditeur de partitions et groupe, @SebL Jul 2022
@bp.route("/partition_editor", methods=["GET", "POST"]) @bp.route("/partition_editor", methods=["GET", "POST"])
@scodoc @scodoc
@ -1801,7 +1802,8 @@ def etudident_delete(etudid, dialog_confirmed=False):
to_inval = [s["formsemestre_id"] for s in etud["sems"]] to_inval = [s["formsemestre_id"] for s in etud["sems"]]
for formsemestre_id in to_inval: for formsemestre_id in to_inval:
sco_cache.invalidate_formsemestre(formsemestre_id=formsemestre_id) # > sco_cache.invalidate_formsemestre(formsemestre_id=formsemestre_id) # >
return flask.redirect(scu.ScoURL() + r"?head_message=Etudiant%20supprimé") flash("Étudiant supprimé !")
return flask.redirect(scu.ScoURL())
@bp.route("/check_group_apogee") @bp.route("/check_group_apogee")
@ -2266,7 +2268,7 @@ def formsemestre_import_etud_admission(formsemestre_id, import_email=True):
) )
if changed_mails: if changed_mails:
H.append("<h3>Adresses mails modifiées:</h3>") H.append("<h3>Adresses mails modifiées:</h3>")
for (info, new_mail) in changed_mails: for info, new_mail in changed_mails:
H.append( H.append(
"%s: <tt>%s</tt> devient <tt>%s</tt><br>" "%s: <tt>%s</tt> devient <tt>%s</tt><br>"
% (info["nom"], info["email"], new_mail) % (info["nom"], info["email"], new_mail)
@ -2286,6 +2288,7 @@ sco_publish(
Permission.ScoEtudChangeAdr, Permission.ScoEtudChangeAdr,
) )
# --- Statistiques # --- Statistiques
@bp.route("/stat_bac") @bp.route("/stat_bac")
@scodoc @scodoc