From a48cbbe5d2b52b0ead0cf2c613947ee0547fc718 Mon Sep 17 00:00:00 2001 From: Paul Selkirk Date: Tue, 5 Mar 2024 17:17:03 -0500 Subject: [PATCH] feat: RSS feed for I-Ds (#6979) --- ietf/doc/feeds.py | 28 +++++++++++++++++++++++++-- ietf/doc/tests.py | 14 ++++++++++++++ ietf/feed_urls.py | 5 ++++- ietf/templates/doc/recent_drafts.html | 11 +++++++++-- 4 files changed, 53 insertions(+), 5 deletions(-) diff --git a/ietf/doc/feeds.py b/ietf/doc/feeds.py index 500ed3cb18..c5a9ed058d 100644 --- a/ietf/doc/feeds.py +++ b/ietf/doc/feeds.py @@ -1,4 +1,4 @@ -# Copyright The IETF Trust 2007-2020, All Rights Reserved +# Copyright The IETF Trust 2007-2024, All Rights Reserved # -*- coding: utf-8 -*- import debug # pyflakes:ignore @@ -18,7 +18,7 @@ from django.utils import timezone from django.utils.html import strip_tags -from ietf.doc.models import Document, State, LastCallDocEvent, DocEvent +from ietf.doc.models import Document, State, LastCallDocEvent, DocEvent, NewRevisionDocEvent from ietf.doc.utils import augment_events_with_revision from ietf.doc.templatetags.ietf_filters import format_textarea from ietf.utils.timezone import RPC_TZINFO @@ -127,6 +127,30 @@ def item_pubdate(self, item): return item.lc_event.time +class DraftFeed(Feed): + title = "Internet-Drafts" + feed_type = Atom1Feed + author_name = "IESG Secretary" + link ="/doc/recent/" + + def items(self): + since = timezone.now() - datetime.timedelta(days=7) + state = State.objects.get(type='draft', slug='active') + events = NewRevisionDocEvent.objects.filter(time__gt=since) + names = [ e.doc.name for e in events ] + docs = Document.objects.filter(name__in=names, states=state).order_by("-time") + return docs + + def item_title(self, item): + return "%s : %s" % (item.name, item.title) + + def item_description(self, item): + return item.abstract + + def item_pubdate(self, item): + return item.time + + class Rss201WithNamespacesFeed(Rss201rev2Feed): def root_attributes(self): attrs = super(Rss201WithNamespacesFeed, self).root_attributes() diff --git a/ietf/doc/tests.py b/ietf/doc/tests.py index c9e1c041d1..3f44a9431b 100644 --- a/ietf/doc/tests.py +++ b/ietf/doc/tests.py @@ -1932,6 +1932,20 @@ def test_last_call_feed(self): self.assertEqual(r.status_code, 200) self.assertContains(r, doc.name) + def test_draft_feed(self): + doc = WgDraftFactory() + doc.docevent_set.filter(newrevisiondocevent__isnull=False).update(time=timezone.now()) + StateDocEventFactory(doc=doc, time=timezone.now()) + + old = WgDraftFactory() + old.docevent_set.filter(newrevisiondocevent__isnull=False).update(time=timezone.now()-datetime.timedelta(days=8)) + StateDocEventFactory(doc=old, time=timezone.now()-datetime.timedelta(days=8)) + + r = self.client.get("/feed/draft/") + self.assertEqual(r.status_code, 200) + self.assertContains(r, doc.name) + self.assertNotContains(r, old.name) + def test_rfc_feed(self): rfc = WgRfcFactory(rfc_number=9000) DocEventFactory(doc=rfc, type="published_rfc") diff --git a/ietf/feed_urls.py b/ietf/feed_urls.py index 6cbe8d0fa0..6621c1c4c0 100644 --- a/ietf/feed_urls.py +++ b/ietf/feed_urls.py @@ -1,7 +1,9 @@ +# Copyright The IETF Trust 2007-2024, All Rights Reserved + from django.views.generic import RedirectView from django.conf import settings -from ietf.doc.feeds import DocumentChangesFeed, InLastCallFeed, RfcFeed +from ietf.doc.feeds import DocumentChangesFeed, InLastCallFeed, RfcFeed, DraftFeed from ietf.group.feeds import GroupChangesFeed from ietf.iesg.feeds import IESGAgendaFeed from ietf.ipr.feeds import LatestIprDisclosuresFeed @@ -20,4 +22,5 @@ url(r'^wg-proceedings/$', LatestMeetingMaterialFeed()), url(r'^rfc/(?P\d{4})/?$', RfcFeed()), url(r'^rfc/$', RfcFeed()), + url(r'^draft/?$', DraftFeed()), ] diff --git a/ietf/templates/doc/recent_drafts.html b/ietf/templates/doc/recent_drafts.html index 9674ba8b66..27bdd4b392 100644 --- a/ietf/templates/doc/recent_drafts.html +++ b/ietf/templates/doc/recent_drafts.html @@ -1,5 +1,5 @@ {% extends "base.html" %} -{# Copyright The IETF Trust 2015, All Rights Reserved #} +{# Copyright The IETF Trust 2015-2024, All Rights Reserved #} {% load origin static %} {% load cache %} {% block pagehead %} @@ -17,7 +17,14 @@

{% endif %}

{% include "doc/search/search_results.html" with start_table=True end_table=True %} -{% endcache %} + {% endcache %} +
+ + Atom feed + +
{% endblock %} {% block js %}