aboutsummaryrefslogtreecommitdiff
path: root/management/commands/timetables.py
diff options
context:
space:
mode:
authorAlban Gruin2017-10-05 09:35:14 +0200
committerAlban Gruin2017-10-05 09:35:14 +0200
commit295f8cbd261cf588f1f5f8eb2b0d82b1ae9c1fe0 (patch)
treed19b9ed9a35e2891f399ff8ef1d6735c40f72087 /management/commands/timetables.py
parentcede815e9314290227f18156b93f8020041381d6 (diff)
On ne supprime pas les cours qui commencent avant le début du traitement
Diffstat (limited to 'management/commands/timetables.py')
-rw-r--r--management/commands/timetables.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/management/commands/timetables.py b/management/commands/timetables.py
index 76f0a7c..8b37a5d 100644
--- a/management/commands/timetables.py
+++ b/management/commands/timetables.py
@@ -27,6 +27,7 @@ from ._private import delete_courses_in_week, get_events, get_update_date, get_w
@transaction.atomic
def process_timetable_week(timetable, soup, weeks_in_soup, force, year=None, week=None):
criteria = {}
+ today = timezone.make_aware(datetime.now())
if year is not None and week is not None:
begin, end = get_week(year, week)
criteria["begin__gte"] = begin
@@ -42,12 +43,12 @@ def process_timetable_week(timetable, soup, weeks_in_soup, force, year=None, wee
return
if year is not None and week is not None:
- delete_courses_in_week(timetable, year, week)
+ delete_courses_in_week(timetable, year, week, today)
else:
- Course.objects.filter(timetable=timetable,
- begin__gte=min(weeks_in_soup.values())).delete()
+ delete_from = max(min(weeks_in_soup.values()), today)
+ Course.objects.filter(timetable=timetable, begin__gte=delete_from).delete()
- for course in get_events(timetable, soup, weeks_in_soup, year, week):
+ for course in get_events(timetable, soup, weeks_in_soup, today, year, week):
course.save()
timetable.last_update_date = new_update_date