aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlban Gruin2018-04-21 15:20:01 +0200
committerAlban Gruin2018-04-21 15:21:33 +0200
commita6d14aa482e322fcd1946ea2541272477b4f8c6b (patch)
treee8c32f4c75853e6917ea25ab35fdddb99b6a92cf
parent7f0fa4871566050e283845ee0577603ded70df0f (diff)
Ajout d’une liste complète des groupes et d’une liste des semaines
-rw-r--r--templates/group_list.html7
-rw-r--r--templates/group_weeks_list.html8
-rw-r--r--templates/groups_all_list.html6
-rw-r--r--templates/index.html2
-rw-r--r--templates/room_weeks_list.html7
-rw-r--r--templates/timetable.html10
-rw-r--r--urls.py3
-rw-r--r--views.py54
8 files changed, 93 insertions, 4 deletions
diff --git a/templates/group_list.html b/templates/group_list.html
index 35536b6..9c9a7fc 100644
--- a/templates/group_list.html
+++ b/templates/group_list.html
@@ -10,5 +10,10 @@
<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>{% else %}<a href="{% url "index" %}">Retour à la liste des années</a>{% endif %}
+ {% 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 %}
{% endblock %}
diff --git a/templates/group_weeks_list.html b/templates/group_weeks_list.html
new file mode 100644
index 0000000..c348d5d
--- /dev/null
+++ b/templates/group_weeks_list.html
@@ -0,0 +1,8 @@
+{% extends "index.html" %}
+{% load dt_week %}
+
+{% block title %}Semaines du groupe {{ group }} &ndash; {% endblock %}
+{% block pagetitle %}Semaines du groupe {{ group }}{% endblock %}
+{% block url %}{% url "timetable" timetable.year.slug timetable.slug group.slug element.year element|dt_week %}{% endblock %}
+{% block element %}{{ element|dt_prettyprint }} (semaine {{ element|dt_week }}){% endblock %}
+{% block navigation %}<a href="{% url "groups" timetable.year.slug timetable.slug %}">Liste des groupes</a>{% endblock %}
diff --git a/templates/groups_all_list.html b/templates/groups_all_list.html
new file mode 100644
index 0000000..36bc447
--- /dev/null
+++ b/templates/groups_all_list.html
@@ -0,0 +1,6 @@
+{% extends "index.html" %}
+
+{% block title %}Liste des groupes de {{ timetable }} &ndash; {% endblock %}
+{% block pagetitle %}Liste des groupes de {{ timetable }}{% endblock %}
+{% block url %}{% url "group-weeks" timetable.year.slug timetable.slug element.slug %}{% endblock %}
+{% block navigation %}<a href="{% url "groups" timetable.year.slug timetable.slug %}">Retour à la liste réduite</a>{% endblock %}
diff --git a/templates/index.html b/templates/index.html
index c7c2543..cdab591 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 %}">{{ element }}</a></li>
+ <li><a href="{% block url %}{% endblock %}">{% block element %}{{ element }}{% endblock %}</a></li>
{% empty %}
<p><em>{% block empty %}Aucun emploi du temps à afficher{% endblock %}</em></p>
{% endfor %}
diff --git a/templates/room_weeks_list.html b/templates/room_weeks_list.html
new file mode 100644
index 0000000..6a4c3d9
--- /dev/null
+++ b/templates/room_weeks_list.html
@@ -0,0 +1,7 @@
+{% extends "group_weeks_list.html" %}
+{% load dt_week %}
+
+{% block title %}Semaines de la salle {{ room }} &ndash; {% endblock %}
+{% block pagetitle %}Semaines de la salle {{ room }}{% endblock %}
+{% block url %}{% url "room-timetable" room.slug element.year element|dt_week %}{% endblock %}
+{% block navigation %}<a href="{% url "rooms" %}">Liste des salles</a>{% endblock %}
diff --git a/templates/timetable.html b/templates/timetable.html
index 4bb3e10..a6dc1ab 100644
--- a/templates/timetable.html
+++ b/templates/timetable.html
@@ -31,15 +31,21 @@
<a href="{% if group_mode %}{% url "timetable" timetable.year.slug timetable.slug group.slug last_week.year last_week|dt_week %}{% else %}{% url "room-timetable" group.slug last_week.year last_week|dt_week %}{% endif %}">
Semaine {{ last_week|dt_week }}
</a>
- {% if next_week is not None %} &ndash; {% endif %}
+ &ndash;
{% endif %}
{% if next_week is not None %}
<a href="{% if group_mode %}{% url "timetable" timetable.year.slug timetable.slug group.slug next_week.year next_week|dt_week %}{% else %}{% url "room-timetable" group.slug next_week.year next_week|dt_week %}{% endif %}">
Semaine {{ next_week|dt_week }}
</a>
+ &ndash;
{% endif %}
{% if group_mode %}
- {% if last_week is not None or next_week is not None %}<br />{% endif %}
+ <a href="{% url "group-weeks" timetable.year.slug timetable.slug group.slug %}">Liste des semaines</a>
+ {% else %}
+ <a href="{% url "room-weeks" group.slug %}">Liste des semaines</a>
+ {% endif %}
+ <br />
+ {% if group_mode %}
<a href="{% url "calendars" timetable.year.slug timetable.slug group.slug %}">ICS</a> &ndash;
<a href="{% url "rss" timetable.year.slug timetable.slug group.slug %}">RSS</a> &ndash;
<a href="{% url "atom" timetable.year.slug timetable.slug group.slug %}">Atom</a>
diff --git a/urls.py b/urls.py
index b61bbbe..977ac8d 100644
--- a/urls.py
+++ b/urls.py
@@ -22,14 +22,17 @@ urlpatterns = [
path("salles/", views.rooms, name="rooms"),
path("salles/qsjps", views.qsjps, name="qsjps"),
path("salles/<slug:room_slug>/", views.room_timetable, name="room-timetable"),
+ path("salles/<slug:room_slug>/semaines", views.room_weeks, name="room-weeks"),
path("salles/<slug:room_slug>/<int:year>/<int:week>", views.room_timetable, name="room-timetable"),
path("<slug:year_slug>/", views.mention_list, name="mentions"),
path("<slug:year_slug>/<slug:timetable_slug>/", views.group_list, name="groups"),
+ path("<slug:year_slug>/<slug:timetable_slug>/tous", views.groups_all, name="groups-all"),
path("<slug:year_slug>/<slug:timetable_slug>/<slug:group_slug>/", views.timetable, name="timetable"),
path("<slug:year_slug>/<slug:timetable_slug>/<slug:group_slug>/calendars", views.calendars, name="calendars"),
path("<slug:year_slug>/<slug:timetable_slug>/<slug:group_slug>/calendar.ics", feeds.IcalFeed(), name="ics"),
path("<slug:year_slug>/<slug:timetable_slug>/<slug:group_slug>/calendar-group.ics", feeds.IcalOnlyOneFeed(), name="ics-group"),
path("<slug:year_slug>/<slug:timetable_slug>/<slug:group_slug>/feed.atom", feeds.AtomFeed(), name="atom"),
path("<slug:year_slug>/<slug:timetable_slug>/<slug:group_slug>/feed.rss", feeds.RSSFeed(), name="rss"),
+ path("<slug:year_slug>/<slug:timetable_slug>/<slug:group_slug>/semaines", views.group_weeks, name="group-weeks"),
path("<slug:year_slug>/<slug:timetable_slug>/<slug:group_slug>/<int:year>/<int:week>/", views.timetable, name="timetable"),
]
diff --git a/views.py b/views.py
index 1308db1..aabda59 100644
--- a/views.py
+++ b/views.py
@@ -79,6 +79,43 @@ def group_list(request, year_slug, timetable_slug):
{"timetable": timetable, "groups": groups})
+def groups_all(request, year_slug, timetable_slug):
+ # Récupération de l’emploi du temps et du groupe
+ timetable = get_object_or_404(Timetable, year__slug=year_slug,
+ slug=timetable_slug)
+ groups = Group.objects.filter(source=timetable.source).order_by("name")
+
+ # Rendu de la page
+ return render(request, "groups_all_list.html",
+ {"timetable": timetable, "elements": groups})
+
+
+def group_weeks(request, year_slug, timetable_slug, group_slug):
+ # Récupération de l’emploi du temps et des groupes
+ timetable = get_object_or_404(Timetable, year__slug=year_slug,
+ slug=timetable_slug)
+ group = get_object_or_404(Group, slug=group_slug, source=timetable.source)
+
+ # Groupes parents
+ groups = Group.objects.get_parents(group)
+
+ # Récupération de toutes les semaines avec des cours, sans doublons
+ courses = Course.objects.filter(groups__in=groups) \
+ .order_by("year", "week") \
+ .annotate(year=ExtractYear("begin"),
+ week=ExtractWeek("begin")) \
+ .values("year", "week") \
+ .annotate(c=Count("*"))
+
+ # Conversion des semaines de cours en dates
+ weeks = [get_week(course["year"], course["week"])[0] for course in courses]
+
+ # Rendu
+ return render(request, "group_weeks_list.html",
+ {"timetable": timetable, "group": group,
+ "elements": weeks})
+
+
def timetable_common(request, obj, year=None, week=None, timetable=None):
current_year, current_week = get_current_or_next_week()
is_old_timetable, provided_week = False, True
@@ -198,6 +235,23 @@ def rooms(request):
return render(request, "group_list.html", {"groups": rooms_weeks})
+def room_weeks(request, room_slug):
+ room = get_object_or_404(Room, slug=room_slug)
+
+ # Récupération des semaines de cours
+ courses = Course.objects.filter(rooms=room) \
+ .order_by("year", "week") \
+ .annotate(year=ExtractYear("begin"),
+ week=ExtractWeek("begin")) \
+ .values("year", "week") \
+ .annotate(c=Count("*"))
+
+ weeks = [get_week(course["year"], course["week"])[0] for course in courses]
+
+ return render(request, "room_weeks_list.html",
+ {"room": room, "elements": weeks})
+
+
def room_timetable(request, room_slug, year=None, week=None):
room = get_object_or_404(Room, slug=room_slug)
return timetable_common(request, room, year, week)