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_etud
params = {
"ScoURL": scu.ScoURL(),
"SCO_USER_MANUAL": scu.SCO_USER_MANUAL,
}
params = {}
H = ['<div class="sidebar">', sidebar_common()]
H.append(
"""<div class="box-chercheetud">Chercher étudiant:<br/>
<form method="get" id="form-chercheetud" action="%(ScoURL)s/search_etud_in_dept">
H = [
f"""<div class="sidebar">
{ sidebar_common() }
<div class="box-chercheetud">Chercher étudiant:<br/>
<form method="get" id="form-chercheetud"
action="{ url_for('scolar.search_etud_in_dept', scodoc_dept=g.scodoc_dept) }">
<div><input type="text" size="12" id="in-expnom" name="expnom" spellcheck="false"></input></div>
</form></div>
<div class="etud-insidebar">
"""
% params
)
]
# ---- Il y-a-t-il un etudiant selectionné ?
etudid = None
if request.method == "GET":
@ -121,59 +118,50 @@ def sidebar():
% params
)
if etud["cursem"]:
params["nbabs"], params["nbabsjust"] = sco_abs.get_abs_count(
etudid, etud["cursem"]
)
params["nbabsnj"] = params["nbabs"] - params["nbabsjust"]
params["date_debut"] = etud["cursem"]["date_debut"]
params["date_fin"] = etud["cursem"]["date_fin"]
cur_sem = etud["cursem"]
nbabs, nbabsjust = sco_abs.get_abs_count(etudid, cur_sem)
nbabsnj = nbabs - nbabsjust
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>"""
% params
f"""<span title="absences du { cur_sem["date_debut"] } au { cur_sem["date_fin"] }">(1/2 j.)
<br/>{ nbabsjust } J., { nbabsnj } N.J.</span>"""
)
H.append("<ul>")
if current_user.has_permission(Permission.ScoAbsChange):
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"):
H.append(
"""<li> <a href="%(ScoURL)s/Absences/listeBilletsEtud?etudid=%(etudid)s">Billets</a></li>"""
% params
f"""<li><a href="{ url_for('absences.listeBilletsEtud', scodoc_dept=g.scodoc_dept, etudid=etudid) }">Billets</a></li>"""
)
H.append(
"""
<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>
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>
"""
% params
)
else:
pass # H.append("(pas d'étudiant en cours)")
# ---------
H.append("</div>") # /etud-insidebar
# Logo
scologo_img = scu.icontag("scologo_img")
H.append(
'<div class="logo-insidebar"><div class="logo-logo">%s</div>' % scologo_img
)
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/>
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> <!-- end of sidebar -->
<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 -->
"""
% params
) # '
#
)
return "".join(H)

View File

@ -672,14 +672,14 @@ def graph_from_edges(edges, graph_name="mygraph"):
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.
(dans les versions anterieures on utilisait Zope)
Les icones sont des fichiers PNG dans .../static/icons
Si la taille (width et height) n'est pas spécifiée, lit l'image
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:
img_file = os.path.join(
Config.SCODOC_DIR,

View File

@ -253,6 +253,13 @@ div.logo-insidebar {
div.logo-logo {
text-align: center ;
}
div.logo-logo img {
margin-top: 20px;
width: 100px;
}
div.sidebar-bottom {
margin-top: 10px;
}
div.etud_info_div {
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 -*-
# -*- coding: utf-8 -*-
SCOVERSION = "9.0.12"
SCOVERSION = "9.0.13"
SCONAME = "ScoDoc"