diff options
Diffstat (limited to 'management/commands')
-rw-r--r-- | management/commands/_private.py | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/management/commands/_private.py b/management/commands/_private.py index 5b4a7ff..3cd23ca 100644 --- a/management/commands/_private.py +++ b/management/commands/_private.py @@ -46,15 +46,12 @@ def delete_courses_in_week(timetable, year, week): Course.objects.filter(begin__gte=start, begin__lt=end, timetable=timetable).delete() -def get_from_db_or_create(cls, timetable=None, **kwargs): +def get_from_db_or_create(cls, **kwargs): obj = cls.objects.all().filter(**kwargs) - if timetable is not None: - obj = obj.filter(timetable=timetable) obj = obj.first() if obj is None: obj = cls(**kwargs) - obj.timetable = timetable obj.save() return obj @@ -79,7 +76,7 @@ def get_events(timetable, year, week, soup, weeks_in_soup): end = add_time(date, datetime.datetime.strptime( event.endtime.text, "%H:%M")) - groups = [get_from_db_or_create(Group, timetable, + groups = [get_from_db_or_create(Group, timetable=timetable, celcat_name=item.text) for item in event.resources.group.find_all("item")] |