diff options
author | Alban Gruin | 2017-10-07 13:12:24 +0200 |
---|---|---|
committer | Alban Gruin | 2017-10-07 13:12:24 +0200 |
commit | b8640c8882a270591bf8632abe7c4d44ee22f94e (patch) | |
tree | 6a0c8c2bc7e2435870f440767fa18ec86bd74871 /management/commands | |
parent | 527212137aa9c48b2e7e46f7f8fcbcb3d31f6b3b (diff) | |
parent | ab47155c3d7eb9b5bf421c5f9c9c903602ebb175 (diff) |
Merge branch 'stable/0.10.z' into prod/pa1ch/0.10.zv0.10.3-pa1ch
Diffstat (limited to 'management/commands')
-rw-r--r-- | management/commands/_private.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/management/commands/_private.py b/management/commands/_private.py index d576daf..bad6e6f 100644 --- a/management/commands/_private.py +++ b/management/commands/_private.py @@ -80,7 +80,7 @@ def get_from_db_or_create(cls, **kwargs): return obj -def get_event(timetable, event, event_week): +def get_event(timetable, event, event_week, today): """Renvoie une classe Course à partir d’un événement récupéré par BS4""" # On récupère la date de l’évènement à partir de la semaine # et de la semaine référencée, puis l’heure de début et de fin @@ -88,6 +88,10 @@ def get_event(timetable, event, event_week): begin = add_time(date, event.starttime.text) end = add_time(date, event.endtime.text) + # On ne traite pas le cours si il commence après le moment du traitement + if begin < today: + return + # Création de l’objet cours course = Course.objects.create(timetable=timetable, begin=begin, end=end) @@ -142,11 +146,10 @@ def get_events(timetable, soup, weeks_in_soup, today, year=None, week=None): year is None or week is None) and \ event.resources.group is not None and \ event.starttime is not None and event.endtime is not None: - course = get_event(timetable, event, event_week) + course = get_event(timetable, event, event_week, today) - # On ne sauvegarde le cours que si il ne - # commence après le moment du traitement - if course.begin >= today: + # On renvoie le cours si il n’est pas nul + if course is not None: yield course def get_update_date(soup): |