aboutsummaryrefslogtreecommitdiff
path: root/management/commands/timetables.py
diff options
context:
space:
mode:
Diffstat (limited to 'management/commands/timetables.py')
-rw-r--r--management/commands/timetables.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/management/commands/timetables.py b/management/commands/timetables.py
index 8fc8ed6..c148fed 100644
--- a/management/commands/timetables.py
+++ b/management/commands/timetables.py
@@ -23,8 +23,14 @@ from django.db.models import Min
from ...models import Course, Source
from ...utils import get_week, tz_now
-from ..parsers.ups2017 import delete_courses_in_week, get_events, \
- get_update_date, get_weeks, get_xml
+from ..parsers.ups2017 import get_events, get_update_date, get_weeks, \
+ get_source
+
+
+def delete_courses_in_week(source, year, week, today):
+ start, end = get_week(year, week)
+ Course.objects.filter(begin__gte=max(start, today), begin__lt=end,
+ source=source).delete()
@transaction.atomic
@@ -100,7 +106,7 @@ def process_timetable_week(source, soup, weeks_in_soup, force,
def process_timetable(source, force, year=None, weeks=None):
- soup = get_xml(source.url)
+ soup = get_source(source.url)
weeks_in_soup = get_weeks(soup)
if year is not None and weeks is not None: