From 735041124f1df31c5c947f13ee34bdf3e747d703 Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Wed, 6 Sep 2017 17:55:56 +0200 Subject: Le parseur récupère l’ID des événements et les stocke dans la base --- management/commands/_private.py | 2 +- management/commands/timetables.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/management/commands/_private.py b/management/commands/_private.py index c31eb34..72e5440 100644 --- a/management/commands/_private.py +++ b/management/commands/_private.py @@ -120,7 +120,7 @@ def get_events(timetable, year, week, soup, weeks_in_soup): rooms = [get_from_db_or_create(Room, name=item.text) for item in event.resources.room.find_all("item")] - yield title, type_, groups, rooms, notes, begin, end + yield title, type_, groups, rooms, notes, begin, end, event["id"] def get_weeks(soup): weeks = {} diff --git a/management/commands/timetables.py b/management/commands/timetables.py index 0984c92..64f90fa 100644 --- a/management/commands/timetables.py +++ b/management/commands/timetables.py @@ -26,8 +26,8 @@ import datetime @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(timetable, year, week, soup, weeks_in_soup): - course = Course.objects.create(timetable=timetable, begin=begin, end=end) + for name, type_, groups, rooms, notes, begin, end, celcat_id in get_events(timetable, year, week, soup, weeks_in_soup): + course = Course.objects.create(timetable=timetable, begin=begin, end=end, celcat_id=celcat_id) course.name = name course.type = type_ course.notes = notes -- cgit v1.2.1