diff options
Diffstat (limited to 'management/commands/timetables.py')
-rw-r--r-- | management/commands/timetables.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/management/commands/timetables.py b/management/commands/timetables.py index 50382ed..81e5a7d 100644 --- a/management/commands/timetables.py +++ b/management/commands/timetables.py @@ -38,10 +38,21 @@ class Command(BaseCommand): soup = get_xml(timetable.url) weeks = get_weeks(soup) - for name, type_, groups, rooms, begin, end in get_events(soup, weeks, week, timetable): - course = Course.objects.create(name=name, type=type_, timetable=timetable, begin=begin, end=end) + for name, type_, groups, rooms, notes, begin, end in get_events(soup, weeks, week, timetable): + course = Course.objects.create(timetable=timetable, begin=begin, end=end) + + if name is not None: + course.name = name + course.notes = notes + elif notes is not None: + course.name = notes + else: + course.name = "Aucune information" + course.groups.add(*groups) - course.rooms.add(*rooms) + if rooms is not None: + course.rooms.add(*rooms) + course.save() self.stdout.write(self.style.SUCCESS("Done.")) |