aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlban Gruin2017-09-09 15:19:42 +0200
committerAlban Gruin2017-09-09 15:19:42 +0200
commit98242cad296b36423daf77e572d7735478d33f1d (patch)
tree71f753a3172008859048832f4a941c258168bc96
parentc7fce37ad4c8dee76f5d58eafefd0c73a03ea00c (diff)
Ajout d’un flux RSS
-rw-r--r--feeds.py12
-rw-r--r--templates/timetable.html2
-rw-r--r--urls.py1
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 <http://www.gnu.org/licenses/>.
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 @@
<h2>{{ group.timetable }} &ndash; {{ group }} &ndash; Semaine {{ week }}</h2>
<p>Dernière mise à jour le {{ last_update|date:"l j F o" }} à {{ last_update|date:"H:i" }}</p>
{% include "timetable_common.html" %}
- <p class="subscribe"><a href="{% url "ics" group.timetable.year.slug group.timetable.slug group.slug %}">ICS</a> &ndash; <a href="{% url "atom" group.timetable.year.slug group.timetable.slug group.slug %}">Atom</a><br /></p>{% endblock %}
+ <p class="subscribe"><a href="{% url "ics" group.timetable.year.slug group.timetable.slug group.slug %}">ICS</a> &ndash; <a href="{% url "rss" group.timetable.year.slug group.timetable.slug group.slug %}">RSS</a> &ndash; <a href="{% url "atom" group.timetable.year.slug group.timetable.slug group.slug %}">Atom</a></p>{% 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<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]+)/calendar.ics$", feeds.IcalFeed(), name="ics"),
url(r"^(?P<year_slug>[-\w]+)/(?P<timetable_slug>[-\w]+)/(?P<group_slug>[-\w]+)/feed.atom$", feeds.AtomFeed(), name="atom"),
+ url(r"^(?P<year_slug>[-\w]+)/(?P<timetable_slug>[-\w]+)/(?P<group_slug>[-\w]+)/feed.rss$", feeds.RSSFeed(), name="rss"),
url(r"^(?P<year_slug>[-\w]+)/(?P<timetable_slug>[-\w]+)/(?P<group_slug>[-\w]+)/(?P<year>[0-9]{4})/(?P<week>[0-4]?[0-9]|5[0-3])/$", views.timetable, name="timetable"),
]