diff options
author | Alban Gruin | 2017-02-28 09:32:01 +0100 |
---|---|---|
committer | Alban Gruin | 2017-02-28 09:32:01 +0100 |
commit | 246d7a2e3a22548ce355a551fb19936dc420f695 (patch) | |
tree | 5781e4a72af773dfdc4808640996c646f25d114b | |
parent | 990b45c050d287ee86483faaa32db25e392a7605 (diff) |
Léger nettoyage
-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")] |