diff options
author | Alban Gruin | 2017-01-22 14:34:14 +0100 |
---|---|---|
committer | Alban Gruin | 2017-01-22 14:34:14 +0100 |
commit | c35a975116bd1a478b7d09028ffba662796d8890 (patch) | |
tree | d232632a2dd3f276a7913768d8430a017c8a2fa3 | |
parent | 310c91fcd777a9e7c97379803e41d795a4661be7 (diff) |
Affichage de la dernière mise à jour sur les pages concernées
-rw-r--r-- | management/commands/timetables.py | 8 | ||||
-rw-r--r-- | templates/timetable.html | 3 | ||||
-rw-r--r-- | views.py | 6 |
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 }} – {{ group.name }} – Semaine {{ week }}</h2>{% for day in courses %} + <h2>{{ timetable.name }} – {{ group.name }} – 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" }} – de {{ day.0.begin|date:"H:i" }} à {% with day|last as last %}{{ last.end|date:"H:i" }}{% endwith %}</h3> <ul>{% for course in day %} @@ -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}) |