2020-09-26 16:19:37 +02:00
|
|
|
# -*- mode: python -*-
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# Gestion scolarite IUT
|
|
|
|
#
|
2022-01-01 14:49:42 +01:00
|
|
|
# Copyright (c) 1999 - 2022 Emmanuel Viennet. All rights reserved.
|
2020-09-26 16:19:37 +02:00
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
# Emmanuel Viennet emmanuel.viennet@viennet.net
|
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
2021-06-19 23:21:37 +02:00
|
|
|
"""HTML Header/Footer for ScoDoc pages
|
|
|
|
"""
|
|
|
|
|
2021-07-29 10:19:00 +02:00
|
|
|
import html
|
2021-02-03 22:00:41 +01:00
|
|
|
|
2022-02-28 11:47:39 +01:00
|
|
|
from flask import render_template
|
2021-07-29 16:31:15 +02:00
|
|
|
from flask import request
|
2021-07-03 23:35:32 +02:00
|
|
|
from flask_login import current_user
|
|
|
|
|
2021-06-19 23:21:37 +02:00
|
|
|
import app.scodoc.sco_utils as scu
|
2022-03-04 20:02:50 +01:00
|
|
|
from app import scodoc_flash_status_messages
|
2021-06-19 23:21:37 +02:00
|
|
|
from app.scodoc import html_sidebar
|
2021-08-21 17:07:44 +02:00
|
|
|
import sco_version
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
# Some constants:
|
|
|
|
|
|
|
|
# Multiselect menus are used on a few pages and not loaded by default
|
|
|
|
BOOTSTRAP_MULTISELECT_JS = [
|
|
|
|
"libjs/bootstrap-3.1.1-dist/js/bootstrap.min.js",
|
|
|
|
"libjs/bootstrap-multiselect/bootstrap-multiselect.js",
|
|
|
|
"libjs/purl.js",
|
|
|
|
]
|
|
|
|
|
|
|
|
BOOTSTRAP_MULTISELECT_CSS = [
|
|
|
|
"libjs/bootstrap-3.1.1-dist/css/bootstrap.min.css",
|
|
|
|
"libjs/bootstrap-3.1.1-dist/css/bootstrap-theme.min.css",
|
|
|
|
"libjs/bootstrap-multiselect/bootstrap-multiselect.css",
|
|
|
|
]
|
|
|
|
|
2021-06-13 18:29:53 +02:00
|
|
|
|
|
|
|
def standard_html_header():
|
|
|
|
"""Standard HTML header for pages outside depts"""
|
|
|
|
# not used in ZScolar, see sco_header
|
|
|
|
return """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
|
|
|
<html><head>
|
|
|
|
<title>ScoDoc: accueil</title>
|
|
|
|
<META http-equiv="Content-Type" content="text/html; charset=%s">
|
|
|
|
<META http-equiv="Content-Style-Type" content="text/css">
|
|
|
|
<META name="LANG" content="fr">
|
|
|
|
<META name="DESCRIPTION" content="ScoDoc: gestion scolarite">
|
|
|
|
|
2021-06-16 16:59:31 +02:00
|
|
|
<link href="/ScoDoc/static/css/scodoc.css" rel="stylesheet" type="text/css"/>
|
2021-06-13 18:29:53 +02:00
|
|
|
|
|
|
|
</head><body>%s""" % (
|
|
|
|
scu.SCO_ENCODING,
|
|
|
|
scu.CUSTOM_HTML_HEADER_CNX,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def standard_html_footer():
|
|
|
|
"""Le pied de page HTML de la page d'accueil."""
|
|
|
|
return """<p class="footer">
|
|
|
|
Problème de connexion (identifiant, mot de passe): <em>contacter votre responsable ou chef de département</em>.</p>
|
|
|
|
<p>Problèmes et suggestions sur le logiciel: <a href="mailto:%s">%s</a></p>
|
|
|
|
<p><em>ScoDoc est un logiciel libre développé par Emmanuel Viennet.</em></p>
|
|
|
|
</body></html>""" % (
|
|
|
|
scu.SCO_USERS_LIST,
|
|
|
|
scu.SCO_USERS_LIST,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2021-11-18 00:24:56 +01:00
|
|
|
_HTML_BEGIN = """<!DOCTYPE html>
|
|
|
|
<html lang="fr">
|
|
|
|
|
2021-06-13 18:29:53 +02:00
|
|
|
<head>
|
2021-11-18 00:24:56 +01:00
|
|
|
<meta charset="UTF-8">
|
|
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
2021-06-13 18:29:53 +02:00
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=%(encoding)s" />
|
|
|
|
<meta http-equiv="Content-Style-Type" content="text/css" />
|
|
|
|
<meta name="LANG" content="fr" />
|
|
|
|
<meta name="DESCRIPTION" content="ScoDoc" />
|
2021-11-18 00:24:56 +01:00
|
|
|
<title>%(page_title)s</title>
|
2021-06-13 18:29:53 +02:00
|
|
|
|
|
|
|
<link type="text/css" rel="stylesheet" href="/ScoDoc/static/libjs/jquery-ui-1.10.4.custom/css/smoothness/jquery-ui-1.10.4.custom.min.css" />
|
|
|
|
|
|
|
|
<link href="/ScoDoc/static/css/scodoc.css" rel="stylesheet" type="text/css" />
|
|
|
|
<link href="/ScoDoc/static/css/menu.css" rel="stylesheet" type="text/css" />
|
2021-09-15 22:13:04 +02:00
|
|
|
<script src="/ScoDoc/static/libjs/menu.js"></script>
|
|
|
|
<script src="/ScoDoc/static/libjs/sorttable.js"></script>
|
|
|
|
<script src="/ScoDoc/static/libjs/bubble.js"></script>
|
|
|
|
<script>
|
2021-06-13 18:29:53 +02:00
|
|
|
window.onload=function(){enableTooltips("gtrcontent")};
|
|
|
|
</script>
|
|
|
|
|
2021-09-15 22:13:04 +02:00
|
|
|
<script src="/ScoDoc/static/jQuery/jquery.js"></script>
|
|
|
|
<script src="/ScoDoc/static/jQuery/jquery-migrate-1.2.0.min.js"></script>
|
|
|
|
<script src="/ScoDoc/static/libjs/jquery.field.min.js"></script>
|
2021-06-13 18:29:53 +02:00
|
|
|
|
2021-09-15 22:13:04 +02:00
|
|
|
<script src="/ScoDoc/static/libjs/jquery-ui-1.10.4.custom/js/jquery-ui-1.10.4.custom.min.js"></script>
|
2021-06-13 18:29:53 +02:00
|
|
|
|
2021-09-15 22:13:04 +02:00
|
|
|
<script src="/ScoDoc/static/libjs/qtip/jquery.qtip-3.0.3.min.js"></script>
|
2021-06-13 18:29:53 +02:00
|
|
|
<link type="text/css" rel="stylesheet" href="/ScoDoc/static/libjs/qtip/jquery.qtip-3.0.3.min.css" />
|
|
|
|
|
2021-09-15 22:13:04 +02:00
|
|
|
<script src="/ScoDoc/static/js/scodoc.js"></script>
|
|
|
|
<script src="/ScoDoc/static/js/etud_info.js"></script>
|
2021-06-13 18:29:53 +02:00
|
|
|
"""
|
|
|
|
|
|
|
|
|
2021-07-29 10:19:00 +02:00
|
|
|
def scodoc_top_html_header(page_title="ScoDoc: bienvenue"):
|
2021-06-13 18:29:53 +02:00
|
|
|
H = [
|
2021-07-29 10:19:00 +02:00
|
|
|
_HTML_BEGIN % {"page_title": page_title, "encoding": scu.SCO_ENCODING},
|
2021-12-04 21:06:32 +01:00
|
|
|
"""</head><body id="gtrcontent">""",
|
2021-06-13 18:29:53 +02:00
|
|
|
scu.CUSTOM_HTML_HEADER_CNX,
|
|
|
|
]
|
|
|
|
return "\n".join(H)
|
|
|
|
|
|
|
|
|
2020-09-26 16:19:37 +02:00
|
|
|
# Header:
|
|
|
|
def sco_header(
|
|
|
|
# optional args
|
|
|
|
page_title="", # page title
|
|
|
|
no_side_bar=False, # hide sidebar
|
|
|
|
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)
|
|
|
|
user_check=True, # verifie passwords temporaires
|
|
|
|
):
|
|
|
|
"Main HTML page header for ScoDoc"
|
2021-06-19 23:21:37 +02:00
|
|
|
from app.scodoc.sco_formsemestre_status import formsemestre_page_title
|
2020-09-26 16:19:37 +02:00
|
|
|
|
2022-03-04 20:02:50 +01:00
|
|
|
scodoc_flash_status_messages()
|
|
|
|
|
2021-07-29 16:31:15 +02:00
|
|
|
# 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", "")
|
2020-09-26 16:19:37 +02:00
|
|
|
params = {
|
2021-08-21 17:07:44 +02:00
|
|
|
"page_title": page_title or sco_version.SCONAME,
|
2020-09-26 16:19:37 +02:00
|
|
|
"no_side_bar": no_side_bar,
|
2021-06-15 12:34:33 +02:00
|
|
|
"ScoURL": scu.ScoURL(),
|
2021-02-04 20:02:44 +01:00
|
|
|
"encoding": scu.SCO_ENCODING,
|
2020-09-26 16:19:37 +02:00
|
|
|
"titrebandeau_mkup": "<td>" + titrebandeau + "</td>",
|
2021-07-29 16:31:15 +02:00
|
|
|
"authuser": current_user.user_name,
|
2020-09-26 16:19:37 +02:00
|
|
|
}
|
|
|
|
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 = [
|
2021-09-15 22:13:04 +02:00
|
|
|
"""<!DOCTYPE html><html lang="fr">
|
2020-09-26 16:19:37 +02:00
|
|
|
<head>
|
2021-09-15 22:13:04 +02:00
|
|
|
<meta charset="utf-8"/>
|
2020-09-26 16:19:37 +02:00
|
|
|
<title>%(page_title)s</title>
|
|
|
|
<meta name="LANG" content="fr" />
|
|
|
|
<meta name="DESCRIPTION" content="ScoDoc" />
|
|
|
|
|
|
|
|
"""
|
|
|
|
% params
|
|
|
|
]
|
|
|
|
# jQuery UI
|
2021-12-04 21:06:32 +01:00
|
|
|
# can modify loaded theme here
|
|
|
|
H.append(
|
|
|
|
'<link type="text/css" rel="stylesheet" href="/ScoDoc/static/libjs/jquery-ui-1.10.4.custom/css/smoothness/jquery-ui-1.10.4.custom.min.css" />\n'
|
|
|
|
)
|
2020-09-26 16:19:37 +02:00
|
|
|
if init_google_maps:
|
|
|
|
# It may be necessary to add an API key:
|
2021-09-15 22:13:04 +02:00
|
|
|
H.append('<script src="https://maps.google.com/maps/api/js"></script>')
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
# Feuilles de style additionnelles:
|
|
|
|
for cssstyle in cssstyles:
|
|
|
|
H.append(
|
|
|
|
"""<link type="text/css" rel="stylesheet" href="/ScoDoc/static/%s" />\n"""
|
|
|
|
% cssstyle
|
|
|
|
)
|
|
|
|
|
|
|
|
H.append(
|
|
|
|
"""
|
|
|
|
<link href="/ScoDoc/static/css/scodoc.css" rel="stylesheet" type="text/css" />
|
|
|
|
<link href="/ScoDoc/static/css/menu.css" rel="stylesheet" type="text/css" />
|
|
|
|
<link href="/ScoDoc/static/css/gt_table.css" rel="stylesheet" type="text/css" />
|
|
|
|
|
2021-09-15 22:13:04 +02:00
|
|
|
<script src="/ScoDoc/static/libjs/menu.js"></script>
|
|
|
|
<script src="/ScoDoc/static/libjs/bubble.js"></script>
|
|
|
|
<script>
|
2020-09-26 16:19:37 +02:00
|
|
|
window.onload=function(){enableTooltips("gtrcontent")};
|
2021-06-21 14:40:58 +02:00
|
|
|
|
|
|
|
var SCO_URL="%(ScoURL)s";
|
2020-09-26 16:19:37 +02:00
|
|
|
</script>"""
|
|
|
|
% params
|
|
|
|
)
|
|
|
|
|
|
|
|
# jQuery
|
2021-12-04 21:06:32 +01:00
|
|
|
H.append(
|
|
|
|
"""<script src="/ScoDoc/static/jQuery/jquery.js"></script>
|
|
|
|
"""
|
|
|
|
)
|
|
|
|
H.append('<script src="/ScoDoc/static/libjs/jquery.field.min.js"></script>')
|
2020-09-26 16:19:37 +02:00
|
|
|
# qTip
|
|
|
|
if init_qtip:
|
|
|
|
H.append(
|
2021-09-15 22:13:04 +02:00
|
|
|
'<script src="/ScoDoc/static/libjs/qtip/jquery.qtip-3.0.3.min.js"></script>'
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
H.append(
|
|
|
|
'<link type="text/css" rel="stylesheet" href="/ScoDoc/static/libjs/qtip/jquery.qtip-3.0.3.min.css" />'
|
|
|
|
)
|
|
|
|
|
2021-12-04 21:06:32 +01:00
|
|
|
H.append(
|
|
|
|
'<script src="/ScoDoc/static/libjs/jquery-ui-1.10.4.custom/js/jquery-ui-1.10.4.custom.min.js"></script>'
|
|
|
|
)
|
|
|
|
|
|
|
|
H.append('<script src="/ScoDoc/static/js/scodoc.js"></script>')
|
2020-09-26 16:19:37 +02:00
|
|
|
if init_google_maps:
|
|
|
|
H.append(
|
2021-09-15 22:13:04 +02:00
|
|
|
'<script src="/ScoDoc/static/libjs/jquery.ui.map.full.min.js"></script>'
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
if init_datatables:
|
|
|
|
H.append(
|
|
|
|
'<link rel="stylesheet" type="text/css" href="/ScoDoc/static/DataTables/datatables.min.css"/>'
|
|
|
|
)
|
2021-09-15 22:13:04 +02:00
|
|
|
H.append('<script src="/ScoDoc/static/DataTables/datatables.min.js"></script>')
|
2022-03-20 23:12:30 +01:00
|
|
|
# H.append(
|
|
|
|
# '<link href="/ScoDoc/static/css/tooltip.css" rel="stylesheet" type="text/css" />'
|
|
|
|
# )
|
2020-09-26 16:19:37 +02:00
|
|
|
# JS additionels
|
|
|
|
for js in javascripts:
|
2021-09-15 22:13:04 +02:00
|
|
|
H.append("""<script src="/ScoDoc/static/%s"></script>\n""" % js)
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
H.append(
|
2021-09-15 22:13:04 +02:00
|
|
|
"""<style>
|
2021-12-04 21:06:32 +01:00
|
|
|
#gtrcontent {
|
2020-09-26 16:19:37 +02:00
|
|
|
margin-left: %(margin_left)s;
|
|
|
|
height: 100%%;
|
|
|
|
margin-bottom: 10px;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
"""
|
|
|
|
% params
|
|
|
|
)
|
|
|
|
# Scripts de la page:
|
|
|
|
if scripts:
|
2021-09-15 22:13:04 +02:00
|
|
|
H.append("""<script>""")
|
2020-09-26 16:19:37 +02:00
|
|
|
for script in scripts:
|
|
|
|
H.append(script)
|
|
|
|
H.append("""</script>""")
|
|
|
|
|
|
|
|
H.append("</head>")
|
|
|
|
|
|
|
|
# Body et bandeau haut:
|
|
|
|
H.append("""<body %(bodyOnLoad_mkup)s>""" % params)
|
2021-02-04 20:02:44 +01:00
|
|
|
H.append(scu.CUSTOM_HTML_HEADER)
|
2020-09-26 16:19:37 +02:00
|
|
|
#
|
|
|
|
if not no_side_bar:
|
2021-07-29 16:31:15 +02:00
|
|
|
H.append(html_sidebar.sidebar())
|
2021-12-04 21:06:32 +01:00
|
|
|
H.append("""<div id="gtrcontent">""")
|
2022-02-28 11:47:39 +01:00
|
|
|
# En attendant le replacement complet de cette fonction,
|
|
|
|
# inclusion ici des messages flask
|
|
|
|
H.append(render_template("flashed_messages.html"))
|
2020-09-26 16:19:37 +02:00
|
|
|
#
|
|
|
|
# Barre menu semestre:
|
2021-08-21 00:24:51 +02:00
|
|
|
H.append(formsemestre_page_title())
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
# Avertissement si mot de passe à changer
|
|
|
|
if user_check:
|
2021-07-03 23:35:32 +02:00
|
|
|
if current_user.passwd_temp:
|
2020-09-26 16:19:37 +02:00
|
|
|
H.append(
|
|
|
|
"""<div class="passwd_warn">
|
|
|
|
Attention !<br/>
|
|
|
|
Vous avez reçu un mot de passe temporaire.<br/>
|
2021-07-03 23:35:32 +02:00
|
|
|
Vous devez le changer: <a href="%s/form_change_password?user_name=%s">cliquez ici</a>
|
2020-09-26 16:19:37 +02:00
|
|
|
</div>"""
|
2021-07-03 23:35:32 +02:00
|
|
|
% (scu.UsersURL, current_user.user_name)
|
2020-09-26 16:19:37 +02:00
|
|
|
)
|
|
|
|
#
|
|
|
|
if head_message:
|
2021-07-29 10:19:00 +02:00
|
|
|
H.append('<div class="head_message">' + html.escape(head_message) + "</div>")
|
2020-09-26 16:19:37 +02:00
|
|
|
#
|
|
|
|
# div pour affichage messages temporaires
|
|
|
|
H.append('<div id="sco_msg" class="head_message"></div>')
|
|
|
|
#
|
2021-07-12 15:13:10 +02:00
|
|
|
return "".join(H)
|
2020-09-26 16:19:37 +02:00
|
|
|
|
|
|
|
|
2021-07-29 10:19:00 +02:00
|
|
|
def sco_footer():
|
2021-01-01 18:40:47 +01:00
|
|
|
"""Main HTMl pages footer"""
|
2021-02-04 20:02:44 +01:00
|
|
|
return (
|
|
|
|
"""</div><!-- /gtrcontent -->""" + scu.CUSTOM_HTML_FOOTER + """</body></html>"""
|
|
|
|
)
|
2021-06-12 22:43:22 +02:00
|
|
|
|
|
|
|
|
2021-06-13 18:29:53 +02:00
|
|
|
def html_sem_header(
|
2022-01-07 15:11:24 +01:00
|
|
|
title, with_page_header=True, with_h2=True, page_title=None, **args
|
2021-06-13 18:29:53 +02:00
|
|
|
):
|
|
|
|
"Titre d'une page semestre avec lien vers tableau de bord"
|
|
|
|
# sem now unused and thus optional...
|
|
|
|
if with_page_header:
|
2021-07-29 16:31:15 +02:00
|
|
|
h = sco_header(page_title="%s" % (page_title or title), **args)
|
2021-06-13 18:29:53 +02:00
|
|
|
else:
|
|
|
|
h = ""
|
|
|
|
if with_h2:
|
|
|
|
return h + """<h2 class="formsemestre">%s</h2>""" % (title)
|
|
|
|
else:
|
|
|
|
return h
|