Skip to content

Commit

Permalink
feat: RSS feed for I-Ds (ietf-tools#6979)
Browse files Browse the repository at this point in the history
  • Loading branch information
pselkirk committed Mar 7, 2024
1 parent 08e0c83 commit a48cbbe
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 5 deletions.
28 changes: 26 additions & 2 deletions ietf/doc/feeds.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand Down
14 changes: 14 additions & 0 deletions ietf/doc/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
5 changes: 4 additions & 1 deletion ietf/feed_urls.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -20,4 +22,5 @@
url(r'^wg-proceedings/$', LatestMeetingMaterialFeed()),
url(r'^rfc/(?P<year>\d{4})/?$', RfcFeed()),
url(r'^rfc/$', RfcFeed()),
url(r'^draft/?$', DraftFeed()),
]
11 changes: 9 additions & 2 deletions ietf/templates/doc/recent_drafts.html
Original file line number Diff line number Diff line change
@@ -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 %}
Expand All @@ -17,7 +17,14 @@ <h1>
{% endif %}
</h1>
{% include "doc/search/search_results.html" with start_table=True end_table=True %}
{% endcache %}
{% endcache %}
<div>
<a class="btn btn-primary"
title="Feed of recent drafts"
href="/feed/draft/">
<i class="bi bi-rss"></i> Atom feed
</a>
</div>
{% endblock %}
{% block js %}
<script src="{% static "ietf/js/list.js" %}"></script>
Expand Down

0 comments on commit a48cbbe

Please sign in to comment.