|
import streamlit as st |
|
import datetime |
|
import pronotepy |
|
|
|
from pages import accueil, devoirs, edt, contenu |
|
|
|
def app(client): |
|
st.title('Accueil') |
|
st.write("Bienvenue sur la page d'accueil.") |
|
|
|
|
|
col1, col2 = st.columns([3, 2]) |
|
|
|
with col1: |
|
st.subheader("Emploi du temps") |
|
today = datetime.date.today() |
|
if not display_timetable_for_date(client, today): |
|
|
|
next_day = today + datetime.timedelta(days=1) |
|
st.warning(f"Aucun cours prévu pour aujourd'hui. Affichage pour le {next_day.strftime('%A %d %B')}.") |
|
display_timetable_for_date(client, next_day) |
|
|
|
if st.button('Voir l\'emploi du temps complet'): |
|
st.session_state.current_page = 'edt' |
|
st.rerun() |
|
|
|
with col2: |
|
st.subheader("Devoirs pour demain") |
|
tomorrow = datetime.date.today() + datetime.timedelta(days=1) |
|
homeworks = client.homework(tomorrow, tomorrow) |
|
if homeworks: |
|
for homework in homeworks: |
|
with st.expander(f"{'✅' if homework.done else '❌'} | {homework.subject.name}", expanded=False): |
|
st.markdown(f"**Description:** {homework.description}") |
|
st.markdown(f"**Statut:** {'✅ Fait' if homework.done else '❌ À faire'}") |
|
else: |
|
st.write("Pas de devoirs prévus pour demain.") |
|
|
|
if st.button('Voir tous les devoirs'): |
|
st.session_state.current_page = 'devoirs' |
|
st.rerun() |
|
|
|
def display_timetable_for_date(client, date): |
|
timetable = client.lessons(datetime.datetime.combine(date, datetime.datetime.min.time()), |
|
datetime.datetime.combine(date, datetime.datetime.min.time()) + datetime.timedelta(days=1)) |
|
sorted_timetable = sorted(timetable, key=lambda lesson: lesson.start) |
|
|
|
if sorted_timetable: |
|
for lesson in sorted_timetable: |
|
with st.container(): |
|
st.markdown(f"**{lesson.subject.name}** ({lesson.start.strftime('%H:%M')} - {lesson.end.strftime('%H:%M')}) - Salle: {lesson.classroom}") |
|
if lesson.status: |
|
st.caption(f"**Statut**: {lesson.status}") |
|
return True |
|
return False |
|
|
|
if __name__ == "__main__": |
|
client = pronotepy.Client(...) |
|
app(client) |
|
|