From 98242cad296b36423daf77e572d7735478d33f1d Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Sat, 9 Sep 2017 15:19:42 +0200 Subject: Ajout d’un flux RSS --- feeds.py | 12 ++++++++---- templates/timetable.html | 2 +- urls.py | 1 + 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/feeds.py b/feeds.py index 722f20c..2dd2479 100644 --- a/feeds.py +++ b/feeds.py @@ -14,6 +14,7 @@ # along with celcatsanitizer. If not, see . from django.core.exceptions import ObjectDoesNotExist +from django.conf import settings from django.contrib.syndication.views import Feed from django.db.models import Q from django.template import loader @@ -76,10 +77,7 @@ class IcalFeed(Feed): "location": format_rooms(item.rooms.all())} -class AtomFeed(Feed): - author_name = "CelcatSanitizer" - feed_type = Atom1Feed - +class RSSFeed(Feed): def get_object(self, request, year_slug, timetable_slug, group_slug): year, week = get_current_or_next_week() try: @@ -121,3 +119,9 @@ class AtomFeed(Feed): update.description = template.render(context) return obj[1] + + +class AtomFeed(RSSFeed): + author_name = settings.ADMINS[0][0] + author_email = settings.ADMINS[0][1] + feed_type = Atom1Feed diff --git a/templates/timetable.html b/templates/timetable.html index f4b8719..7a30595 100644 --- a/templates/timetable.html +++ b/templates/timetable.html @@ -6,4 +6,4 @@

{{ group.timetable }} – {{ group }} – Semaine {{ week }}

Dernière mise à jour le {{ last_update|date:"l j F o" }} à {{ last_update|date:"H:i" }}

{% include "timetable_common.html" %} -

ICSAtom

{% endblock %} +

ICSRSSAtom

{% endblock %} diff --git a/urls.py b/urls.py index aaf9b67..2e731b5 100644 --- a/urls.py +++ b/urls.py @@ -23,5 +23,6 @@ urlpatterns = [ 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]+)/feed.rss$", feeds.RSSFeed(), name="rss"), url(r"^(?P[-\w]+)/(?P[-\w]+)/(?P[-\w]+)/(?P[0-9]{4})/(?P[0-4]?[0-9]|5[0-3])/$", views.timetable, name="timetable"), ] -- cgit v1.2.1