Modifie URL vers ressources statiques selon la version. Close #404

This commit is contained in:
Emmanuel Viennet 2022-06-26 17:54:44 +02:00
parent f7463cbbb0
commit 6b1d4d1afd
8 changed files with 85 additions and 96 deletions

View File

@ -211,6 +211,12 @@ def create_app(config_class=DevConfig):
app.config.from_object(config_class) app.config.from_object(config_class)
# Vérifie/crée lien sym pour les URL statiques
link_filename = f"{app.root_path}/static/links/{sco_version.SCOVERSION}"
if not os.path.exists(link_filename):
app.logger.info(f"creating symlink {link_filename}")
os.symlink("..", link_filename)
db.init_app(app) db.init_app(app)
migrate.init_app(app, db) migrate.init_app(app, db)
login.init_app(app) login.init_app(app)

View File

@ -163,7 +163,8 @@ class ModuleImplResults:
) )
# Notes en attente: (ne prend en compte que les inscrits, non démissionnaires) # Notes en attente: (ne prend en compte que les inscrits, non démissionnaires)
nb_att = sum( nb_att = sum(
evals_notes[str(evaluation.id)][inscrits_module] == scu.NOTES_ATTENTE evals_notes[str(evaluation.id)][list(inscrits_module)]
== scu.NOTES_ATTENTE
) )
self.evaluations_etat[evaluation.id] = EvaluationEtat( self.evaluations_etat[evaluation.id] = EvaluationEtat(
evaluation_id=evaluation.id, nb_attente=nb_att, is_complete=is_complete evaluation_id=evaluation.id, nb_attente=nb_att, is_complete=is_complete

View File

@ -59,35 +59,29 @@ BOOTSTRAP_MULTISELECT_CSS = [
def standard_html_header(): def standard_html_header():
"""Standard HTML header for pages outside depts""" """Standard HTML header for pages outside depts"""
# not used in ZScolar, see sco_header # 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"> return f"""<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head> <html><head>
<title>ScoDoc: accueil</title> <title>ScoDoc: accueil</title>
<META http-equiv="Content-Type" content="text/html; charset=%s"> <META http-equiv="Content-Type" content="text/html; charset={scu.SCO_ENCODING}">
<META http-equiv="Content-Style-Type" content="text/css"> <META http-equiv="Content-Style-Type" content="text/css">
<META name="LANG" content="fr"> <META name="LANG" content="fr">
<META name="DESCRIPTION" content="ScoDoc: gestion scolarite"> <META name="DESCRIPTION" content="ScoDoc: gestion scolarite">
<link href="/ScoDoc/static/css/scodoc.css" rel="stylesheet" type="text/css"/> <link href="{scu.STATIC_DIR}/css/scodoc.css" rel="stylesheet" type="text/css"/>
</head><body>%s""" % ( </head><body>{scu.CUSTOM_HTML_HEADER_CNX}"""
scu.SCO_ENCODING,
scu.CUSTOM_HTML_HEADER_CNX,
)
def standard_html_footer(): def standard_html_footer():
"""Le pied de page HTML de la page d'accueil.""" """Le pied de page HTML de la page d'accueil."""
return """<p class="footer"> return f"""<p class="footer">
Problème de connexion (identifiant, mot de passe): <em>contacter votre responsable ou chef de département</em>.</p> Problème de connexion (identifiant, mot de passe): <em>contacter votre responsable ou chef de département</em>.</p>
<p>Probl&egrave;mes et suggestions sur le logiciel: <a href="mailto:%s">%s</a></p> <p>Probl&egrave;mes et suggestions sur le logiciel: <a href="mailto:{scu.SCO_USERS_LIST}">{scu.SCO_USERS_LIST}</a></p>
<p><em>ScoDoc est un logiciel libre développé par Emmanuel Viennet.</em></p> <p><em>ScoDoc est un logiciel libre développé par Emmanuel Viennet.</em></p>
</body></html>""" % ( </body></html>"""
scu.SCO_USERS_LIST,
scu.SCO_USERS_LIST,
)
_HTML_BEGIN = """<!DOCTYPE html> _HTML_BEGIN = f"""<!DOCTYPE html>
<html lang="fr"> <html lang="fr">
<head> <head>
@ -100,27 +94,27 @@ _HTML_BEGIN = """<!DOCTYPE html>
<meta name="DESCRIPTION" content="ScoDoc" /> <meta name="DESCRIPTION" content="ScoDoc" />
<title>%(page_title)s</title> <title>%(page_title)s</title>
<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 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 href="/ScoDoc/static/css/scodoc.css" rel="stylesheet" type="text/css" /> <link href="{scu.STATIC_DIR}/css/scodoc.css" rel="stylesheet" type="text/css" />
<link href="/ScoDoc/static/css/menu.css" rel="stylesheet" type="text/css" /> <link href="{scu.STATIC_DIR}/css/menu.css" rel="stylesheet" type="text/css" />
<script src="/ScoDoc/static/libjs/menu.js"></script> <script src="{scu.STATIC_DIR}/libjs/menu.js"></script>
<script src="/ScoDoc/static/libjs/bubble.js"></script> <script src="{scu.STATIC_DIR}/libjs/bubble.js"></script>
<script> <script>
window.onload=function(){enableTooltips("gtrcontent")}; window.onload=function(){{enableTooltips("gtrcontent")}};
</script> </script>
<script src="/ScoDoc/static/jQuery/jquery.js"></script> <script src="{scu.STATIC_DIR}/jQuery/jquery.js"></script>
<script src="/ScoDoc/static/jQuery/jquery-migrate-1.2.0.min.js"></script> <script src="{scu.STATIC_DIR}/jQuery/jquery-migrate-1.2.0.min.js"></script>
<script src="/ScoDoc/static/libjs/jquery.field.min.js"></script> <script src="{scu.STATIC_DIR}/libjs/jquery.field.min.js"></script>
<script src="/ScoDoc/static/libjs/jquery-ui-1.10.4.custom/js/jquery-ui-1.10.4.custom.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="/ScoDoc/static/libjs/qtip/jquery.qtip-3.0.3.min.js"></script> <script src="{scu.STATIC_DIR}/libjs/qtip/jquery.qtip-3.0.3.min.js"></script>
<link type="text/css" rel="stylesheet" href="/ScoDoc/static/libjs/qtip/jquery.qtip-3.0.3.min.css" /> <link type="text/css" rel="stylesheet" href="{scu.STATIC_DIR}/libjs/qtip/jquery.qtip-3.0.3.min.css" />
<script src="/ScoDoc/static/js/scodoc.js"></script> <script src="{scu.STATIC_DIR}/js/scodoc.js"></script>
<script src="/ScoDoc/static/js/etud_info.js"></script> <script src="{scu.STATIC_DIR}/js/etud_info.js"></script>
""" """
@ -193,7 +187,7 @@ def sco_header(
# jQuery UI # jQuery UI
# can modify loaded theme here # can modify loaded theme here
H.append( 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' 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" />\n'
) )
if init_google_maps: if init_google_maps:
# It may be necessary to add an API key: # It may be necessary to add an API key:
@ -202,72 +196,65 @@ def sco_header(
# Feuilles de style additionnelles: # Feuilles de style additionnelles:
for cssstyle in cssstyles: for cssstyle in cssstyles:
H.append( H.append(
"""<link type="text/css" rel="stylesheet" href="/ScoDoc/static/%s" />\n""" f"""<link type="text/css" rel="stylesheet" href="{scu.STATIC_DIR}/{cssstyle}" />\n"""
% cssstyle
) )
H.append( H.append(
""" f"""
<link href="/ScoDoc/static/css/scodoc.css" rel="stylesheet" type="text/css" /> <link href="{scu.STATIC_DIR}/css/scodoc.css" rel="stylesheet" type="text/css" />
<link href="/ScoDoc/static/css/menu.css" rel="stylesheet" type="text/css" /> <link href="{scu.STATIC_DIR}/css/menu.css" rel="stylesheet" type="text/css" />
<link href="/ScoDoc/static/css/gt_table.css" rel="stylesheet" type="text/css" /> <link href="{scu.STATIC_DIR}/css/gt_table.css" rel="stylesheet" type="text/css" />
<script src="/ScoDoc/static/libjs/menu.js"></script> <script src="{scu.STATIC_DIR}/libjs/menu.js"></script>
<script src="/ScoDoc/static/libjs/bubble.js"></script> <script src="{scu.STATIC_DIR}/libjs/bubble.js"></script>
<script> <script>
window.onload=function(){enableTooltips("gtrcontent")}; window.onload=function(){{enableTooltips("gtrcontent")}};
var SCO_URL="%(ScoURL)s"; var SCO_URL="{scu.ScoURL()}";
</script>""" </script>"""
% params
) )
# jQuery # jQuery
H.append( H.append(
"""<script src="/ScoDoc/static/jQuery/jquery.js"></script> f"""<script src="{scu.STATIC_DIR}/jQuery/jquery.js"></script>
""" <script src="{scu.STATIC_DIR}/libjs/jquery.field.min.js"></script>"""
) )
H.append('<script src="/ScoDoc/static/libjs/jquery.field.min.js"></script>')
# qTip # qTip
if init_qtip: if init_qtip:
H.append( H.append(
'<script src="/ScoDoc/static/libjs/qtip/jquery.qtip-3.0.3.min.js"></script>' 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(
'<link type="text/css" rel="stylesheet" href="/ScoDoc/static/libjs/qtip/jquery.qtip-3.0.3.min.css" />'
) )
H.append( H.append(
'<script src="/ScoDoc/static/libjs/jquery-ui-1.10.4.custom/js/jquery-ui-1.10.4.custom.min.js"></script>' 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}/js/scodoc.js"></script>"""
) )
H.append('<script src="/ScoDoc/static/js/scodoc.js"></script>')
if init_google_maps: if init_google_maps:
H.append( H.append(
'<script src="/ScoDoc/static/libjs/jquery.ui.map.full.min.js"></script>' f'<script src="{scu.STATIC_DIR}/libjs/jquery.ui.map.full.min.js"></script>'
) )
if init_datatables: if init_datatables:
H.append( H.append(
'<link rel="stylesheet" type="text/css" href="/ScoDoc/static/DataTables/datatables.min.css"/>' 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('<script src="/ScoDoc/static/DataTables/datatables.min.js"></script>')
# H.append( # H.append(
# '<link href="/ScoDoc/static/css/tooltip.css" rel="stylesheet" type="text/css" />' # f'<link href="{scu.STATIC_DIR}/css/tooltip.css" rel="stylesheet" type="text/css" />'
# ) # )
# JS additionels # JS additionels
for js in javascripts: for js in javascripts:
H.append("""<script src="/ScoDoc/static/%s"></script>\n""" % js) H.append(f"""<script src="{scu.STATIC_DIR}/{js}"></script>\n""")
H.append( H.append(
"""<style> f"""<style>
#gtrcontent { #gtrcontent {{
margin-left: %(margin_left)s; margin-left: {params["margin_left"]};
height: 100%%; height: 100%%;
margin-bottom: 10px; margin-bottom: 10px;
} }}
</style> </style>
""" """
% params
) )
# Scripts de la page: # Scripts de la page:
if scripts: if scripts:
@ -296,12 +283,11 @@ def sco_header(
if user_check: if user_check:
if current_user.passwd_temp: if current_user.passwd_temp:
H.append( H.append(
"""<div class="passwd_warn"> f"""<div class="passwd_warn">
Attention !<br/> Attention !<br/>
Vous avez reçu un mot de passe temporaire.<br/> Vous avez reçu un mot de passe temporaire.<br/>
Vous devez le changer: <a href="%s/form_change_password?user_name=%s">cliquez ici</a> Vous devez le changer: <a href="{scu.UsersURL}/form_change_password?user_name={current_user.user_name}">cliquez ici</a>
</div>""" </div>"""
% (scu.UsersURL, current_user.user_name)
) )
# #
if head_message: if head_message:
@ -330,6 +316,6 @@ def html_sem_header(
else: else:
h = "" h = ""
if with_h2: if with_h2:
return h + """<h2 class="formsemestre">%s</h2>""" % (title) return h + f"""<h2 class="formsemestre">{title}</h2>"""
else: else:
return h return h

View File

@ -151,10 +151,8 @@ def trombino_html(groups_infos):
if sco_photos.etud_photo_is_local(t, size="small"): if sco_photos.etud_photo_is_local(t, size="small"):
foto = sco_photos.etud_photo_html(t, title="") foto = sco_photos.etud_photo_html(t, title="")
else: # la photo n'est pas immédiatement dispo else: # la photo n'est pas immédiatement dispo
foto = ( foto = f"""<span class="unloaded_img" id="{t["etudid"]
'<span class="unloaded_img" id="%s"><img border="0" height="90" alt="en cours" src="/ScoDoc/static/icons/loading.jpg"/></span>' }"><img border="0" height="90" alt="en cours" src="{scu.STATIC_DIR}/icons/loading.jpg"/></span>"""
% t["etudid"]
)
H.append( H.append(
'<a href="%s">%s</a>' '<a href="%s">%s</a>'
% ( % (

View File

@ -63,6 +63,8 @@ from app.scodoc import sco_exceptions
from app.scodoc import sco_xml from app.scodoc import sco_xml
import sco_version import sco_version
# le répertoire static, lié à chaque release pour éviter les problèmes de caches
STATIC_DIR = "/ScoDoc/static/links/" + sco_version.SCOVERSION
# ----- CALCUL ET PRESENTATION DES NOTES # ----- CALCUL ET PRESENTATION DES NOTES
NOTES_PRECISION = 1e-4 # evite eventuelles erreurs d'arrondis NOTES_PRECISION = 1e-4 # evite eventuelles erreurs d'arrondis
@ -957,12 +959,7 @@ def icontag(name, file_format="png", no_size=False, **attrs):
if "alt" not in attrs: if "alt" not in attrs:
attrs["alt"] = "logo %s" % name attrs["alt"] = "logo %s" % name
s = " ".join(['%s="%s"' % (k, attrs[k]) for k in attrs]) s = " ".join(['%s="%s"' % (k, attrs[k]) for k in attrs])
return '<img class="%s" %s src="/ScoDoc/static/icons/%s.%s" />' % ( return f'<img class="{name}" {s} src="{STATIC_DIR}/icons/{name}.{file_format}" />'
name,
s,
name,
file_format,
)
ICON_PDF = icontag("pdficon16x20_img", title="Version PDF") ICON_PDF = icontag("pdficon16x20_img", title="Version PDF")

View File

@ -10,7 +10,7 @@
{% include 'bul_head.html' %} {% include 'bul_head.html' %}
<releve-but></releve-but> <releve-but></releve-but>
<script src="/ScoDoc/static/js/releve-but.js"></script> <script src="{{sco.scu.STATIC_DIR}}/js/releve-but.js"></script>
{% include 'bul_foot.html' %} {% include 'bul_foot.html' %}

View File

@ -10,7 +10,7 @@
<ref-competences></ref-competences> <ref-competences></ref-competences>
<script src="/ScoDoc/static/js/ref_competences.js"></script> <script src="{{sco.scu.STATIC_DIR}}/js/ref_competences.js"></script>
<div class="help"> <div class="help">
Référentiel chargé le {{ref.scodoc_date_loaded.strftime("%d/%m/%Y à %H:%M") if ref.scodoc_date_loaded else ""}} à Référentiel chargé le {{ref.scodoc_date_loaded.strftime("%d/%m/%Y à %H:%M") if ref.scodoc_date_loaded else ""}} à

View File

@ -4,13 +4,14 @@
{% block styles %} {% block styles %}
{{super()}} {{super()}}
<link type="text/css" rel="stylesheet" <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" /> href="{{sco.scu.STATIC_DIR}}/libjs/jquery-ui-1.10.4.custom/css/smoothness/jquery-ui-1.10.4.custom.min.css" />
<link rel="stylesheet" href="/ScoDoc/static/css/scodoc.css"> <link rel="stylesheet" href="{{sco.scu.STATIC_DIR}}/css/scodoc.css">
<link href="/ScoDoc/static/css/menu.css" rel="stylesheet" type="text/css" /> <link href="{{sco.scu.STATIC_DIR}}/css/menu.css" rel="stylesheet" type="text/css" />
<link href="/ScoDoc/static/css/gt_table.css" rel="stylesheet" type="text/css" /> <link href="{{sco.scu.STATIC_DIR}}/css/gt_table.css" rel="stylesheet" type="text/css" />
<link type="text/css" rel="stylesheet" href="/ScoDoc/static/libjs/qtip/jquery.qtip-3.0.3.min.css" /> <link type="text/css" rel="stylesheet" href="{{sco.scu.STATIC_DIR}}/libjs/qtip/jquery.qtip-3.0.3.min.css" />
{# <link href="/ScoDoc/static/css/tooltip.css" rel="stylesheet" type="text/css" /> #} {#
<link rel="stylesheet" type="text/css" href="/ScoDoc/static/DataTables/datatables.min.css" /> <link href="{{sco.scu.STATIC_DIR}}/css/tooltip.css" rel="stylesheet" type="text/css" /> #}
<link rel="stylesheet" type="text/css" href="{{sco.scu.STATIC_DIR}}/DataTables/datatables.min.css" />
{% endblock %} {% endblock %}
{% block title %} {% block title %}
@ -46,16 +47,16 @@
{{ super() }} {{ super() }}
{{ moment.include_moment() }} {{ moment.include_moment() }}
{{ moment.lang(g.locale) }} {{ moment.lang(g.locale) }}
<script src="/ScoDoc/static/libjs/menu.js"></script> <script src="{{sco.scu.STATIC_DIR}}/libjs/menu.js"></script>
<script src="/ScoDoc/static/libjs/bubble.js"></script> <script src="{{sco.scu.STATIC_DIR}}/libjs/bubble.js"></script>
<script src="/ScoDoc/static/jQuery/jquery.js"></script> <script src="{{sco.scu.STATIC_DIR}}/jQuery/jquery.js"></script>
<script src="/ScoDoc/static/jQuery/jquery-migrate-1.2.0.min.js"></script> <script src="{{sco.scu.STATIC_DIR}}/jQuery/jquery-migrate-1.2.0.min.js"></script>
<script src="/ScoDoc/static/libjs/jquery.field.min.js"></script> <script src="{{sco.scu.STATIC_DIR}}/libjs/jquery.field.min.js"></script>
<script src="/ScoDoc/static/libjs/jquery-ui-1.10.4.custom/js/jquery-ui-1.10.4.custom.min.js"></script> <script src="{{sco.scu.STATIC_DIR}}/libjs/jquery-ui-1.10.4.custom/js/jquery-ui-1.10.4.custom.min.js"></script>
<script src="/ScoDoc/static/libjs/qtip/jquery.qtip-3.0.3.min.js"></script> <script src="{{sco.scu.STATIC_DIR}}/libjs/qtip/jquery.qtip-3.0.3.min.js"></script>
<script src="/ScoDoc/static/js/scodoc.js"></script> <script src="{{sco.scu.STATIC_DIR}}/js/scodoc.js"></script>
<script src="/ScoDoc/static/DataTables/datatables.min.js"></script> <script src="{{sco.scu.STATIC_DIR}}/DataTables/datatables.min.js"></script>
<script> <script>
window.onload = function () { enableTooltips("gtrcontent") }; window.onload = function () { enableTooltips("gtrcontent") };