aboutsummaryrefslogtreecommitdiff
path: root/management
diff options
context:
space:
mode:
Diffstat (limited to 'management')
-rw-r--r--management/commands/_private.py15
-rw-r--r--management/commands/timetables.py2
2 files changed, 10 insertions, 7 deletions
diff --git a/management/commands/_private.py b/management/commands/_private.py
index f14dae6..5b4a7ff 100644
--- a/management/commands/_private.py
+++ b/management/commands/_private.py
@@ -27,7 +27,8 @@ import requests
class Week:
def __init__(self, number, start):
self.number = number
- self.start = timezone.make_aware(datetime.datetime.strptime(start, "%d/%m/%Y"))
+ self.start = timezone.make_aware(
+ datetime.datetime.strptime(start, "%d/%m/%Y"))
def get_day(self, id):
return self.start + datetime.timedelta(id)
@@ -58,7 +59,7 @@ def get_from_db_or_create(cls, timetable=None, **kwargs):
return obj
-def get_events(soup, weeks, year, week, timetable):
+def get_events(timetable, year, week, soup, weeks_in_soup):
for event in soup.find_all("event"):
title = None
type_ = None
@@ -66,11 +67,12 @@ def get_events(soup, weeks, year, week, timetable):
rooms = None
notes = None
- if weeks[event.rawweeks.text].number == week and \
- weeks[event.rawweeks.text].year == year and \
+ if weeks_in_soup[event.rawweeks.text].number == week and \
+ weeks_in_soup[event.rawweeks.text].year == year and \
event.resources.group is not None and \
event.starttime is not None and event.endtime is not None:
- date = weeks[event.rawweeks.text].get_day(int(event.day.text))
+ date = weeks_in_soup[event.rawweeks.text].get_day(int(
+ event.day.text))
begin = add_time(date, datetime.datetime.strptime(
event.starttime.text, "%H:%M"))
@@ -104,7 +106,8 @@ def get_events(soup, weeks, year, week, timetable):
def get_weeks(soup):
weeks = {}
for span in soup.find_all("span"):
- weeks[span.alleventweeks.text] = Week(int(span.title.text), span["date"])
+ weeks[span.alleventweeks.text] = Week(int(span.title.text),
+ span["date"])
return weeks
diff --git a/management/commands/timetables.py b/management/commands/timetables.py
index 88d9008..50256db 100644
--- a/management/commands/timetables.py
+++ b/management/commands/timetables.py
@@ -29,7 +29,7 @@ import requests
@transaction.atomic
def process_timetable_week(timetable, year, week, soup, weeks_in_soup):
delete_courses_in_week(timetable, year, week)
- for name, type_, groups, rooms, notes, begin, end in get_events(soup, weeks_in_soup, year, week, timetable):
+ for name, type_, groups, rooms, notes, begin, end in get_events(timetable, year, week, soup, weeks_in_soup):
course = Course.objects.create(timetable=timetable, begin=begin, end=end)
course.name = name
course.type = type_