diff options
author | Alban Gruin | 2017-10-05 22:11:59 +0200 |
---|---|---|
committer | Alban Gruin | 2017-10-05 22:11:59 +0200 |
commit | f6e81c1a165b983316b49bdd433cd12cfebe1897 (patch) | |
tree | d638e3cf6335dcab46a415c5cb9c5946ae02dbac /management/commands/_private.py | |
parent | ae3358c1296a02352409910a9ffcc2307d5ea87a (diff) | |
parent | 76e344f68c1616693e93791f55348272cc61267e (diff) |
Merge branch 'stable/0.10.z' into prod/pa1ch/0.10.zv0.10.1-pa1ch
Diffstat (limited to 'management/commands/_private.py')
-rw-r--r-- | management/commands/_private.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/management/commands/_private.py b/management/commands/_private.py index 8f195a1..d576daf 100644 --- a/management/commands/_private.py +++ b/management/commands/_private.py @@ -65,9 +65,9 @@ def consolidate_groups(groups): if group.parent is None: consolidate_group(group) -def delete_courses_in_week(timetable, year, week): +def delete_courses_in_week(timetable, year, week, today): start, end = get_week(year, week) - Course.objects.filter(begin__gte=start, begin__lt=end, + Course.objects.filter(begin__gte=max(start, today), begin__lt=end, timetable=timetable).delete() def get_from_db_or_create(cls, **kwargs): @@ -128,7 +128,7 @@ def get_event(timetable, event, event_week): return course -def get_events(timetable, soup, weeks_in_soup, year=None, week=None): +def get_events(timetable, soup, weeks_in_soup, today, year=None, week=None): """Récupère tous les cours disponibles dans l’emploi du temps Celcat. Le traîtement se limitera à la semaine indiquée si il y en a une.""" for event in soup.find_all("event"): @@ -142,7 +142,12 @@ def get_events(timetable, soup, weeks_in_soup, 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: - yield get_event(timetable, event, event_week) + course = get_event(timetable, event, event_week) + + # On ne sauvegarde le cours que si il ne + # commence après le moment du traitement + if course.begin >= today: + yield course def get_update_date(soup): # Explication de la regex |