enhance sidebar

This commit is contained in:
Emmanuel Viennet 2021-09-10 21:12:59 +02:00
parent 245f954b05
commit 8589aab659
5 changed files with 46 additions and 51 deletions

View File

@ -83,22 +83,19 @@ def sidebar():
from app.scodoc import sco_abs from app.scodoc import sco_abs
from app.scodoc import sco_etud from app.scodoc import sco_etud
params = { params = {}
"ScoURL": scu.ScoURL(),
"SCO_USER_MANUAL": scu.SCO_USER_MANUAL,
}
H = ['<div class="sidebar">', sidebar_common()] H = [
f"""<div class="sidebar">
H.append( { sidebar_common() }
"""<div class="box-chercheetud">Chercher étudiant:<br/> <div class="box-chercheetud">Chercher étudiant:<br/>
<form method="get" id="form-chercheetud" action="%(ScoURL)s/search_etud_in_dept"> <form method="get" id="form-chercheetud"
<div><input type="text" size="12" id="in-expnom" name="expnom" spellcheck="false"></input></div> action="{ url_for('scolar.search_etud_in_dept', scodoc_dept=g.scodoc_dept) }">
</form></div> <div><input type="text" size="12" id="in-expnom" name="expnom" spellcheck="false"></input></div>
<div class="etud-insidebar"> </form></div>
""" <div class="etud-insidebar">
% params """
) ]
# ---- Il y-a-t-il un etudiant selectionné ? # ---- Il y-a-t-il un etudiant selectionné ?
etudid = None etudid = None
if request.method == "GET": if request.method == "GET":
@ -121,59 +118,50 @@ def sidebar():
% params % params
) )
if etud["cursem"]: if etud["cursem"]:
params["nbabs"], params["nbabsjust"] = sco_abs.get_abs_count( cur_sem = etud["cursem"]
etudid, etud["cursem"] nbabs, nbabsjust = sco_abs.get_abs_count(etudid, cur_sem)
) nbabsnj = nbabs - nbabsjust
params["nbabsnj"] = params["nbabs"] - params["nbabsjust"]
params["date_debut"] = etud["cursem"]["date_debut"]
params["date_fin"] = etud["cursem"]["date_fin"]
H.append( H.append(
"""<span title="absences du %(date_debut)s au %(date_fin)s">(1/2 j.)<br/>%(nbabsjust)s J., %(nbabsnj)s N.J.</span>""" f"""<span title="absences du { cur_sem["date_debut"] } au { cur_sem["date_fin"] }">(1/2 j.)
% params <br/>{ nbabsjust } J., { nbabsnj } N.J.</span>"""
) )
H.append("<ul>") H.append("<ul>")
if current_user.has_permission(Permission.ScoAbsChange): if current_user.has_permission(Permission.ScoAbsChange):
H.append( H.append(
f"""
<li><a href="{ url_for('absences.SignaleAbsenceEtud', scodoc_dept=g.scodoc_dept, etudid=etudid) }">Ajouter</a></li>
<li><a href="{ url_for('absences.JustifAbsenceEtud', scodoc_dept=g.scodoc_dept, etudid=etudid) }">Justifier</a></li>
<li><a href="{ url_for('absences.AnnuleAbsenceEtud', scodoc_dept=g.scodoc_dept, etudid=etudid) }">Supprimer</a></li>
""" """
<li> <a href="%(ScoURL)s/Absences/SignaleAbsenceEtud?etudid=%(etudid)s">Ajouter</a></li>
<li> <a href="%(ScoURL)s/Absences/JustifAbsenceEtud?etudid=%(etudid)s">Justifier</a></li>
<li> <a href="%(ScoURL)s/Absences/AnnuleAbsenceEtud?etudid=%(etudid)s">Supprimer</a></li>
"""
% params
) )
if sco_preferences.get_preference("handle_billets_abs"): if sco_preferences.get_preference("handle_billets_abs"):
H.append( H.append(
"""<li> <a href="%(ScoURL)s/Absences/listeBilletsEtud?etudid=%(etudid)s">Billets</a></li>""" f"""<li><a href="{ url_for('absences.listeBilletsEtud', scodoc_dept=g.scodoc_dept, etudid=etudid) }">Billets</a></li>"""
% params
) )
H.append( H.append(
f"""
<li><a href="{ url_for('absences.CalAbs', scodoc_dept=g.scodoc_dept, etudid=etudid) }">Calendrier</a></li>
<li><a href="{ url_for('absences.ListeAbsEtud', scodoc_dept=g.scodoc_dept, etudid=etudid) }">Liste</a></li>
</ul>
""" """
<li> <a href="%(ScoURL)s/Absences/CalAbs?etudid=%(etudid)s">Calendrier</a></li>
<li> <a href="%(ScoURL)s/Absences/ListeAbsEtud?etudid=%(etudid)s">Liste</a></li>
</ul>
"""
% params
) )
else: else:
pass # H.append("(pas d'étudiant en cours)") pass # H.append("(pas d'étudiant en cours)")
# --------- # ---------
H.append("</div>") # /etud-insidebar H.append("</div>") # /etud-insidebar
# Logo # Logo
scologo_img = scu.icontag("scologo_img")
H.append( H.append(
'<div class="logo-insidebar"><div class="logo-logo">%s</div>' % scologo_img f"""<div class="logo-insidebar">
<div class="sidebar-bottom"><a href="{ url_for( 'scolar.about', scodoc_dept=g.scodoc_dept ) }" class="sidebar">À propos</a><br/>
<a href="{ scu.SCO_USER_MANUAL }" target="_blank" class="sidebar">Aide</a>
</div></div>
<div class="logo-logo"><a href= { url_for( 'scolar.about', scodoc_dept=g.scodoc_dept ) }
">{ scu.icontag("scologo_img", no_size=True) }</a>
</div>
</div>
<!-- end of sidebar -->
"""
) )
H.append(
"""<div class="logo-logo"><a href="%(ScoURL)s/about" class="sidebar">A propos</a><br/>
<a href="%(SCO_USER_MANUAL)s" class="sidebar">Aide</a><br/>
</div></div>
</div> <!-- end of sidebar -->
"""
% params
) # '
#
return "".join(H) return "".join(H)

