From 5eae1571d2e2a446958c9576b6dbe4a59c488e60 Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Fri, 8 Sep 2017 21:48:47 +0200 Subject: Génération du lien alternatif pour le flux atom. Ajout d’un URL pour le flux atom --- feeds.py | 8 +++++++- urls.py | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/feeds.py b/feeds.py index 37d6f8d..aa68934 100644 --- a/feeds.py +++ b/feeds.py @@ -16,6 +16,7 @@ from django.core.exceptions import ObjectDoesNotExist from django.contrib.syndication.views import Feed from django.db.models import Q +from django.urls import reverse from django.utils.feedgenerator import Atom1Feed, SyndicationFeed from icalendar import Calendar, Event @@ -87,5 +88,10 @@ class AtomFeed(Feed): else: return group, updates + def link(self, obj): + group = obj[0] + link = reverse("timetable", kwargs={"year_slug": group.timetable.year.slug, "timetable_slug": group.timetable.slug, "group_slug": group.slug}) + return link + def items(self, obj): - pass + return [] diff --git a/urls.py b/urls.py index 2df41f4..7f313c1 100644 --- a/urls.py +++ b/urls.py @@ -22,6 +22,7 @@ urlpatterns = [ 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]+)/calendar.ics$", feeds.IcalFeed(), name="ics"), + url(r"^(?P[-\w]+)/(?P[-\w]+)/(?P[-\w]+)/feed.atom$", feeds.AtomFeed(), name="atom"), url(r"^(?P[-\w]+)/(?P[-\w]+)/(?P[-\w]+)/(?P[0-9]{4})/(?P[0-4]?[0-9]|5[0-3])/$", views.timetable, name="timetable"), url(r"^(?P[-\w]+)/(?P[-\w]+)/(?P[-\w]+)/(?P[0-9]{4})/(?P[0-4]?[0-9]|5[0-3])/subscribe$", views.subscribe, name="subscribe"), url(r"^subscriptions/confirm/(?P[0-9a-f]{40})$", views.confirm_subscription, name="confirm"), -- cgit v1.2.1