aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--templates/timetable.html2
-rw-r--r--templates/timetable_common.html3
-rw-r--r--views.py11
3 files changed, 9 insertions, 7 deletions
diff --git a/templates/timetable.html b/templates/timetable.html
index 4ab6a1a..e4dffe7 100644
--- a/templates/timetable.html
+++ b/templates/timetable.html
@@ -15,7 +15,7 @@
{% if is_old_timetable %}
<b><a href="{% url "timetable" group.timetable.year.slug group.timetable.slug group.slug %}">Accéder à l’emploi du temps de cette semaine.</b></a><br />
{% endif %}
- Dernière mise à jour le {{ last_update|date:"l j F o" }} à {{ last_update|date:"H:i" }}
+ {% if last_update %}Dernière mise à jour le {{ last_update|date:"l j F o" }} à {{ last_update|date:"H:i" }}{% endif %}
</p>
{% include "timetable_common.html" %}
<p class="subscribe"><a href="{% url "ics" group.timetable.year.slug group.timetable.slug group.slug %}">ICS</a> &ndash; <a href="{% url "rss" group.timetable.year.slug group.timetable.slug group.slug %}">RSS</a> &ndash; <a href="{% url "atom" group.timetable.year.slug group.timetable.slug group.slug %}">Atom</a></p>{% endblock %}
diff --git a/templates/timetable_common.html b/templates/timetable_common.html
index 4319e60..9a2c27e 100644
--- a/templates/timetable_common.html
+++ b/templates/timetable_common.html
@@ -9,4 +9,5 @@
<small>Remarques : {{ course.notes }}</small>{% endif %}
</li>{% endfor %}
</ul>
- </section>{% endfor %}
+ </section>{% empty %}
+ <p>Aucun cours cette semaine.</p>{% endfor %}
diff --git a/views.py b/views.py
index bd93712..2100972 100644
--- a/views.py
+++ b/views.py
@@ -65,10 +65,11 @@ def group_list(request, year_slug, timetable_slug):
def timetable(request, year_slug, timetable_slug, group_slug, year=None, week=None):
current_year, current_week = get_current_or_next_week()
- is_old_timetable = False
+ is_old_timetable, provided_week = False, True
if year is None or week is None:
year, week = current_year, current_week
+ provided_week = False
elif (int(year), int(week)) < (current_year, current_week):
is_old_timetable = True
@@ -80,15 +81,15 @@ def timetable(request, year_slug, timetable_slug, group_slug, year=None, week=No
if group.children.count():
return group_list_common(request, timetable, Group.objects.get_relevant_children(group))
- courses = Course.objects.get_courses_for_group(group, begin__gte=start, begin__lt=end) \
- .annotate(Max("last_update"))
- if courses.count() == 0:
+ courses = Course.objects.get_courses_for_group(group, begin__gte=start, begin__lt=end)
+ if courses.count() == 0 and provided_week:
raise Http404
+ last_update = courses.aggregate(Max("last_update"))["last_update__max"]
grouped_courses = group_courses(courses)
return render(request, "timetable.html", {"group": group, "courses": grouped_courses,
- "last_update": courses.first().last_update__max,
+ "last_update": last_update,
"year": year, "week": int(week),
"is_old_timetable": is_old_timetable})