diff --git a/app/scodoc/gen_tables.py b/app/scodoc/gen_tables.py index 078017e8c..3791c8142 100644 --- a/app/scodoc/gen_tables.py +++ b/app/scodoc/gen_tables.py @@ -628,8 +628,6 @@ class GenTable(object): H.append( self.html_header or html_sco_header.sco_header( - context, - REQUEST, page_title=page_title, javascripts=javascripts, init_qtip=init_qtip, diff --git a/app/scodoc/html_sco_header.py b/app/scodoc/html_sco_header.py index 2401ee7cb..7381cc734 100644 --- a/app/scodoc/html_sco_header.py +++ b/app/scodoc/html_sco_header.py @@ -30,6 +30,8 @@ import html +from flask import g +from flask import request from flask_login import current_user import app.scodoc.sco_utils as scu @@ -136,10 +138,7 @@ def scodoc_top_html_header(page_title="ScoDoc: bienvenue"): # Header: def sco_header( - context, - REQUEST=None, # optional args - container=None, # objet qui a lancé la demande page_title="", # page title no_side_bar=False, # hide sidebar cssstyles=[], # additionals CSS sheets @@ -159,15 +158,13 @@ def sco_header( from app.scodoc.sco_formsemestre_status import formsemestre_page_title context = None # XXX TODO à enlever #context - # context est une instance de ZScolar. container est une instance qui "acquiert" ZScolar - # Add a HTTP header (can be used by Apache to log requests) - if REQUEST.AUTHENTICATED_USER: - REQUEST.RESPONSE.setHeader("X-ScoDoc-User", str(REQUEST.AUTHENTICATED_USER)) - - # Get more parameters from REQUEST - if not head_message and "head_message" in REQUEST.form: - head_message = REQUEST.form["head_message"] + # 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 VERSION.SCONAME, @@ -175,7 +172,7 @@ def sco_header( "ScoURL": scu.ScoURL(), "encoding": scu.SCO_ENCODING, "titrebandeau_mkup": "" + titrebandeau + "", - "authuser": str(REQUEST.AUTHENTICATED_USER), + "authuser": current_user.user_name, } if bodyOnLoad: params["bodyOnLoad_mkup"] = """onload="%s" """ % bodyOnLoad @@ -307,11 +304,11 @@ def sco_header( H.append(scu.CUSTOM_HTML_HEADER) # if not no_side_bar: - H.append(html_sidebar.sidebar(REQUEST)) + H.append(html_sidebar.sidebar()) H.append("""
""") # # Barre menu semestre: - H.append(formsemestre_page_title(context, REQUEST)) + H.append(formsemestre_page_title(context)) # Avertissement si mot de passe à changer if user_check: @@ -354,9 +351,7 @@ def html_sem_header( "Titre d'une page semestre avec lien vers tableau de bord" # sem now unused and thus optional... if with_page_header: - h = sco_header( - context, REQUEST, page_title="%s" % (page_title or title), **args - ) + h = sco_header(page_title="%s" % (page_title or title), **args) else: h = "" if with_h2: diff --git a/app/scodoc/html_sidebar.py b/app/scodoc/html_sidebar.py index a172df4f0..8bcdb487f 100644 --- a/app/scodoc/html_sidebar.py +++ b/app/scodoc/html_sidebar.py @@ -28,30 +28,32 @@ """ Génération de la "sidebar" (marge gauche des pages HTML) """ -from flask import url_for, g +from flask import url_for +from flask import g +from flask import request +from flask_login import current_user import app.scodoc.sco_utils as scu from app.scodoc import sco_preferences from app.scodoc.sco_permissions import Permission -def sidebar_common(REQUEST=None): +def sidebar_common(): "partie commune à toutes les sidebar" - authuser = REQUEST.AUTHENTICATED_USER params = { "ScoURL": scu.ScoURL(), "UsersURL": scu.UsersURL(), "NotesURL": scu.NotesURL(), "AbsencesURL": scu.AbsencesURL(), "LogoutURL": url_for("auth.logout"), - "authuser": str(authuser), + "authuser": current_user.user_name, } H = [ 'ScoDoc 8', '
%(authuser)s
déconnexion
' % params, - sidebar_dept(REQUEST), - """

Scolarité

+ sidebar_dept(), + """

Scolarité

Semestres
Programmes
Absences
@@ -59,14 +61,14 @@ def sidebar_common(REQUEST=None): % params, ] - if authuser.has_permission(Permission.ScoUsersAdmin) or authuser.has_permission( - Permission.ScoUsersView - ): + if current_user.has_permission( + Permission.ScoUsersAdmin + ) or current_user.has_permission(Permission.ScoUsersView): H.append( """Utilisateurs
""" % params ) - if authuser.has_permission(Permission.ScoChangePreferences): + if current_user.has_permission(Permission.ScoChangePreferences): H.append( """Paramétrage
""" % params @@ -75,7 +77,7 @@ def sidebar_common(REQUEST=None): return "".join(H) -def sidebar(REQUEST=None): +def sidebar(): "Main HTML page sidebar" # rewritten from legacy DTML code from app.scodoc import sco_abs @@ -86,7 +88,7 @@ def sidebar(REQUEST=None): "SCO_USER_MANUAL": scu.SCO_USER_MANUAL, } - H = ['