diff options
author | Alban Gruin | 2017-10-05 09:35:14 +0200 |
---|---|---|
committer | Alban Gruin | 2017-10-05 09:35:14 +0200 |
commit | 295f8cbd261cf588f1f5f8eb2b0d82b1ae9c1fe0 (patch) | |
tree | d19b9ed9a35e2891f399ff8ef1d6735c40f72087 /management/commands/_private.py | |
parent | cede815e9314290227f18156b93f8020041381d6 (diff) |
On ne supprime pas les cours qui commencent avant le début du traitement
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 |