From 246d7a2e3a22548ce355a551fb19936dc420f695 Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Tue, 28 Feb 2017 09:32:01 +0100 Subject: Léger nettoyage --- management/commands/_private.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'management/commands') 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")] -- cgit v1.2.1