Amélioration de l'affichage du temps restant pour les salles.
Ajout de fonctions dans 'date_tools' pour cela. Ajout des prototypes d'interface mis à jour.
This commit is contained in:
parent
560868a7b8
commit
81a8247d5a
29
app.py
29
app.py
@ -87,23 +87,36 @@ def free_rooms() :
|
|||||||
# Récupération des départements choisis à partir des données du formulaire :
|
# Récupération des départements choisis à partir des données du formulaire :
|
||||||
i = 0
|
i = 0
|
||||||
depts = list()
|
depts = list()
|
||||||
|
depts_str = "" # Noms des départements pour l'affichage
|
||||||
for d in dept_list :
|
for d in dept_list :
|
||||||
if i < len(dident_list) and d.ident == int(dident_list[i]) :
|
if i < len(dident_list) and d.ident == int(dident_list[i]) :
|
||||||
depts.append(d)
|
depts.append(d)
|
||||||
|
depts_str += d.name
|
||||||
|
if (i + 1) < len(dident_list) :
|
||||||
|
depts_str += ", "
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
hdelay = 1 #TODO : décalage horaire (pb de fuseau ?)
|
|
||||||
|
|
||||||
if time.localtime().tm_isdst != 0 :
|
|
||||||
hdelay = 2
|
|
||||||
|
|
||||||
ignore_list = ["salle non définie", "salle en Distanciel"]
|
ignore_list = ["salle non définie", "salle en Distanciel"]
|
||||||
|
|
||||||
date = dti.datetime(2022, 5, 5, 10, 30) #TODO : à changer
|
date = dti.datetime.now()
|
||||||
|
|
||||||
available_rooms = ro.getrooms(date, depts, ignore_list)
|
free_rooms = ro.getrooms(date, depts, ignore_list)
|
||||||
|
|
||||||
context = {"available_rooms":available_rooms, "hdelay":hdelay}
|
frooms_disp = dict() # Mise en forme des infos pour la page Web
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
for r in free_rooms :
|
||||||
|
remain_time_str = ""
|
||||||
|
if r.is_free :
|
||||||
|
remain_time_str = date_tools.remain_time(date, r.end)
|
||||||
|
else :
|
||||||
|
remain_time_str = date_tools.remain_time(date, r.start)
|
||||||
|
|
||||||
|
frooms_disp[r.name] = {"start":date_tools.hour_disp(r.start),
|
||||||
|
"end":date_tools.hour_disp(r.end),
|
||||||
|
"rtime":remain_time_str}
|
||||||
|
|
||||||
|
context = {"free_rooms":free_rooms, "frooms_disp":frooms_disp, "depts_str":depts_str}
|
||||||
|
|
||||||
url_for("static", filename="style.css")
|
url_for("static", filename="style.css")
|
||||||
return render_template("free-rooms.html", **context)
|
return render_template("free-rooms.html", **context)
|
@ -65,6 +65,7 @@ def bissextile(year) :
|
|||||||
|
|
||||||
return (year % 4 == 0 and year % 100 != 0) or year % 400 == 0
|
return (year % 4 == 0 and year % 100 != 0) or year % 400 == 0
|
||||||
|
|
||||||
|
|
||||||
def month_days(month, year) :
|
def month_days(month, year) :
|
||||||
"""
|
"""
|
||||||
Renvoie le nombre de jours dans le mois 'month'.
|
Renvoie le nombre de jours dans le mois 'month'.
|
||||||
@ -125,3 +126,58 @@ def date_input() :
|
|||||||
minute = int(input("Entrer les minutes.\n> "))
|
minute = int(input("Entrer les minutes.\n> "))
|
||||||
|
|
||||||
return datetime.datetime(year, month, day, hour, minute)
|
return datetime.datetime(year, month, day, hour, minute)
|
||||||
|
|
||||||
|
|
||||||
|
def hour_disp(time) :
|
||||||
|
"""
|
||||||
|
Convertit une heure au format datetime
|
||||||
|
en une chaîne de caractères.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
time : datetime.datetime
|
||||||
|
Heure au format datetime.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
time_str : str
|
||||||
|
Heure en chaîne de caractères.
|
||||||
|
"""
|
||||||
|
|
||||||
|
time_str = str(time.hour) + ":"
|
||||||
|
|
||||||
|
if time.minute < 10 : # Ajout du zéro au début du nombre de minutes
|
||||||
|
time_str += "0" + str(time.minute)
|
||||||
|
else :
|
||||||
|
time_str += str(time.minute)
|
||||||
|
|
||||||
|
return time_str
|
||||||
|
|
||||||
|
|
||||||
|
def remain_time(date, rdate) :
|
||||||
|
"""
|
||||||
|
Détermine le temps restant avant
|
||||||
|
la fin/le début de disponibilité d'une salle.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
date : datetime.datetime
|
||||||
|
Date choisie au format datetime.
|
||||||
|
rdate : datetime.datetime
|
||||||
|
Date de la salle au format datetime.
|
||||||
|
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
remain_time_str : str
|
||||||
|
Temps restant.
|
||||||
|
"""
|
||||||
|
|
||||||
|
deltasec = rdate.timestamp() - date.timestamp()
|
||||||
|
remain_time_str = str(int(deltasec / 60 + 0.5)) + " minutes"
|
||||||
|
if deltasec / 60 + 0.5 >= 60 : # Conversion en heures:minutes si les minutes dépassent 60
|
||||||
|
deltasec = minutes_convert(deltasec / 60 + 0.5)
|
||||||
|
remain_time_str = str(deltasec[0]) + " heures"
|
||||||
|
if deltasec[1] > 0 :
|
||||||
|
remain_time_str += " " + str(deltasec[1]) + " minutes"
|
||||||
|
|
||||||
|
return remain_time_str
|
16
main_cli.py
16
main_cli.py
@ -95,13 +95,7 @@ def main() :
|
|||||||
for room in available_rooms :
|
for room in available_rooms :
|
||||||
if room.name in favorites or len(favorites) == 0 : # TODO : Changer le comportement de ce 'if' : il faudrait afficher toutes les salles, mais d'abord les favorites
|
if room.name in favorites or len(favorites) == 0 : # TODO : Changer le comportement de ce 'if' : il faudrait afficher toutes les salles, mais d'abord les favorites
|
||||||
if room.is_free :
|
if room.is_free :
|
||||||
deltasec = room.end.timestamp() - date.timestamp()
|
remain_time_str = date_tools.remain_time(date, room.end)
|
||||||
remain_time_str = str(int(deltasec / 60 + 0.5)) + " minutes"
|
|
||||||
if deltasec / 60 + 0.5 >= 60 : # Conversion en heures:minutes si les minutes dépassent 60
|
|
||||||
deltasec = date_tools.minutes_convert(deltasec / 60 + 0.5)
|
|
||||||
remain_time_str = str(deltasec[0]) + " heures"
|
|
||||||
if deltasec[1] > 0 :
|
|
||||||
remain_time_str += " " + str(deltasec[1]) + " minutes"
|
|
||||||
|
|
||||||
if room.end.hour == 23 and room.end.minute == 59 and room.end.second == 59 :
|
if room.end.hour == 23 and room.end.minute == 59 and room.end.second == 59 :
|
||||||
print(" - " + room.name)
|
print(" - " + room.name)
|
||||||
@ -113,13 +107,7 @@ def main() :
|
|||||||
for room in available_rooms :
|
for room in available_rooms :
|
||||||
if room.name in favorites or len(favorites) == 0 :
|
if room.name in favorites or len(favorites) == 0 :
|
||||||
if not room.is_free :
|
if not room.is_free :
|
||||||
deltasec = room.start.timestamp() - date.timestamp()
|
remain_time_str = date_tools.remain_time(date, room.start)
|
||||||
remain_time_str = str(int(deltasec / 60 + 0.5)) + " minutes"
|
|
||||||
if deltasec / 60 + 0.5 >= 60 : # Conversion en heures:minutes si les minutes dépassent 60
|
|
||||||
deltasec = date_tools.minutes_convert(deltasec / 60 + 0.5)
|
|
||||||
remain_time_str = str(deltasec[0]) + " heures"
|
|
||||||
if deltasec[1] > 0 :
|
|
||||||
remain_time_str += " " + str(deltasec[1]) + " minutes"
|
|
||||||
|
|
||||||
if room.end.hour == 23 and room.end.minute == 59 and room.end.second == 59 :
|
if room.end.hour == 23 and room.end.minute == 59 and room.end.second == 59 :
|
||||||
print(" - " + room.name + " | Libre à " + str(room.start.hour) + ":" + str(room.start.minute) + " (dans " + remain_time_str + ")") # TODO : Obligé d'ajouter 1h (problème de fuseau horaire ?)
|
print(" - " + room.name + " | Libre à " + str(room.start.hour) + ":" + str(room.start.minute) + " (dans " + remain_time_str + ")") # TODO : Obligé d'ajouter 1h (problème de fuseau horaire ?)
|
||||||
|
BIN
prototypes/interface/Schéma interface.odg
Normal file
BIN
prototypes/interface/Schéma interface.odg
Normal file
Binary file not shown.
BIN
prototypes/interface/Schéma interface.pdf
Normal file
BIN
prototypes/interface/Schéma interface.pdf
Normal file
Binary file not shown.
@ -30,8 +30,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
main {
|
main {
|
||||||
/*display: flex;
|
display: flex;
|
||||||
flex-direction: row;*/
|
flex-direction: column;
|
||||||
line-height: 1.7;
|
line-height: 1.7;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,14 +9,18 @@
|
|||||||
<body>
|
<body>
|
||||||
{% include "base.html" %}
|
{% include "base.html" %}
|
||||||
<main>
|
<main>
|
||||||
Les salles suivantes sont disponibles actuellement :
|
Départements sélectionnés :
|
||||||
|
<b>{{ depts_str }}</b>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<h1>Disponibles maintenant</h1>
|
||||||
<div class="flex-container">
|
<div class="flex-container">
|
||||||
<ul>
|
<ul>
|
||||||
{% for room in available_rooms : %}
|
{% for room in free_rooms : %}
|
||||||
{% if room.is_free : %}
|
{% if room.is_free : %}
|
||||||
<dt>{{ room.name }}
|
<dt>{{ room.name }}
|
||||||
{% if not(room.end.hour == 23 and room.end.minute == 59 and room.end.second == 59) : %}
|
{% if not(room.end.hour == 23 and room.end.minute == 59 and room.end.second == 59) : %}
|
||||||
<br><span class=details>Occupée à : {{ room.end.hour + hdelay }}:{{ room.end.minute }}</span>
|
<br><span class=details>Jusqu'à {{ frooms_disp[room.name]["end"] }} (dans {{ frooms_disp[room.name]["rtime"] }})</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</dt>
|
</dt>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -24,16 +28,16 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
Les salles suivantes seront disponibles prochainement :
|
<h1>Disponibles prochainement</h1>
|
||||||
<div class="flex-container">
|
<div class="flex-container">
|
||||||
<ul>
|
<ul>
|
||||||
{% for room in available_rooms : %}
|
{% for room in free_rooms : %}
|
||||||
{% if not room.is_free : %}
|
{% if not room.is_free : %}
|
||||||
<dt>{{ room.name }}
|
<dt>{{ room.name }}
|
||||||
{% if room.end.hour == 23 and room.end.minute == 59 and room.end.second == 59 : %}
|
{% if room.end.hour == 23 and room.end.minute == 59 and room.end.second == 59 : %}
|
||||||
<br><span class=details>Libre à : {{ room.start.hour + hdelay }}:{{ room.start.minute + hdelay }}</span>
|
<br><span class=details>À {{ frooms_disp[room.name]["start"] }} (dans {{ frooms_disp[room.name]["rtime"] }})</span>
|
||||||
{% else %}
|
{% else %}
|
||||||
<br><span class=details>Libre de {{ room.start.hour + hdelay }}:{{ room.start.minute + hdelay }} à {{ room.end.hour + hdelay }}:{{ room.end.minute + hdelay }}</span>
|
<br><span class=details>De {{ frooms_disp[room.name]["start"] }} à {{ frooms_disp[room.name]["end"] }} (dans {{ frooms_disp[room.name]["rtime"] }})</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</dt>
|
</dt>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
Loading…
Reference in New Issue
Block a user