aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlban Gruin2017-09-27 14:58:06 +0200
committerAlban Gruin2017-09-27 14:58:06 +0200
commita43f7fa835fcdf9f591c3f759f5ab7545c9df5b3 (patch)
tree64098df1357185f69861edb1fdea3a384d2ac167
parentba343196f8305dfadf01f8a617b05e6d9723ce13 (diff)
Affichage d’un message lorsque quelqu’un consulte un emploi du temps périmé
-rw-r--r--templates/timetable.html7
-rw-r--r--views.py12
2 files changed, 16 insertions, 3 deletions
diff --git a/templates/timetable.html b/templates/timetable.html
index 7a30595..21afa24 100644
--- a/templates/timetable.html
+++ b/templates/timetable.html
@@ -4,6 +4,11 @@
{% block body %}
<h2>{{ group.timetable }} &ndash; {{ group }} &ndash; Semaine {{ week }}</h2>
- <p>Dernière mise à jour le {{ last_update|date:"l j F o" }} à {{ last_update|date:"H:i" }}</p>
+ <p>
+ {% 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" }}
+ </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/views.py b/views.py
index 66f0a03..442ada6 100644
--- a/views.py
+++ b/views.py
@@ -55,8 +55,13 @@ def group_list(request, year_slug, timetable_slug):
return render(request, "group_list.html", {"timetable": timetable, "groups": groups})
def timetable(request, year_slug, timetable_slug, group_slug, year=None, week=None):
+ current_year, current_week = get_current_week()
+ is_old_timetable = False
+
if year is None or week is None:
- year, week = get_current_week()
+ year, week = current_year, current_week
+ elif (int(year), int(week)) < (current_year, current_week):
+ is_old_timetable = True
start, end = get_week(int(year), int(week))
@@ -69,7 +74,10 @@ def timetable(request, year_slug, timetable_slug, group_slug, year=None, week=No
grouped_courses = group_courses(courses)
- return render(request, "timetable.html", {"group": group, "courses": grouped_courses, "last_update": courses.first().last_update__max, "year": year, "week": int(week)})
+ return render(request, "timetable.html", {"group": group, "courses": grouped_courses,
+ "last_update": courses.first().last_update__max,
+ "year": year, "week": int(week),
+ "is_old_timetable": is_old_timetable})
def contact(request):
return render(request, "contact.html", {"email": settings.ADMINS[0][1]})