60 lines
1.7 KiB
Python
60 lines
1.7 KiB
Python
from colloscope.models import *
|
|
|
|
def table_colloscope(periode, heading=True, est_colle=True):
|
|
semaines = periode.range_semaines()
|
|
lundis = [periode.classe.week_beginning_date(n) for n in semaines]
|
|
creneaux = Slot.objects.filter(periode=periode, est_colle=est_colle)
|
|
jours = ["dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"]
|
|
|
|
s = ""
|
|
|
|
s += "<table>\n"
|
|
|
|
|
|
if heading:
|
|
s += "<tr>\n"
|
|
|
|
for th in ("Matière", "Jour", "Heure", "Colleur", "Salle"):
|
|
s += f"<th rowspan=2>{th}</th>\n"
|
|
|
|
for sem in semaines:
|
|
s +=f"<th>{sem}</th>\n"
|
|
|
|
s += "</tr>\n<tr>\n"
|
|
|
|
for lundi in lundis:
|
|
s += f"<th>{lundi.strftime('%d/%m/%y')}</th>\n"
|
|
|
|
s += "</tr>\n"
|
|
|
|
for i, c in enumerate(creneaux):
|
|
matiere = c.subject
|
|
jour = c.jour
|
|
heure = c.time
|
|
colleur = c.colleur
|
|
salle = c.room
|
|
|
|
s += "<tr>\n"
|
|
s += f"<td>{matiere.description}</td>\n"
|
|
s += f"<td>{jours[jour]}</td>\n"
|
|
s += f"<td>{heure.strftime('%H:%M')}</td>\n"
|
|
s += "<td>{} {}</td>\n".format("M." if colleur.civilite=="M" else "Mme", colleur.nom.upper())
|
|
s += f"<td>salle</td>\n"
|
|
|
|
for sem in semaines:
|
|
if Colle.objects.filter(creneau=c, semaine=sem).exists():
|
|
r = Colle.objects.get(creneau=c, semaine=sem)
|
|
groupes = r.groupes
|
|
content = ", ".join(g.description for g in groupes.all())
|
|
|
|
if r.is_edited():
|
|
s += f"<td class='modif'>{content}</td>\n"
|
|
else:
|
|
s += f"<td>{content}</td>\n"
|
|
else:
|
|
s += "<td></td>\n"
|
|
|
|
s += "</table>\n"
|
|
|
|
return s
|