From c80a41ffafe3065f35f07b71063b5596d33d0ff2 Mon Sep 17 00:00:00 2001
From: Alban Gruin
Date: Sun, 29 Oct 2017 15:37:43 +0100
Subject: Déplacement de tous les liens vers les ICS dans une page spéciale
---
templates/calendars.html | 13 +++++++++++++
templates/timetable.html | 2 +-
urls.py | 1 +
views.py | 9 +++++++++
4 files changed, 24 insertions(+), 1 deletion(-)
create mode 100644 templates/calendars.html
diff --git a/templates/calendars.html b/templates/calendars.html
new file mode 100644
index 0000000..70f3dac
--- /dev/null
+++ b/templates/calendars.html
@@ -0,0 +1,13 @@
+{% extends "index.html" %}
+
+{% block title %}Calendriers disponibles pour le groupe {{ group }} – {% endblock %}
+
+{% block body %}
+
Calendriers disponibles pour le groupe {{ group }}
+
+{% endblock %}
diff --git a/templates/timetable.html b/templates/timetable.html
index b009174..fc2065f 100644
--- a/templates/timetable.html
+++ b/templates/timetable.html
@@ -18,4 +18,4 @@
{% if last_update %}Dernière mise à jour le {{ last_update|date:"l j F o" }} à {{ last_update|date:"H:i" }}{% endif %}
{% include "timetable_common.html" %}
- ICS – ICS séparés – RSS – Atom
{% endblock %}
+ ICS – RSS – Atom
{% endblock %}
diff --git a/urls.py b/urls.py
index d269400..c84ac75 100644
--- a/urls.py
+++ b/urls.py
@@ -22,6 +22,7 @@ urlpatterns = [
url(r"^(?P[-\w]+)/$", views.mention_list, name="mentions"),
url(r"^(?P[-\w]+)/(?P[-\w]+)/$", views.group_list, name="groups"),
url(r"^(?P[-\w]+)/(?P[-\w]+)/(?P[-\w]+)/$", views.timetable, name="timetable"),
+ url(r"^(?P[-\w]+)/(?P[-\w]+)/(?P[-\w]+)/calendars", views.calendars, name="calendars"),
url(r"^(?P[-\w]+)/(?P[-\w]+)/(?P[-\w]+)/calendar.ics$", feeds.IcalFeed(), name="ics"),
url(r"^(?P[-\w]+)/(?P[-\w]+)/(?P[-\w]+)/calendar-group.ics$", feeds.IcalOnlyOneFeed(), name="ics-group"),
url(r"^(?P[-\w]+)/(?P[-\w]+)/(?P[-\w]+)/feed.atom$", feeds.AtomFeed(), name="atom"),
diff --git a/views.py b/views.py
index 9c38524..7c19840 100644
--- a/views.py
+++ b/views.py
@@ -17,6 +17,7 @@ import datetime
from django.conf import settings
from django.db.models import Max
+from django.db.models.functions import Length
from django.http import Http404
from django.shortcuts import get_object_or_404, render
@@ -95,5 +96,13 @@ def timetable(request, year_slug, timetable_slug, group_slug, year=None, week=No
"year": year, "week": int(week),
"is_old_timetable": is_old_timetable})
+def calendars(request, year_slug, timetable_slug, group_slug):
+ group = get_object_or_404(Group, timetable__year__slug=year_slug,
+ timetable__slug=timetable_slug, slug=group_slug)
+ groups = Group.objects.get_parents(group).annotate(length=Length("subgroup")) \
+ .order_by("length")
+
+ return render(request, "calendars.html", {"group": group, "groups": groups})
+
def contact(request):
return render(request, "contact.html", {"email": settings.ADMINS[0][1]})
--
cgit v1.2.1