aboutsummaryrefslogtreecommitdiff
path: root/management/commands/scraptimetables.py
diff options
context:
space:
mode:
authorAlban Gruin2017-09-09 21:04:12 +0200
committerAlban Gruin2017-09-09 21:04:12 +0200
commitafa67de3f2b8cb01d4565ad9dd438155b4023f09 (patch)
treed52ae14c9b96444ee88b5c54bf6210e955a17553 /management/commands/scraptimetables.py
parent0dfb4fbf3478b0b07d0e6995b108974e6eb16d50 (diff)
Rajout des emplois du temps dans la base
Diffstat (limited to 'management/commands/scraptimetables.py')
-rw-r--r--management/commands/scraptimetables.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/management/commands/scraptimetables.py b/management/commands/scraptimetables.py
index 780ea8d..255bfd4 100644
--- a/management/commands/scraptimetables.py
+++ b/management/commands/scraptimetables.py
@@ -34,7 +34,14 @@ class Command(BaseCommand):
if "toutes sections et semestres confondus" in link.text:
url_base = finder.rsplit("/", 1)
timetable_url = "/".join([url_base[0], link.parent.parent.find("a", attrs={"class": "xmllink"})["href"]])
- print(year, name, link.text, timetable_url)
+
+ try:
+ timetable = Timetable.objects.get(year=year, name=name)
+ timetable.url = timetable_url
+ except:
+ timetable = Timetable(year=year, name=name, url=timetable_url)
+ finally:
+ timetable.save()
def __get_finders(self, url):
soup = get_xml(url)