aboutsummaryrefslogtreecommitdiff
path: root/management/commands/_private.py
diff options
context:
space:
mode:
Diffstat (limited to 'management/commands/_private.py')
-rw-r--r--management/commands/_private.py13
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