View File

@ -672,14 +672,14 @@ def graph_from_edges(edges, graph_name="mygraph"):
ICONSIZES = {} # name : (width, height) cache image sizes ICONSIZES = {} # name : (width, height) cache image sizes
def icontag(name, file_format="png", **attrs): def icontag(name, file_format="png", no_size=False, **attrs):
"""tag HTML pour un icone. """tag HTML pour un icone.
(dans les versions anterieures on utilisait Zope) (dans les versions anterieures on utilisait Zope)
Les icones sont des fichiers PNG dans .../static/icons Les icones sont des fichiers PNG dans .../static/icons
Si la taille (width et height) n'est pas spécifiée, lit l'image Si la taille (width et height) n'est pas spécifiée, lit l'image
pour la mesurer (et cache le résultat). pour la mesurer (et cache le résultat).
""" """
if ("width" not in attrs) or ("height" not in attrs): if (not no_size) and (("width" not in attrs) or ("height" not in attrs)):
if name not in ICONSIZES: if name not in ICONSIZES:
img_file = os.path.join( img_file = os.path.join(
Config.SCODOC_DIR, Config.SCODOC_DIR,

View File

@ -253,6 +253,13 @@ div.logo-insidebar {
div.logo-logo { div.logo-logo {
text-align: center ; text-align: center ;
} }
div.logo-logo img {
margin-top: 20px;
width: 100px;
}
div.sidebar-bottom {
margin-top: 10px;
}
div.etud_info_div { div.etud_info_div {
border: 2px solid gray; border: 2px solid gray;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.9 KiB

After

Width:  |  Height:  |  Size: 29 KiB

View File

@ -1,7 +1,7 @@
# -*- mode: python -*- # -*- mode: python -*-
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
SCOVERSION = "9.0.12" SCOVERSION = "9.0.13"
SCONAME = "ScoDoc" SCONAME = "ScoDoc"