aboutsummaryrefslogtreecommitdiff
path: root/management
diff options
context:
space:
mode:
authorAlban Gruin2017-01-22 12:37:56 +0100
committerAlban Gruin2017-01-22 12:37:56 +0100
commit310c91fcd777a9e7c97379803e41d795a4661be7 (patch)
tree8da131dceeb256ce2555b88fcd43a48fa27c794f /management
parent3f0efad5ee4069d5387e742f346f8d782607fa96 (diff)
Stockage de la date de dernière mise à jour d'un emploi du temps par semaine et année
Diffstat (limited to 'management')
-rw-r--r--management/commands/timetables.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/management/commands/timetables.py b/management/commands/timetables.py
index 6412b7e..21148c8 100644
--- a/management/commands/timetables.py
+++ b/management/commands/timetables.py
@@ -1,7 +1,7 @@
from django.core.management.base import BaseCommand, CommandError
from django.db import transaction
from django.utils import timezone
-from edt.models import Timetable, Group, Room, Course
+from edt.models import Timetable, LastUpdate, Group, Room, Course
from bs4 import BeautifulSoup
@@ -25,6 +25,14 @@ def process_timetable_week(timetable, year, week, soup, weeks_in_soup):
course.save()
+ date = timezone.make_aware(datetime.datetime.now())
+ try:
+ lastUpdate = LastUpdate.objects.get(timetable=timetable, year=year, week=week)
+ lastUpdate.date = date
+ except:
+ lastUpdate = LastUpdate(timetable=timetable, year=year, week=week, date=date)
+ lastUpdate.save()
+
def process_timetable(timetable, year, weeks):
soup = get_xml(timetable.url)
weeks_in_soup = get_weeks(soup)