aboutsummaryrefslogtreecommitdiff
path: root/management/commands/timetables.py
diff options
context:
space:
mode:
authorAlban Gruin2017-01-19 21:43:34 +0100
committerAlban Gruin2017-01-19 21:43:34 +0100
commitd70781860ba63d457b63a977a2d403ad9aa160b9 (patch)
tree55c04cd28fa07368ff3c3df893fbbab2d6c473b7 /management/commands/timetables.py
parenteea8dd99b859943d441e36b4958ce7bf61a27e8f (diff)
Ajout d'un champ "notes" aux cours.
Il apparement possible qu'un cours n'ai pas de nom, ni de salle bien définie, ou que ces informations soient stockées dans un champ "notes". Le traitement d'un évenement celcat peut être interrompu seulement si aucun groupe n'est renseigné. Si aucun nom n'est renseigné, il est remplacé par le contenu de la note.
Diffstat (limited to 'management/commands/timetables.py')
-rw-r--r--management/commands/timetables.py17
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."))