aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--management/commands/timetables.py8
-rw-r--r--templates/timetable.html3
-rw-r--r--views.py6
3 files changed, 10 insertions, 7 deletions
diff --git a/management/commands/timetables.py b/management/commands/timetables.py
index 21148c8..809b600 100644
--- a/management/commands/timetables.py
+++ b/management/commands/timetables.py
@@ -27,11 +27,11 @@ def process_timetable_week(timetable, year, week, soup, weeks_in_soup):
date = timezone.make_aware(datetime.datetime.now())
try:
- lastUpdate = LastUpdate.objects.get(timetable=timetable, year=year, week=week)
- lastUpdate.date = date
+ last_update = LastUpdate.objects.get(timetable=timetable, year=year, week=week)
+ last_update.date = date
except:
- lastUpdate = LastUpdate(timetable=timetable, year=year, week=week, date=date)
- lastUpdate.save()
+ last_update = LastUpdate(timetable=timetable, year=year, week=week, date=date)
+ last_update.save()
def process_timetable(timetable, year, weeks):
soup = get_xml(timetable.url)
diff --git a/templates/timetable.html b/templates/timetable.html
index f4be3a3..8c125c5 100644
--- a/templates/timetable.html
+++ b/templates/timetable.html
@@ -3,7 +3,8 @@
{% block title %}{{ timetable.name }} – {{ group.name }} – Semaine {{ week }} – {% endblock %}
{% block body %}
- <h2>{{ timetable.name }} &ndash; {{ group.name }} &ndash; Semaine {{ week }}</h2>{% for day in courses %}
+ <h2>{{ timetable.name }} &ndash; {{ group.name }} &ndash; Semaine {{ week }}</h2>
+ <p>Dernière mise à jour le {{ last_update|date:"l j F o" }} à {{ last_update|date:"H:i" }}</p>{% for day in courses %}
<section>
<h3>{{ day.0.begin|date:"l j F o" }} &ndash; de {{ day.0.begin|date:"H:i" }} à {% with day|last as last %}{{ last.end|date:"H:i" }}{% endwith %}</h3>
<ul>{% for course in day %}
diff --git a/views.py b/views.py
index b971dc5..a6dfede 100644
--- a/views.py
+++ b/views.py
@@ -2,7 +2,7 @@ from django.http import HttpResponse
from django.db.models import Count
from django.shortcuts import get_object_or_404, render, render_to_response
-from edt.models import Timetable, Group, Course
+from edt.models import Timetable, LastUpdate, Group, Course
from edt.utils import get_week
import datetime
@@ -28,7 +28,9 @@ def timetable(request, timetable_slug, year, week, group_slug):
timetable = get_object_or_404(Timetable, slug=timetable_slug)
group = get_object_or_404(Group, slug=group_slug, timetable=timetable)
+
courses = Course.objects.get_courses_for_group(group, begin__gte=start, begin__lt=end)
+ last_update = LastUpdate.objects.get(timetable=timetable, week=week, year=year)
grouped_courses = []
for i, course in enumerate(courses):
@@ -37,4 +39,4 @@ def timetable(request, timetable_slug, year, week, group_slug):
else:
grouped_courses[-1].append(course)
- return render_to_response("timetable.html", {"timetable": timetable, "group": group, "courses": grouped_courses, "week": week})
+ return render_to_response("timetable.html", {"timetable": timetable, "group": group, "courses": grouped_courses, "last_update": last_update.date, "week": week})