diff options
author | Alban Gruin | 2017-10-29 15:37:43 +0100 |
---|---|---|
committer | Alban Gruin | 2017-10-29 15:37:43 +0100 |
commit | c80a41ffafe3065f35f07b71063b5596d33d0ff2 (patch) | |
tree | dfe357fe9ce314460fa0d9312f3f0bcdd419862e | |
parent | f0790a2420684a39e2b48922beec1245f4446912 (diff) |
Déplacement de tous les liens vers les ICS dans une page spéciale
-rw-r--r-- | templates/calendars.html | 13 | ||||
-rw-r--r-- | templates/timetable.html | 2 | ||||
-rw-r--r-- | urls.py | 1 | ||||
-rw-r--r-- | views.py | 9 |
4 files changed, 24 insertions, 1 deletions
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 %} + <h2>Calendriers disponibles pour le groupe {{ group }}</h2> + <ul> + <li><a href="{% url "ics" group.timetable.year.slug group.timetable.slug group.slug %}">Un seul ICS pour tous les cours</a></li> +{% for group in groups %} + <li><a href="{% url "ics-group" group.timetable.year.slug group.timetable.slug group.slug %}">ICS pour le groupe {{ group }} uniquement</a></li> +{% endfor %} + </ul> +{% 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 %} </p> {% include "timetable_common.html" %} - <p class="subscribe"><a href="{% url "ics" group.timetable.year.slug group.timetable.slug group.slug %}">ICS</a> – <a href="{% url "calendar-list" group.timetable.year.slug group.timetable.slug group.slug %}">ICS séparés</a> – <a href="{% url "rss" group.timetable.year.slug group.timetable.slug group.slug %}">RSS</a> – <a href="{% url "atom" group.timetable.year.slug group.timetable.slug group.slug %}">Atom</a></p>{% endblock %} + <p class="subscribe"><a href="{% url "calendars" group.timetable.year.slug group.timetable.slug group.slug %}">ICS</a> – <a href="{% url "rss" group.timetable.year.slug group.timetable.slug group.slug %}">RSS</a> – <a href="{% url "atom" group.timetable.year.slug group.timetable.slug group.slug %}">Atom</a></p>{% endblock %} @@ -22,6 +22,7 @@ urlpatterns = [ url(r"^(?P<year_slug>[-\w]+)/$", views.mention_list, name="mentions"), url(r"^(?P<year_slug>[-\w]+)/(?P<timetable_slug>[-\w]+)/$", views.group_list, name="groups"), url(r"^(?P<year_slug>[-\w]+)/(?P<timetable_slug>[-\w]+)/(?P<group_slug>[-\w]+)/$", views.timetable, name="timetable"), + url(r"^(?P<year_slug>[-\w]+)/(?P<timetable_slug>[-\w]+)/(?P<group_slug>[-\w]+)/calendars", views.calendars, name="calendars"), url(r"^(?P<year_slug>[-\w]+)/(?P<timetable_slug>[-\w]+)/(?P<group_slug>[-\w]+)/calendar.ics$", feeds.IcalFeed(), name="ics"), url(r"^(?P<year_slug>[-\w]+)/(?P<timetable_slug>[-\w]+)/(?P<group_slug>[-\w]+)/calendar-group.ics$", feeds.IcalOnlyOneFeed(), name="ics-group"), url(r"^(?P<year_slug>[-\w]+)/(?P<timetable_slug>[-\w]+)/(?P<group_slug>[-\w]+)/feed.atom$", feeds.AtomFeed(), name="atom"), @@ -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]}) |