hanze/programmeerles-ouderen

preparing merge (3cea76fe26ef8af5977d26b85fc32f48aec4408d)
Repositories

commit 3cea76fe26ef8af5977d26b85fc32f48aec4408d
parent 2f3e04fac63163a47d10b3eb549ba248f65ea1c0
Author: Friedel Schön <[email protected]>
Date:   Thu,  7 Apr 2022 13:30:31 +0200

preparing merge

Diffstat:
Mpgmles/flaskcalendar.py25+++++++++++++++++++++----
Mpgmles/templates/layout.html1+
2 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/pgmles/flaskcalendar.py b/pgmles/flaskcalendar.py @@ -1,21 +1,38 @@ +import enum import random from calendar import Calendar as Month from datetime import datetime +from glob import glob +from pydoc import doc -lessons = ['Python van Cr', 'C van Hg', 'Python van Kr', - None, None, None, None, None, None] +from sqlalchemy import true + +lesson_names = ['Python', 'C', 'C++', 'Java', + 'JavaScript', None, None, None, None, None, None, None, None] + +lessons = [None] * 31 class Calendar: weekdays = list(enumerate(['Ma', 'Di', 'Wo', 'Do', 'Vr', 'Za', 'Zo'])) + nextlesson = '' rows = [] def __init__(self): today = datetime.today() m = Month() + + for day in m.itermonthdays(today.year, today.month): + if day != 0: + lessons[day] = random.choice(lesson_names) + + for day, lesson in enumerate(lessons[today.day:]): + if lesson is not None: + self.nextlesson = lesson + break + for days in m.monthdayscalendar(today.year, today.month): - self.rows.append([(i, d, (random.choice(lessons) if d != 0 and i != 6 else None)) - for i, d in enumerate(days)]) + self.rows.append([(i, d, lessons[d]) for i, d in enumerate(days)]) print(self.rows) diff --git a/pgmles/templates/layout.html b/pgmles/templates/layout.html @@ -86,6 +86,7 @@ </tr> {% endfor %} </table> + {{ calendar.nextlesson }} </div> </div> </div>