diff options
-rw-r--r-- | templates/group_list.html | 7 | ||||
-rw-r--r-- | templates/group_weeks_list.html | 8 | ||||
-rw-r--r-- | templates/groups_all_list.html | 6 | ||||
-rw-r--r-- | templates/index.html | 2 | ||||
-rw-r--r-- | templates/room_weeks_list.html | 7 | ||||
-rw-r--r-- | templates/timetable.html | 10 | ||||
-rw-r--r-- | urls.py | 3 | ||||
-rw-r--r-- | views.py | 54 |
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> — {% 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 %}– {% 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> – + <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 }} – {% 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 }} – {% 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 }} – {% 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 %} – {% endif %} + – {% 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> + – {% 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> – <a href="{% url "rss" timetable.year.slug timetable.slug group.slug %}">RSS</a> – <a href="{% url "atom" timetable.year.slug timetable.slug group.slug %}">Atom</a> @@ -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"), ] @@ -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) |