1
0
forked from ScoDoc/ScoDoc

use check_version

This commit is contained in:
Emmanuel Viennet 2022-03-20 23:12:30 +01:00
parent d1af865ebd
commit 9a13470ff3
7 changed files with 28 additions and 12 deletions

View File

@ -250,6 +250,9 @@ def sco_header(
'<link rel="stylesheet" type="text/css" href="/ScoDoc/static/DataTables/datatables.min.css"/>'
)
H.append('<script src="/ScoDoc/static/DataTables/datatables.min.js"></script>')
# H.append(
# '<link href="/ScoDoc/static/css/tooltip.css" rel="stylesheet" type="text/css" />'
# )
# JS additionels
for js in javascripts:
H.append("""<script src="/ScoDoc/static/%s"></script>\n""" % js)

View File

@ -1170,8 +1170,10 @@ def formsemestre_tableau_modules(
H.append('<tr class="formsemestre_status%s">' % fontorange)
H.append(
'<td class="formsemestre_status_code"><a href="moduleimpl_status?moduleimpl_id=%s" title="%s" class="stdlink">%s</a></td>'
% (modimpl["moduleimpl_id"], mod_descr, mod.code)
f"""<td class="formsemestre_status_code""><a
href="{url_for('notes.moduleimpl_status',
scodoc_dept=g.scodoc_dept, moduleimpl_id=modimpl['moduleimpl_id'])}"
title="{mod_descr}" class="stdlink">{mod.code}</a></td>"""
)
H.append(
'<td class="scotext"><a href="moduleimpl_status?moduleimpl_id=%s" title="%s" class="formsemestre_status_link">%s</a></td>'

View File

@ -33,6 +33,8 @@ import json
import requests
import time
from flask import current_app
from app import log
import app.scodoc.sco_utils as scu
from sco_version import SCOVERSION, SCONAME
@ -43,7 +45,7 @@ def is_up_to_date() -> str:
"""
diag = ""
try:
response = requests.get(scu.SCO_UP2DATE)
response = requests.get(scu.SCO_UP2DATE + "/" + SCOVERSION)
except requests.exceptions.ConnectionError:
current_app.logger.debug("is_up_to_date: %s", diag)
return f"""<div>Attention: installation de {SCONAME} non fonctionnelle.</div>
@ -60,7 +62,6 @@ def is_up_to_date() -> str:
<a href="https://scodoc.org/GuideInstallDebian11/#informations-sur-les-flux-reseau">voir la documentation</a>.
</div>
"""
if response.status_code != 200:
current_app.logger.debug(
f"is_up_to_date: invalid response code ({response.status_code})"
@ -75,12 +76,16 @@ def is_up_to_date() -> str:
return f"""<div>Attention: réponse invalide de {scu.SCO_WEBSITE}</div>
<div>(erreur json).</div>"""
# nb: si de nouveaux paquets sont publiés chaque jour, le décalage ne sera jamais signalé.
# mais en régime "normal", on aura une alerte après 24h sans mise à jour.
days_since_last_package = (time.time() - infos["publication_time"]) / (24 * 60 * 60)
if (infos["version"] != SCOVERSION) and (days_since_last_package > 1.0):
if infos["status"] != "ok":
# problème coté serveur, ignore discrètement
log(f"is_up_to_date: server {infos['status']}")
return ""
if (SCOVERSION != infos["last_version"]) and (
(time.time() - infos["last_version_date"]) > (24 * 60 * 60)
):
# nouvelle version publiée depuis plus de 24h !
return f"""<div>Attention: {SCONAME} version ({SCOVERSION}) non à jour
({infos["version"]} disponible).</div>
({infos["last_version"]} disponible).</div>
<div>Contacter votre administrateur système
(<a href="https://scodoc.org/MisesAJour/">documentation</a>).
</div>

View File

@ -361,7 +361,7 @@ SCO_DEV_MAIL = "emmanuel.viennet@gmail.com" # SVP ne pas changer
# Adresse pour l'envoi des dumps (pour assistance technnique):
# ne pas changer (ou vous perdez le support)
SCO_DUMP_UP_URL = "https://scodoc.org/scodoc-installmgr/upload-dump"
SCO_UP2DATE = "https://scodoc.org/scodoc-installmgr/last_stable_version"
SCO_UP2DATE = "https://scodoc.org/scodoc-installmgr/check_version"
CSV_FIELDSEP = ";"
CSV_LINESEP = "\n"
CSV_MIMETYPE = "text/comma-separated-values"

View File

@ -2884,7 +2884,7 @@ div.othersemlist input {
div#update_warning {
/* display: none; */
display: none;
border: 1px solid red;
background-color: rgb(250,220,220);
margin: 3ex;

View File

@ -58,7 +58,12 @@ $(function () {
if (update_div) {
fetch('install_info').then(
response => response.text()
).then(text => update_div.innerHTML = text);
).then(text => {
update_div.innerHTML = text;
if (text) {
update_div.style.display = "block";
}
});
}
});

View File

@ -9,6 +9,7 @@
<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" />
<link type="text/css" rel="stylesheet" href="/ScoDoc/static/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" />
{% endblock %}