aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlban Gruin2018-04-25 09:35:18 +0200
committerAlban Gruin2018-04-25 09:35:18 +0200
commitfb3a3bc214b071083325a75a9546331150eaa8a5 (patch)
tree908c2e4d5d3e65324e22d2df554139f9fe58f64d
parent60e3b389d065746d61906f91327867bfd5ed582c (diff)
templates: abstraction des listes de groupes/salles/semaines
-rw-r--r--templates/group_list.html25
-rw-r--r--templates/index.html2
-rw-r--r--templates/room_list.html9
-rw-r--r--views.py6
4 files changed, 24 insertions, 18 deletions
diff --git a/templates/group_list.html b/templates/group_list.html
index 9c9a7fc..bca8c70 100644
--- a/templates/group_list.html
+++ b/templates/group_list.html
@@ -1,19 +1,16 @@
{% extends "index.html" %}
{% load dt_week %}
-{% block title %}{% if timetable %}{{ timetable }}{% else %}Emploi du temps des salles{% endif %} – {% endblock %}
+{% block title %}{{ timetable }} – {% endblock %}
+{% block pagetitle %}<a href="{{ timetable.source.url }}">{{ timetable }}</a>{% endblock %}
-{% block body %}
- <h3>{% if timetable %}<a href="{{ timetable.source.url }}">{{ timetable }}</a>{% else %}Emploi du temps des salles{% endif %}</h3>
- <ul>
- {% for group in groups %}
- <li><a class="text"{% if group.weeks is not None %} href="{% if timetable %}{% url "timetable" timetable.year.slug timetable.slug group.slug %}{% else %}{% url "room-timetable" group.slug %}{% endif %}"{% endif %}>{{ group }}</a> &mdash; {% for week in group.weeks %}<a href="{% if timetable %}{% url "timetable" timetable.year.slug timetable.slug group.slug week.year week|dt_week %}{% else %}{% url "room-timetable" group.slug week.year week|dt_week %}{% endif %}">{{ week|dt_prettyprint }}</a> {% if not forloop.last %}&ndash; {% endif %}{% empty %}<em>aucun cours dans le mois à venir</em>{% endfor %}</li>
- {% endfor %}
- </ul>
- {% if timetable %}
- <a href="{% url "mentions" timetable.year.slug %}">Retour à la liste des mentions</a> &ndash;
- <a href="{% url "groups-all" timetable.year.slug timetable.slug %}">Tous les groupes</a>
- {% else %}
- <a href="{% url "index" %}">Retour à la liste des années</a>
- {% endif %}
+{% block lelement %}<a class="text"{% if element.weeks is not None %} href="{% block gurl %}{% url "timetable" timetable.year.slug timetable.slug element.slug %}{% endblock %}"{% endif %}>{{ element }}</a> &mdash;
+{% for week in element.weeks %}
+ <a href="{% block wurl %}{% url "timetable" timetable.year.slug timetable.slug element.slug week.year week|dt_week %}{% endblock %}">{{ week|dt_prettyprint }}</a> {% if not forloop.last %}&ndash; {% endif %}
+{% empty %}
+ <em>aucun cours dans le mois à venir</em>
+{% endfor %}
{% endblock %}
+
+{% block navigation %}<a href="{% url "mentions" timetable.year.slug %}">Retour à la liste des mentions</a> &ndash;
+<a href="{% url "groups-all" timetable.year.slug timetable.slug %}">Tous les groupes</a>{% endblock %}
diff --git a/templates/index.html b/templates/index.html
index cdab591..e86038e 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -16,7 +16,7 @@
<h3>{% block pagetitle %}{% endblock %}</h3>
<ul>
{% for element in elements %}
- <li><a href="{% block url %}{% endblock %}">{% block element %}{{ element }}{% endblock %}</a></li>
+ <li>{% block lelement %}<a href="{% block url %}{% endblock %}">{% block element %}{{ element }}{% endblock %}</a>{% endblock %}</li>
{% empty %}
<p><em>{% block empty %}Aucun emploi du temps à afficher{% endblock %}</em></p>
{% endfor %}
diff --git a/templates/room_list.html b/templates/room_list.html
new file mode 100644
index 0000000..1b8497d
--- /dev/null
+++ b/templates/room_list.html
@@ -0,0 +1,9 @@
+{% extends "group_list.html" %}
+{% load dt_week %}
+
+{% block title %}Emploi du temps des salles &ndash; {% endblock %}
+{% block pagetitle %}Emploi du temps des salles{% endblock %}
+{% block gurl %}{% url "room-timetable" element.slug %}{% endblock %}
+{% block wurl %}{% url "room-timetable" element.slug week.year week|dt_week %}{% endblock %}
+{% block navigation %}<a href="{% url "index" %}">Retour à la liste des années</a> &ndash;
+<a href="{% url "qsjps" %}">Trouver une salle libre</a>{% endblock %}
diff --git a/views.py b/views.py
index 2411fe7..e45ece3 100644
--- a/views.py
+++ b/views.py
@@ -76,7 +76,7 @@ def group_list(request, year_slug, timetable_slug):
group.weeks.sort()
return render(request, "group_list.html",
- {"timetable": timetable, "groups": groups})
+ {"timetable": timetable, "elements": groups})
def groups_all(request, year_slug, timetable_slug):
@@ -199,7 +199,7 @@ def rooms(request):
RawSQL("date_trunc('week', edt_course.begin)",
[]), distinct=True))
- return render(request, "group_list.html", {"groups": rooms})
+ return render(request, "room_list.html", {"elements": rooms})
# Récupération des salles et de toutes les semaines où elles sont
# concernées.
@@ -232,7 +232,7 @@ def rooms(request):
rooms_weeks[-1].weeks.append(date)
# Rendu de la page.
- return render(request, "group_list.html", {"groups": rooms_weeks})
+ return render(request, "room_list.html", {"elements": rooms_weeks})
def room_weeks(request, room_slug):